Skip to content
Snippets Groups Projects
Commit 9bec5189 authored by Guillaume Chanel's avatar Guillaume Chanel
Browse files

Change euid if root

parent 5a9170c8
Branches master
No related tags found
No related merge requests found
Pipeline #20744 failed
......@@ -11,6 +11,8 @@ import shutil
from colorama import Fore
import argparse
import sys
import pwd
# TODO: How to include the folder creation in the test function instead of repeating it for all test functions
# TODO: pass over EVERY ASSERTION ERROR (i.e. continu test). But seems unlikely to be done easily
......@@ -258,6 +260,17 @@ if __name__=="__main__":
parser.add_argument('-p', '--no-zero-mode', dest='no_perms', action='store_false', help='tests will NOT include files without any permission (only applies to concerned tests)')
parser.add_argument('-d', '--delete-tests', dest='delete_tests', action='store_true', help='delete the test folders when tests are over')
args = parser.parse_args()
# If effective user id is root change to nobody user (should be available on most machines...)
print(os.geteuid())
if os.geteuid() == 0:
try:
nobody = pwd.getpwnam('nobody')
except:
print("!!! Effective user id is root and user nobody could be be found: some test might be corrupted (e.g. umask)")
os.seteuid(nobody.pw_uid)
t = Test(args.prog_path, delete_root=args.delete_tests)
t.test_listing(args.no_perms)
t.test_file_copy()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment