set uid programs

I have a python script that I want any user to be able to run as root. I understand the risks, but I am the only the user on this machine. Here is what I have done:

Code:
root# chown root script.py
root# chmod 4755 script.py
user$ python script.py
operation not permitted

Here is what the permissions of script.py look like:
Code:
-rwsr-xr-x  1 root

Any idea why this doesn't work
 
That would be odd since python provides a os.setuid() function, which I tried using in my suid script and it wouldn't allow it (maybe it just doesn't like you setting the uid to 0?). BTW, the reason I need this suid script is so I can start a python web server on port 80.
 
I think when you do
Code:
user$ python script.py
you run python, not script, so setuid not working
 
Alt is right. You have to set the setuid on /usr/local/bin/python instead of your script. Which is not a good idea.

Why not use $ sudo?
 
sudo would be the way to go.

you can do something like this:
Code:
%somegroup ALL=(root) NOPASSWD: /usr/local/bin/python26, /usr/local/bin/somescript, /usr/local/bin/whatever
 
Back
Top