Becoming root within a Python script

Mark Krischer mkrisch at radiata.com
Thu Sep 23 22:44:09 EDT 1999


why don't you call the python script using sudo, or make a wrapper
script that calls sudo <scriptname>.py

(sudo lets a user run an executable as root--i know it exists on linux,
i assume it can be compiled for other unices....)

--mk

Siggy Brentrup wrote:
> 
> François Pinard <pinard at iro.umontreal.ca> writes:
> 
> > Hi, people.  I have a small problem, for which I see no elegant solution yet.
> > Is there a common idiom I could use?
> >
> > I would like, within a executing Python started as non-root, ask for the root
> > password, and then, continue executing part of the script while being root,
> > becoming the previous again after some sub-job is done.
> >
> > Of course, I can kludge something in, but I would prefer something nice. :-)
> 
> What you are asking for requires suid root scripts, a really bad thing
> modern Unices don't allow any more.
> 
> You have to hack up a wrapper written a compiled language, which
> starts the interpreter with root priveledge.
> 
> A while ago I did some work on such a beast using an md5 registry for
> trusted scripts, but after rethinking I threw it away - just to big a
> security risk.
> 
> CU
>   Siggy
> 
> --
> noch nichts Aufregendes:
> 
> Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134




More information about the Python-list mailing list