From 2e20e0f42dc1c356569aed4f88093175bef1fbd9 Mon Sep 17 00:00:00 2001 From: Lucas Moura Date: Wed, 18 Nov 2020 17:19:23 -0300 Subject: [PATCH 1/2] Run lxc commands as non root by default --- pycloudlib/lxd/instance.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pycloudlib/lxd/instance.py b/pycloudlib/lxd/instance.py index fc06aeb2..ea85e875 100644 --- a/pycloudlib/lxd/instance.py +++ b/pycloudlib/lxd/instance.py @@ -23,6 +23,7 @@ def __init__(self, name, key_pair=None): super().__init__(key_pair=key_pair) self._name = name + self._user_id = None def __repr__(self): """Create string representation for class.""" @@ -33,7 +34,9 @@ def _run_command(self, command, stdin): if self.key_pair: return super()._run_command(command, stdin) - base_cmd = ['lxc', 'exec', self.name, '--'] + base_cmd = [ + 'lxc', 'exec', self.name, '--', 'sudo', '-u', self.username, '--' + ] return subp(base_cmd + list(command), rcs=None) @property From d5412b7f320756ce86418df897e4feb7d7feb117 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Thu, 26 Nov 2020 16:14:16 -0500 Subject: [PATCH 2/2] Update pycloudlib/lxd/instance.py --- pycloudlib/lxd/instance.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pycloudlib/lxd/instance.py b/pycloudlib/lxd/instance.py index ea85e875..873b92ff 100644 --- a/pycloudlib/lxd/instance.py +++ b/pycloudlib/lxd/instance.py @@ -23,7 +23,6 @@ def __init__(self, name, key_pair=None): super().__init__(key_pair=key_pair) self._name = name - self._user_id = None def __repr__(self): """Create string representation for class."""