aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-9p.c
diff options
context:
space:
mode:
authorVenkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>2010-06-14 13:34:45 -0700
committerAnthony Liguori <aliguori@us.ibm.com>2010-06-22 15:15:50 -0500
commit4750a96f6baf8949cc04a0c5b7167606544a4401 (patch)
tree59dfed5f2adfb3fb546c078119629e3eca599d82 /hw/virtio-9p.c
parent1237ad7607aae5859067831e36a59d3b017c5a54 (diff)
virtio-9p: Security model for create/open2
In the mapped security model, VirtFS server intercepts and maps the file object create and get/set attribute requests. Files on the fileserver will be created with VirtFS servers (QEMU) user credentials and the client-users credentials are stored in extended attributes. On the request to get attributes, server extracts the client-users credentials from extended attributes and sends them to the client. On Host/Fileserver: -rw-------. 2 virfsuid virtfsgid 0 2010-05-11 09:19 afile On Guest/Client: -rw-r--r-- 2 guestuser guestuser 0 2010-05-11 12:19 afile 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.c')
-rw-r--r--hw/virtio-9p.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index fa459c9260..49a3065be9 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -180,9 +180,17 @@ static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf)
return s->ops->fstat(&s->ctx, fd, stbuf);
}
-static int v9fs_do_open2(V9fsState *s, V9fsString *path, int flags, mode_t mode)
+static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs)
{
- return s->ops->open2(&s->ctx, path->data, flags, mode);
+ FsCred cred;
+ int flags;
+
+ cred_init(&cred);
+ cred.fc_uid = vs->fidp->uid;
+ cred.fc_mode = vs->perm & 0777;
+ flags = omode_to_uflags(vs->mode) | O_CREAT;
+
+ return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred);
}
static int v9fs_do_symlink(V9fsState *s, V9fsString *oldpath,
@@ -1815,9 +1823,7 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
err = v9fs_do_mksock(s, &vs->fullname);
v9fs_create_post_mksock(s, vs, err);
} else {
- vs->fidp->fd = v9fs_do_open2(s, &vs->fullname,
- omode_to_uflags(vs->mode) | O_CREAT,
- vs->perm & 0777);
+ vs->fidp->fd = v9fs_do_open2(s, vs);
v9fs_create_post_open2(s, vs, err);
}