Python prog needs root -how to do this securely  Andrew McNamara
andrewm at Mon Aug 25 03:57:32 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?  What you
are talking about is "setuid" - it's best avoided unless you are
an expert (and even they get caught out - there are many gotchya
- use google if you care). You generally can't make scripts
setuid.  It's generally considered a good idea to have the
minimum amount of code possible running with elevated
priviledges - rather than making the entire application
priviledged, you might have it ask a priviledged daemon to do
the work instead.  With security, you always err on the side of
caution - in your message above, rather than removing so