Commit cbd4c464 by Stéphane Graber

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: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 767d4c67
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment