From 4750a96f6baf8949cc04a0c5b7167606544a4401 Mon Sep 17 00:00:00 2001 From: "Venkateswararao Jujjuri (JV)" Date: Mon, 14 Jun 2010 13:34:45 -0700 Subject: 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 Signed-off-by: Anthony Liguori --- hw/virtio-9p.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'hw/virtio-9p.c') 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); } -- cgit v1.2.3