permission problem with os.setuid

Michele Simionato michele.simionato at gmail.com
Fri Sep 17 18:16:44 CEST 2004


Benjamin Niemann <b.niemann at betternet.de> wrote in message news:<cieb24$d6s$1 at online.de>...
> Once a process is running as nobody (or any other non-root user account), you 
> cannot simple change the uid - that's a (very important) feature not a bug! To 
> change the uid you have to be root first, 'sudo' may help you - though I don't 
> know about the details how this works...
> Possible pseudocode (and by pseudo I mean pseudo ;)
> 
> if os.getuid() == 0: # I'm root
>    os.setuid(501)
> elif os.getuid() != 501:
>    os.exec*("sudo", "myscript.py") # script is restarted, now as root
> 
> assert os.getuid() == 501

Uhm ... I wanted somewhat to avoid "sudo". Anyway, at the end I have decided
to change the design so that the script is always run as nobody.
This solves as well other issues and I am happy with it.


                 Michele Simionato



More information about the Python-list mailing list