Skip to content

Commit 903cecf

Browse files
committed
Fix for the case where root is actually running the tool
1 parent 7bed3a5 commit 903cecf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nordnm/__main__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ def main():
2020
print("%s must be run as root (unfortunately). Exiting." % __package__)
2121
sys.exit(1)
2222

23-
# We are running with root priveledges, which is kinda scary, so lets switch to the original user until we actually need root
24-
os.seteuid(int(os.getenv("SUDO_UID")))
23+
# We are running with root priveledges, which is kinda scary, so lets switch to the original user until we actually need root (if there is one)
24+
user_uid = os.getenv("SUDO_UID")
25+
if user_uid:
26+
os.seteuid(int(user_uid))
2527

2628
# Add our custom logging formatter function to handle all logging output
2729
formatter = utils.LoggingFormatter()

0 commit comments

Comments
 (0)