469,342 Members | 5,936 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

Python prog needs root -how to do this securely

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()


Jul 18 '05 #1
1 1284
John D. <li***@webcrunchers.com> wrote:
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?


With your approach you have to be aware that users on the system will probably
be able to view the parameters your are passing to myutil. Whether this is a
problem depends on your particular setup.

One alternative would be to make nobody, apache, etc. (which ever your apache
server runs under) the group owners of the file and give the apache group
write permissions to the file. This may not be feasible for your setup.

--
----------------------------------------------------------------------------
Suchandra Thapa
s-********@NOSPAMalumni.uchicago.edu
----------------------------------------------------------------------------
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ben Eisenberg | last post: by
4 posts views Thread by Edward K. Ream | last post: by
2 posts views Thread by Rien Kok | last post: by
2 posts views Thread by abhinav | last post: by
24 posts views Thread by Mark | last post: by
9 posts views Thread by Katie Tam | last post: by
3 posts views Thread by Jeffrey Froman | last post: by
reply views Thread by Tomas | last post: by
2 posts views Thread by Jean-Paul Calderone | last post: by
5 posts views Thread by aha | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.