Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python prog needs root -how to do this securely

Reply
Thread Tools

Python prog needs root -how to do this securely

 
 
John D.
Guest
Posts: n/a
 
      08-25-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()




 
Reply With Quote
 
 
 
 
Suchandra Thapa
Guest
Posts: n/a
 
      09-04-2003
John D. <> 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-thapa-
----------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Securely distributing python source code as an application? xkenneth Python 6 12-11-2007 10:24 AM
Starting and stopping a prog. from another prog. andoni.oconchubhair@ie.fid-intl.com Java 1 10-22-2006 10:43 PM
SRT DIvision, Square root and reciprocal square root alghazo@siu.edu VHDL 0 05-27-2004 06:23 AM
securely overwrite files with Python Bart Nessux Python 11 03-06-2004 08:02 PM
Tertiary Conditional: what does this evaluate to ("docRoot == null ? this.root : doc root")? Rick Osborn Java 10 02-08-2004 02:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57