aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-9p-local.c
diff options
context:
space:
mode:
authorVenkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>2010-06-14 13:34:46 -0700
committerAnthony Liguori <aliguori@us.ibm.com>2010-06-22 15:15:51 -0500
commit00ec5c37601accb2b85b089d72fc7ddff2f4222e (patch)
treea36bb07705c0045bc2db955115274e32071dae7c /hw/virtio-9p-local.c
parent4750a96f6baf8949cc04a0c5b7167606544a4401 (diff)
virtio-9p: Security model for mkdir
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-9p-local.c')
-rw-r--r--hw/virtio-9p-local.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index bb5140efce..e99eff9639 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -207,9 +207,40 @@ static int local_mksock(FsContext *ctx2, const char *path)
return 0;
}
-static int local_mkdir(FsContext *ctx, const char *path, mode_t mode)
+static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)
{
- return mkdir(rpath(ctx, path), mode);
+ int err = -1;
+ int serrno = 0;
+
+ /* Determine the security model */
+ if (fs_ctx->fs_sm == SM_MAPPED) {
+ err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS);
+ if (err == -1) {
+ return err;
+ }
+ credp->fc_mode = credp->fc_mode|S_IFDIR;
+ err = local_set_xattr(rpath(fs_ctx, path), credp);
+ if (err == -1) {
+ serrno = errno;
+ goto err_end;
+ }
+ } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
+ err = mkdir(rpath(fs_ctx, path), credp->fc_mode);
+ if (err == -1) {
+ return err;
+ }
+ err = local_post_create_passthrough(fs_ctx, path, credp);
+ if (err == -1) {
+ serrno = errno;
+ goto err_end;
+ }
+ }
+ return err;
+
+err_end:
+ remove(rpath(fs_ctx, path));
+ errno = serrno;
+ return err;
}
static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf)