I'm trying to build a platform to launch some scripts. This scripts are placed in home folder of each user. Every launch should be done with each user id so, I'm doing, for each user, this:
user_id = pwd.getpwnam( user )[ 3 ]
user_home = pwd.getpwnam( user )[ 5 ]
os.chdir( user_home )
os.setuid( user_id )
subprocess.Popen( shlex.split( "user_script.py" ) )
But, when python trys to do os.setuid( user_id )
it raise this exception:
Traceback (most recent call last):
File "launcher.py", line XX, in <module>
OSError: [Errno 1] Operation not permitted
By the way, the user who starts this script is in the root group (on GNU/linux OS) and it has all the root privileges.
If I try to launch the same code with root user I get a different error:
OSError: [Errno 13] Permission denied
If someone can help me to understand what's happening please...
Only root can do a setuid, being in the root-group is not enough.