Asking a user for the root password and executing root only commands...
Jeff Epler
jepler at unpythonic.net
Wed Oct 30 22:35:35 EST 2002
On Wed, Oct 30, 2002 at 07:29:22PM -0800, logistix wrote:
> >
> > How could I achieve this?
>
> Smart-ass answer: don't, if a user can't su, they should be making
> changes
>
> Real answer:
> sudo /sbin/chown root.wheel script.py
> sudo chmod 4770 script.py
Smart-ass answer: do you actually test the crap you spew?
[jepler at anchor jepler]$ cat test.py
#!/usr/bin/python
import os; print os.getuid()
[jepler at anchor jepler]$ chmod +x test.py
[jepler at anchor jepler]$ ./test.py
405
[jepler at anchor jepler]$ sudo chown root.root test.py
[jepler at anchor jepler]$ sudo chmod 4755 test.py
[jepler at anchor jepler]$ ./test.py
405
Jeff
More information about the Python-list
mailing list