I have been attempting to get some knowledge of how privileges can be changed within a running Bash script, with some little success.
From within a running Bash script a command can be launched as root which will ask for the required password. Of course the command can be launched as any user too ..... Options -c for root and -u followed by username, for another user, when using kdesu.
kdesu -u test dolphin # launches Dolphin as user 'test'
kdesu -c dolphin # launches Dolphin as user root
So what if you have several commands to be executed?
This format works .... giving both Dolphin and Konqueror launched as user root. It requires the password to be input only once to run both commands.
kdesu -c 'dolphin; konqueror --profile filemanagement'
So now I am wondering how far this can be taken in a Bash script.
On initial reading I was unsure this much was even possible
It might be useful for instance if a bunch of commands could be placed in a function and the function called as root, but I believe this is not possible.
So all that leads to the question ...... is there some way that commands that require root privileges can be run in a user-level Bash script, requiring the input of the password only once for all of them, without changing the privileg of the running Bash script itself?
I am just trying to explore the limits of what is possible in Bash scripts.
Using the one line example above would not be suitable for lots of commands.
I just know I will be asked ...... real world application of this? ..... I have no idea at the moment ...... just want to know the limitations ...
regards.