mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-02 18:48:41 +00:00
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:
parent
767d4c6743
commit
cbd4c46406
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user