Prevent user from shutting down?

Asked by tdn

I have a cron-job that is run daily on each laptop in the household. The cron job can sometimes take a while to complete (30 mins or so). The cron job is run as root.

How do I prevent users from shutting down the system, while the cron job is running? Actually I would like to prevent them from:
 * Logging out
 * Shut down
 * Reboot

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu cron Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :
#1
Revision history for this message
tdn (spam-thomasdamgaard) said :
#2

mycae: Thanks, but that does not solve my problem.
It seems that pessulus only removes some GUI elements from GNOME, is that correct?

Pessulus is a GUI tool. That does not help me much, since I must be able enable and disable logout/reboot from the cron-job.
I am imagining something like the following pseudo code for a crontab:
0 0 * * * root disable-logout && run-heavy-task && enable-logout

So, "disable-logout" changes the state of the system so that logout, reboot, shutdown, hibernate is disabled.
"run-heavy-task" is my script that takes a while to complete.
"enable-logout" reverts the changes that "disable-logout" made, thus enabling logout, reboot, shutdown and hibernate again.

Revision history for this message
mycae (mycae) said :
#3

>It seems that pessulus only removes some GUI elements from GNOME, is that correct?
Sounds about right, but I think you will find it is a fancy frontend to gconf2-tool. You can use this to do the same functionality as pessulus, by modifying the keys in gconf's database (/desktop/gnome/interface). THis can be done from the commandlines

But yes, it is just a hint -- a determined user can still log out. AFAIK, logging out is a user-level - you would need to prevent users from being allowed to terminate their processes, which is a bit weird.

Shutting down is of course a root level action, and could be more easily bulletproofed.

Can you help with this problem?

Provide an answer of your own, or ask tdn for more information if necessary.

To post a message you must log in.