# set uid programs



## daemonSlayer (Mar 12, 2010)

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:


```
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:

```
-rwsr-xr-x  1 root
```

Any idea why this doesn't work


----------



## fronclynne (Mar 13, 2010)

Would python itself be disallowing users to run setuid scripts?


----------



## daemonSlayer (Mar 13, 2010)

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.


----------



## Alt (Mar 13, 2010)

I think when you do 
	
	



```
user$ python script.py
```
 you run python, not script, so setuid not working


----------



## sixtydoses (Mar 13, 2010)

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`?


----------



## wonslung (Mar 14, 2010)

sudo would be the way to go.

you can do something like this:

```
%somegroup ALL=(root) NOPASSWD: /usr/local/bin/python26, /usr/local/bin/somescript, /usr/local/bin/whatever
```


----------

