sudo open() ? (python newbee question)

Denis WERNERT penguin_archer at yahoo.com
Tue Jun 14 05:52:13 EDT 2005


The script could be SUID Root, and you could use os.setuid immediately after
having performed the task to switch to a non-priviledged user. May be a big
security risk, if someone can alter the script, he gains root access to the
system...

slava at crackpot.org wrote:

> hello,
> 
> i am writing a python script that will be run by a non root user
> the script needs to open a file in write mode that is owned by root
> 
> file = open('/etc/apt/sources.list', 'r+')
> 
> returns permission error
> 
> how can i call sudo on open()?
> 
> thanks alot
> slava



More information about the Python-list mailing list