Getting SuperUser Authority From Within Running Python Program

Laura Creighton lac at
Sun Jan 26 01:29:26 CET 2003

> Is there a way to have a running Python program acquire super-user status
> (assuming the program knows the correct password)?  If so, is this
> method portable to Win32 or will Unix and Win32 need different implementation
> s?
> TIA,
> -- 
> -----------------------------------------------------------------------------
> -
> Tim Daneliuk
> tundra at

You do not want to do this.  You do not want a super-user shell out
there, ever, and without that there is no need or use for password
things. You will totally circumvent all the security mechanisms you
have.  The unix way to do something as root is to make a setuid
program -- NOT a shell script-- that does whatever you want done as
root and does that and only that.  You exec that when you want it. The
authority comes from the person who is allowed to change the
permission bits on a file, owned by root, to make it setuid. I have no
idea what you do for Win32, but I know for certain that this is not

Please post what you want to do as root and why so we can figure out
what is the best thing for you to do.  


More information about the Python-list mailing list