[pygtk] running pygtk application with root privileges

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 12 08:32:48 WST 2007

Miki wrote:

> How can I run pygtk application in root (setuid) mode

It would be very dangerous to run the whole application
setuid, since what a Python program does depends a lot
on the environment (via PYTHONPATH, etc).

The usual advice in situations like this is to write
a small C program that does just the parts that really
need privilege, make that setuid, and control it from
the main application.

> or how can I ask the user to enter the root password

If the user needs to know the root password, then this
is a very different situation from "any user" being
able to run it! The sudo mechanism is better for this,
since it allows specific users to be given specific
abilities without having to give them the root password.


More information about the pygtk mailing list