Python prog needs root -how to do this securely

John D. lists at webcrunchers.com
Mon Aug 25 02:57:57 CEST 2003


I have a Python program which runs as user 'www' (it's a CGI).
It needs root privilege to write a particular file.
What's the best way of doing this while remaining secure?

Right now I do os.system("sudo myutil parms") and pass the parms to it.
I remove : < > & | from the parm string before passing it.
Is there a way to do this without making a system call?
i.e.
gimme_root()
my code...
drop_root()








More information about the Python-list mailing list