1

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?

Bee
  • 195
  • 1
  • 3
  • 12
  • 1
    I think it is not possible to use suid on scripts: https://unix.stackexchange.com/questions/364/allow-setuid-on-shell-scripts#2910 – Heap Underflow Aug 06 '20 at 23:33
  • @HeapUnderflow That's what I'm starting to think too. Since my code is a cgi script, I'm looking into using Apache's suEXEC to run it as a certain user. – Bee Aug 12 '20 at 15:10

0 Answers0