container will create /dev/pts directory in /dev.
the owner of /dev should be the root user of container.

Signed-off-by: Gao feng <gaof...@cn.fujitsu.com>
---
 src/lxc/lxc_controller.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 4660f25..f892ce3 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1191,6 +1191,13 @@ virLXCControllerSetupDev(virLXCControllerPtr ctrl)
     char *opts = NULL;
     char *dev = NULL;
     int ret = -1;
+    uid_t uid = (uid_t)-1;
+    gid_t gid = (gid_t)-1;
+
+    if (ctrl->def->idmap.uidmap) {
+        uid = ctrl->def->idmap.uidmap[0].target;
+        gid = ctrl->def->idmap.gidmap[0].target;
+    }
 
     VIR_DEBUG("Setting up /dev/ for container");
 
@@ -1231,6 +1238,13 @@ virLXCControllerSetupDev(virLXCControllerPtr ctrl)
         goto cleanup;
     }
 
+    if (chown(dev, uid, gid) < 0) {
+        virReportSystemError(errno,
+                             _("Failed to change owner of %s to %d:%d"),
+                             dev, uid, gid);
+        goto cleanup;
+    }
+
     ret = 0;
 
 cleanup:
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to