Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ask for root password but perform the action at a later time?

I have a python script that I would like to add a "Shutdown when done" feature to.

I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).

I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.

Any ideas how I can achieve this?

Thanks in advance, Ashy.

like image 402
Ashy Avatar asked Nov 04 '08 22:11

Ashy


2 Answers

Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better..

As for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script?

like image 196
dbr Avatar answered Sep 27 '22 16:09

dbr


gksudo should have a timeout, I believe it's from the time you last executed a gksudo command.

So I think I'd just throw out a "gksudo echo meh" or something every minute. Should reset the timer and keep you active until you reboot.

like image 25
Bill K Avatar answered Sep 27 '22 18:09

Bill K