473,659 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Python Scripts With 'sudo'

Given that setuid is a Bad Thing for scripts, what is the general consensus
here on running a Python script via 'sudo' to give it root system access?
Is this reasonably secure, or am I still asking for trouble?

TIA,
--
----------------------------------------------------------------------------
Tim Daneliuk tu****@tundrawa re.com
PGP Key: http://www.tundraware.com/PGP/

Jul 18 '05 #1
2 3734
Tim Daneliuk wrote:
Given that setuid is a Bad Thing for scripts, what is the general consensus
here on running a Python script via 'sudo' to give it root system access?
Is this reasonably secure, or am I still asking for trouble?

TIA,


The value of "sudo" is that everyone must authenticate as themselves,
and sudo logs all activity. Therefore the system administrators can
partition responsibility and know from the logs exactly who did what.

The risks involved with setuid scripts involve the exploitation of race
conditions within the kernel, IIRC, and since the root permissions are
established by sudo for the invoking process, I believe sudo would
eliminate the risks involved (because the setuid bit would no longer be
used on the script).

regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
Jul 18 '05 #2
Does "sudo" sanitize the environment? Imagine that the user can set
PYTHONPATH, PYTHONINSPECT, etc.

Beyond that, you have the same problems as with any code that runs with
"extra privileges". Can the user supply any code that is fed to
patently unsafe primitives (like the unpickler, eval() or the exec
statement)? If your program opens files with user-controlled names, did
you make all the right checks?

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCJizoJd0 1MZaTXX0RAvBnAK CtvhaxQn5aDGIhc mBCfXgMX+8CUgCe LI3Z
H7bQM84BbIKHWvu AKh59Yb0=
=J0mR
-----END PGP SIGNATURE-----

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2866
by: Rolfe | last post by:
Hi, I struggled, and got mod_python running on Apache/Win2k. Follow these instructions verbatim and you shouldn't have any trouble. These instructions are based on "http://www.modpython.org/live/current/doc-html/inst-testing.html". I've added specific information such as Windows filepaths and filenames so there's no ambiguity on what you should do. I encourage you to copy and paste to avoid typing errors. Cheers, Rolfe
5
7413
by: slava | last post by:
hello, i am writing a python script that will be run by a non root user the script needs to open a file in write mode that is owned by root file = open('/etc/apt/sources.list', 'r+') returns permission error how can i call sudo on open()?
16
2455
by: Thomas Nelson | last post by:
I just purchased a new macbook (os 10.4.6), and I'm trying to install python 2.4 on it. I downloaded and ran the two installers recommended at http://www.python.org/download/mac/. Now I have IDLE, which runs 2.4.1, but typing "python" at a terminal still opens 2.3.5, because it points to /usr/bin/python. Is there a way to run python 2.4 without idle? If I want to do a unix style script, something like #!/usr/bin/python print "hello...
8
11180
by: Bernard Lebel | last post by:
Hello, I would like to know if there is a way to run a Python file under a different user account than the one logged in. Allow me to explain. There are a bunch of people here, they are "basic user", with limited permissions. Basically there are locations on the network where they can only read and execute files, but no way to write. Now, if these users want to write or modify files and directories,
5
9321
by: Marcpp | last post by:
Hi, when i mount a share with python... os.system ("mount -t smbfs -o username=nobody ...") the problem is that I'll to be root. Have a comand to send a root password...? I've tried os.system ("su") os.system ("the password")
27
2909
by: bcwhite | last post by:
I've been trying to find out what the future of Python is with regard to Tk. It seems there are several interfaces that make use of new functionality, including "Tile" and "Ttk". If I want to write a program that will run under the standard Python distribution of the future, what extension module should I work with today? Thanks!
12
1844
by: =?ISO-8859-1?Q?S=E9bastien?= | last post by:
Hi folks, I am currently using Eclipse+PyDev when developping Python projects but I lack a fast, simple editor for tiny bit of scripts. So here is my question: what is, for you, the current best ( but still kind of light! ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking for a linux compatible editor. Cheers,
8
2768
by: geert | last post by:
Hi all, I have a mac mini running maocosx 10.5 leopard I want to deploy a django project on. My backend is MySQL, and I have it running as a 64- bit app. Of course, apache2 is also running as 64-bit. MySQLdb installs with the usual warnings after applying the various patches I found here and there. These patches consist of altering _mysql.c and site.cfg.
1
6922
by: mpc | last post by:
hello, how does one run a PHP page with a python webserver? Lets say i have a simple python web server running /path/webserver.py #!/usr/bin/env python from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler serve = HTTPServer(("",8080),CGIHTTPRequestHandler)
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.