[libvirt] [PATCH v4 10/10] LXC: fuse: Change files owner to the root user of container

Gao feng gaofeng at cn.fujitsu.com
Fri Jun 7 07:12:27 UTC 2013


The owner of the /proc/meminfo in container should
be the root user of container.

Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
---
 src/lxc/lxc_fuse.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index 32886cd..b98a0d9 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -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;
-- 
1.8.1.4




More information about the libvir-list mailing list