I want to check if the setuid bit is correct for my Python script, so I'm trying to add some code to print the user that's running it.
I tried getpass.getuser()
but I believe that looks at environment variables to determine the user. I don't think a setuid bit is altering environment variables.
I also tried os.geteuid()
but that prints out a number and I'm not sure how to correlate that to a username.
Is there any other way to check the effective user of a Python script?