mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
test-runner: remove root user requirement from log/monitor/result
Certain aspects of QEMU like mounting host directories may still require root access but for UML this is not the case. To handle both cases first check if SUDO_UID/GID are set and use those to obtain the actual users ID's. Otherwise if running as non-root use the UID/GID of the user directly.
This commit is contained in:
parent
7104e12667
commit
641f558b3d
@ -305,18 +305,12 @@ class RunnerAbstract:
|
|||||||
|
|
||||||
# For QEMU/UML --log, --monitor, --result
|
# For QEMU/UML --log, --monitor, --result
|
||||||
def _prepare_outfiles(self):
|
def _prepare_outfiles(self):
|
||||||
gid = None
|
|
||||||
append_gid_uid = False
|
append_gid_uid = False
|
||||||
|
|
||||||
if os.environ.get('SUDO_GID', None):
|
uid = int(os.environ.get('SUDO_UID', os.getuid()))
|
||||||
uid = int(os.environ['SUDO_UID'])
|
gid = int(os.environ.get('SUDO_GID', os.getgid()))
|
||||||
gid = int(os.environ['SUDO_GID'])
|
|
||||||
|
|
||||||
if self.args.log:
|
if self.args.log:
|
||||||
if os.getuid() != 0:
|
|
||||||
print("--log can only be used as root user")
|
|
||||||
quit()
|
|
||||||
|
|
||||||
append_gid_uid = True
|
append_gid_uid = True
|
||||||
|
|
||||||
if not os.path.exists(self.args.log):
|
if not os.path.exists(self.args.log):
|
||||||
@ -326,20 +320,12 @@ class RunnerAbstract:
|
|||||||
os.chown(self.args.log, uid, gid)
|
os.chown(self.args.log, uid, gid)
|
||||||
|
|
||||||
if self.args.monitor:
|
if self.args.monitor:
|
||||||
if os.getuid() != 0:
|
|
||||||
print("--monitor can only be used as root user")
|
|
||||||
quit()
|
|
||||||
|
|
||||||
append_gid_uid = True
|
append_gid_uid = True
|
||||||
|
|
||||||
self.args.monitor_parent = os.path.abspath(
|
self.args.monitor_parent = os.path.abspath(
|
||||||
os.path.join(self.args.monitor, os.pardir))
|
os.path.join(self.args.monitor, os.pardir))
|
||||||
|
|
||||||
if self.args.result:
|
if self.args.result:
|
||||||
if os.getuid() != 0:
|
|
||||||
print("--result can only be used as root user")
|
|
||||||
quit()
|
|
||||||
|
|
||||||
append_gid_uid = True
|
append_gid_uid = True
|
||||||
|
|
||||||
self.args.result_parent = os.path.abspath(
|
self.args.result_parent = os.path.abspath(
|
||||||
|
Loading…
Reference in New Issue
Block a user