]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
LXC: fuse: Change files owner to the root user of container
authorGao feng <gaofeng@cn.fujitsu.com>
Fri, 7 Jun 2013 07:12:27 +0000 (15:12 +0800)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 2 Jul 2013 10:20:05 +0000 (11:20 +0100)
The owner of the /proc/meminfo in container should
be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
src/lxc/lxc_fuse.c

index 32886cd253e3c1f245f4985900f87c85b55494bf..b98a0d9973dcd5ba465660595231b23eb8833e79 100644 (file)
@@ -48,6 +48,8 @@ static int lxcProcGetattr(const char *path, struct stat *stbuf)
     int res;
     char *mempath = NULL;
     struct stat sb;
+    struct fuse_context *context = fuse_get_context();
+    virDomainDefPtr def = (virDomainDefPtr)context->private_data;
 
     memset(stbuf, 0, sizeof(struct stat));
     if (virAsprintf(&mempath, "/proc/%s", path) < 0) {
@@ -66,6 +68,8 @@ static int lxcProcGetattr(const char *path, struct stat *stbuf)
             goto cleanup;
         }
 
+        stbuf->st_uid = def->idmap.uidmap ? def->idmap.uidmap[0].target : 0;
+        stbuf->st_gid = def->idmap.gidmap ? def->idmap.gidmap[0].target : 0;
         stbuf->st_mode = sb.st_mode;
         stbuf->st_nlink = 1;
         stbuf->st_blksize = sb.st_blksize;