[libvirt] [sandbox PATCH 1/6] Add UID/GID support for use with interactive containers.

dwalsh at redhat.com dwalsh at redhat.com
Thu Apr 18 18:34:50 UTC 2013


From: Dan Walsh <dwalsh at redhat.com>

Openshift Containers will be run with a unique UID and GID
---
 bin/virt-sandbox-service | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index ad01649..d3dceea 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -83,10 +83,16 @@ class Container:
         self.file_type = file_type
 
     def set_uid(self, uid):
-        self.uid = uid
+        return self.config.set_userid(uid)
 
     def get_uid(self):
-        return self.uid
+        return self.config.get_userid(uid)
+
+    def set_gid(self, gid):
+        return self.config.set_groupid(gid)
+
+    def get_gid(self):
+        return self.config.get_groupid(gid)
 
     def get_config_path(self, name = None):
         if not name:
@@ -846,6 +852,8 @@ def create(args):
         container.add_network(net)
     if args.security:
         container.set_security(args.security)
+    container.set_uid(args.uid)
+    container.set_gid(args.gid)
     container.set_path(args.path)
     container.set_file_type(args.file_type)
     if args.imagesize:
@@ -1043,6 +1051,9 @@ def gen_create_args(subparser):
     parser.add_argument("-f", "--filetype", dest="file_type",
                         default=c.get_file_type(),
                         help=_("SELinux file type to assign to content within the sandbox.  Default: %s") % c.get_file_type())
+    parser.add_argument("-G", "--gid", dest="gid",
+                        default=0, type=int,
+                        help=_("Specify the gid for the container"))
     parser.add_argument("-i", "--imagesize", dest="imagesize", default = None,
                        action=SizeAction,
                        help=_("create image of this many megabytes."))
@@ -1058,6 +1069,9 @@ def gen_create_args(subparser):
                         action=CheckUnit,
                         dest="unitfiles", default=[],
                         help=_("Systemd Unit file to run within the Service sandbox container. Commands cannot be specified with unit files."))
+    parser.add_argument("-U", "--uid", dest="uid",
+                        default=0,type=int,
+                        help=_("Specify the uid for the container"))
 
     requires_name(parser)
     parser.add_argument("command", default=[], nargs="*",
-- 
1.8.2




More information about the libvir-list mailing list