Asking a user for the root password and executing root only commands...
logistix at zworg.com
Thu Oct 31 04:29:22 CET 2002
> How could I achieve this?
Smart-ass answer: don't, if a user can't su, they should be making
sudo /sbin/chown root.wheel script.py
sudo chmod 4770 script.py
Of course suid'ing programs is very dangerous, but that's what it was
designed for (letting someone run a program with privleges they don't
have) If you do this you should try to minimize the amount of script
that's suid'ed. For example, have the gui run safely as user, and
then when the execute 'special' commmands, use os.popen() to hit the
> They should get a nice qt windows asking for the root password, wich will
> then check if that's the correct password by probably su'ing?
Grab the hashed password from the passwd file. Hash whatever the user
types in with python's crypt.crypt(). If the strings are equal, the
password is right.
You could also have python generate a shell script, and then force the
user to su and run said script.
More information about the Python-list