All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/6] test-runner: remove root user requirement from log/monitor/result
@ 2022-05-25 19:37 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-05-25 19:37 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1673 bytes --]

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.
---
 tools/runner.py | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/tools/runner.py b/tools/runner.py
index 1739b786..7c177f1f 100644
--- a/tools/runner.py
+++ b/tools/runner.py
@@ -305,18 +305,12 @@ class RunnerAbstract:
 
 	# For QEMU/UML --log, --monitor, --result
 	def _prepare_outfiles(self):
-		gid = None
 		append_gid_uid = False
 
-		if os.environ.get('SUDO_GID', None):
-			uid = int(os.environ['SUDO_UID'])
-			gid = int(os.environ['SUDO_GID'])
+		uid = int(os.environ.get('SUDO_UID', os.getuid()))
+		gid = int(os.environ.get('SUDO_GID', os.getgid()))
 
 		if self.args.log:
-			if os.getuid() != 0:
-				print("--log can only be used as root user")
-				quit()
-
 			append_gid_uid = True
 
 			if not os.path.exists(self.args.log):
@@ -326,20 +320,12 @@ class RunnerAbstract:
 				os.chown(self.args.log, uid, gid)
 
 		if self.args.monitor:
-			if os.getuid() != 0:
-				print("--monitor can only be used as root user")
-				quit()
-
 			append_gid_uid = True
 
 			self.args.monitor_parent = os.path.abspath(
 						os.path.join(self.args.monitor, os.pardir))
 
 		if self.args.result:
-			if os.getuid() != 0:
-				print("--result can only be used as root user")
-				quit()
-
 			append_gid_uid = True
 
 			self.args.result_parent = os.path.abspath(
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/6] test-runner: remove root user requirement from log/monitor/result
@ 2022-05-25 20:00 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-05-25 20:00 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

Hi James,

On 5/25/22 14:37, James Prestwood wrote:
> 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.
> ---
>   tools/runner.py | 18 ++----------------
>   1 file changed, 2 insertions(+), 16 deletions(-)
> 

All applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-25 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 19:37 [PATCH v2 1/6] test-runner: remove root user requirement from log/monitor/result James Prestwood
2022-05-25 20:00 Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.