From 0ad889f55d97f14193fbb7e452e70e4767d81437 Mon Sep 17 00:00:00 2001 From: Alan De Smet <alan.desmet@ssec.wisc.edu> Date: Tue, 8 Apr 2025 11:39:44 -0500 Subject: [PATCH] CI: Try to run as nobody if running as root One of the tests relies on there being a file we cannot update the update time on, which doesn't work as root. --- csppfetch/test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/csppfetch/test.py b/csppfetch/test.py index da48259..68b5f92 100755 --- a/csppfetch/test.py +++ b/csppfetch/test.py @@ -1121,4 +1121,12 @@ if __name__ == '__main__': import logging #logging.basicConfig(format='%(process)d:%(levelname)s:%(message)s', level=logging.DEBUG) + if os.getuid() == 0: + import pwd + try: + pwent = pwd.getpwnam("nobody") + except KeyError: + raise Exception("Running as root; tried to switch to 'nobody', but there is no account by that name") + os.setuid(pwent.pw_uid) + unittest.main() -- GitLab