Raise exception when getting Container instance as non-root in python3-lxc

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>
This commit is contained in:
Stéphane Graber 2012-09-06 16:06:27 -04:00
parent 767d4c6743
commit cbd4c46406

View 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)