]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Raise exception when getting Container instance as non-root in python3-lxc
authorStéphane Graber <stgraber@ubuntu.com>
Thu, 6 Sep 2012 20:06:27 +0000 (16:06 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 12 Nov 2012 18:17:54 +0000 (13:17 -0500)
The liblxc API currently doesn't work as non-root, so check that the euid
is 0 when getting a Container instance in the python API.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
src/python-lxc/lxc/__init__.py

index 94616f59abb0837c88957227f1e2959922781169..5fa99ed414ecaca5e24d614492aeb550d836414f 100644 (file)
@@ -32,6 +32,7 @@ import warnings
 warnings.warn("The python-lxc API isn't yet stable "
               "and may change at any point in the future.", Warning, 2)
 
+
 class ContainerNetwork():
     props = {}
 
@@ -142,6 +143,9 @@ class Container(_lxc.Container):
             Creates a new Container instance.
         """
 
+        if os.geteuid() != 0:
+            raise Exception("Running as non-root.")
+
         _lxc.Container.__init__(self, name)
         self.network = ContainerNetworkList(self)