Superuser authority (again)

Michele Simionato mis6 at pitt.edu
Tue Feb 11 12:23:32 EST 2003


"Wouter van Marle" <wouterm at spammers-unite-here.com> wrote in message news:<b29upv$7du4 at imsp212.netvigator.com>...
> Hi all.
> 
> I have a similar problem as outlined by Tim Daneliuk in the thread a few
> weeks ago - I need to perform some superuser action. I was already so far
> (before reading the thread) to not want the script to know the password -
> the user will have to give this password. This also because the script will
> have to be distributed.
> 
> Background: I have a fax application, and want it to interact with the
> mgetty and sendfax config files. Also I want to write an automated
> installer. Reading those config files of course works fine, now I want the
> program to also be able to write to these files. That requires root
> permissions.
> 
> So what I am thinking of: when the user has changed some setting and wants
> to save those files, he will have to give the root password.
> Basically all the script has to do as root, is invoke a copy command, to
> copy the updated config file from the user-writable temporary directory, to
> the /etc/mgetty+sendfax directory.
> Same for the installation: files can first be stored in the temp directory,
> and then copied to the final destination.
> 
> How to do this 'copy with root permissions'? And related: setting the
> correct ownership of the files (with root permissions again).
> 
> Secondly I would like to know what you think about having the user give the
> password for every single action (copying and chown-ing of a batch counting
> as a single action), or once per session?
> 
> Wouter.

IIRC, on linux, you can can go with

os.system("su -c 'python script_doing_what_I_want_with_root_permissions.py'")

(not sure 100%). Hope this helps,

                                        Michele




More information about the Python-list mailing list