Running one Python program from another as a different user

Mike Meyer mwm at mired.org
Fri Aug 12 22:21:27 EDT 2005


"dwelch91 at gmail.com" <dwelch91 at gmail.com> writes:

> Greetings-
> This is on Linux... I have a daemon running as root and I want to
> execute another Python program as another user (a regular user). I have
> the name of the user and can use the 'pwd' and 'grp' modules to get
> that user's user and group ids. What I don't understand is how to then
> go about launching that new program. I had considered having the
> launched program switch itself back to the target user (somehow), but
> the launched program is graphical in nature (PyQt), and I am afraid of
> X11 locking out the display to user root (many distros seem to ship
> with server access for user root turned off). That might prevent the
> launched program from even starting?
>
> Any ideas? My Google searching was not successful in figuring this
> out...

Well, Jeff already pointed out running su. You might also check the
os.setuid docs, and the setuid man page.

         <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list