I'm very inexperienced when it comes to UNIX privileges. I have a Python script that starts some other Python scripts and also other programs like tcpdump
. All those processes are started via subprocess.Popen, some of the programs are opened in terminals (via the x-terminal-emulator -e
option).
Some of the scripts/programs need to be started as root, however. I have tried to split up the whole functionality in smaller scripts and only use sudo when it's necessary. Now my problem is that my setup requires me to enter my root password like 3 or 4 times everytime I start up the whole thing.
What I am looking for is a way to enter my password once when I start the original script, but only grant actual root permissions at specified places in my scripts. Can anyone help me out? :)
One way of doing this is to start as root, fork all sub-processes and then drop your privileges in the (sub-)processes that don't need the privileges.
For an example, see here
There are some other suggestions as well in the same post.