473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1376
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Eisenberg | last post by:
I'm trying to run a php script setuid. I've tried POSIX_setuid but you have to be root to run this. The files are located on a public access unix system and have me as the owner and nobody as the...
4
by: Edward K. Ream | last post by:
Previous to Python 2.3 my app has destroyed the root Tk window using root.destroy rather than the more usual root.quit. In Python 2.3 this does not work so well. In some situations (i.e., for some...
2
by: Rien Kok | last post by:
Hi, I have a strange problem. I want to install Plone (Plone2-2.0.0rh-2.i386.rpm) Because Plone 2.0 needs Python 2.3.3, I installed Python 2.3.3 from source (Python-2.3.3.tar). Everything...
2
by: abhinav | last post by:
//A CRAWLER IMPLEMENTATION please run this prog. on the shell and under the control of debugger when this prog. is run normally the prog. does not terminate .It doesn't come out of the cond. if...
24
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm...
9
by: Katie Tam | last post by:
I am new to this filed and begin to learn this langague. Can you tell me the good books to start with ? Katie Tam Network administrator http://www.linkwaves.com/main.asp...
3
by: Jeffrey Froman | last post by:
Hello All, I have two python versions installed, one in /usr/bin, and one in /usr/local/bin. However, when invoking python without a full path, I get the wrong executable with the right...
0
by: Tomas | last post by:
Dear group. I have some big problems getting python to work with svn. Python SVN and SWIG is compiled from source. I have been testing Python 2.5.1 and 2.4.4 together with SWIG 1.3.25 and 1.3.33...
2
by: Jean-Paul Calderone | last post by:
On Mon, 16 Jun 2008 08:39:52 +1000, Ben Finney <bignose+hates-spam@benfinney.id.auwrote: Maybe. I'm no expert on Debian packaging. However, exarkun@boson:~$ ls -l...
5
by: aha | last post by:
Hello All, I have a situation where I can count on a Python installation being available on a system, but I can't count on it being a version of Python needed by my application. Since my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.