LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   how do i prevent regular user from shutting down the system (http://www.linuxquestions.org/questions/linux-desktop-74/how-do-i-prevent-regular-user-from-shutting-down-the-system-4175443638/)

baronobeefdip 12-31-2012 07:38 PM

how do i prevent regular user from shutting down the system
 
I have a debian box running as my DNS and Web server and I also have my brother use it for his purposes but every time he leaves the computer he shuts it down, He uses the computer like 5 to 7 times a day and shuts it down between uses, (is this safe for the power supply). I want to know how to prevent him from turning the system off as a regular user.

kbp 12-31-2012 09:19 PM

The simplest way is user education ... have you tried asking him to log off instead of shutdown? If you're running Gnome 3 he won't even see the shutdown option unless he enables the alternate status menu.

baronobeefdip 12-31-2012 11:35 PM

He won't do it, he claims that it uses a lot of power but now I want to know if turning it on and off in the way that he does will ruin the power supply. User education in this situation doesn't seem very effective given that I am reasoning with a 13 year old

Timothy Miller 12-31-2012 11:50 PM

I would think that if you were to chmod o-x /sbin/shutdown (maybe go-x depending on how your distro set up rights to it), depending on how it's being shutdown (not all DE's use this command directly) that should suffice.

dinkus223 01-01-2013 01:02 AM

First
Code:

sudo visudo
Then add alias for shutdown commands in a convenient place for you. I did mine under the supplied commented commands.
Code:

Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, /sbin/poweroff, /sbin/reboot, /sbin/init
Then add the username and permissions you want to grant/allow.
So he can't run the shutdown commands defined, even with sudo use:
Code:

username    localhost=!SHUTDOWN
You might want to add pm-hibernate, pm-powersave, pm-suspend and pm-suspend-hybrid if you have them just in case. I am not that familiar with Debian, they are provided by the pm-utils-1.4.1-8.fc15.i686.rpm in Fedora 15.

Learn about the /etc/sudoers file to control what he can run or not.
The /etc/pam.d/su file has permissions to control who can switch to root. It might be helpful if he is knowledgeable on his commands.

If he complain, remind him of his refusal to comply with your request to not shutdown the computer. Be respectful and give him an out so he won't feel some type of way about what you had to do. After all you got business going on.

baronobeefdip 01-01-2013 02:19 PM

Quote:

Originally Posted by dinkus223 (Post 4860470)
First
Code:

sudo visudo
Then add alias for shutdown commands in a convenient place for you. I did mine under the supplied commented commands.
Code:

Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, /sbin/poweroff, /sbin/reboot, /sbin/init
Then add the username and permissions you want to grant/allow.
So he can't run the shutdown commands defined, even with sudo use:
Code:

username    localhost=!SHUTDOWN
You might want to add pm-hibernate, pm-powersave, pm-suspend and pm-suspend-hybrid if you have them just in case. I am not that familiar with Debian, they are provided by the pm-utils-1.4.1-8.fc15.i686.rpm in Fedora 15.

Learn about the /etc/sudoers file to control what he can run or not.
The /etc/pam.d/su file has permissions to control who can switch to root. It might be helpful if he is knowledgeable on his commands.

If he complain, remind him of his refusal to comply with your request to not shutdown the computer. Be respectful and give him an out so he won't feel some type of way about what you had to do. After all you got business going on.

Will this also prevent him from sing the menu at the top in the gnome desktop environment to shut it down (or at least be prompted for the password). At this point the only thing he can do is hard shut it down with the button in the front but you can always remove the pin inside of the case :D

dinkus223 01-02-2013 02:24 AM

Works on command line, not in Gnome2.32.0 or Xfce4 GUI on Fedora 15 machine. I don't have KDE installed. Will try to find a solution, might need it in the future.

jefro 01-02-2013 09:35 AM

There is nothing wrong with shutting down a computer. You don't leave your car, tv, or nuclear submarine running all day do you? Well, maybe the nuke sub.

Shut it down when not in use and save some energy.

Lennie 01-02-2013 10:08 AM

Some distros use consolekit to shutdown. You can add a rule about it by creating the file /etc/polkit-1/50-local.d/disable-shutdown.pkla:

Code:

[Disable shutdown]
Identity=unix-user:username
Action=org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.restart
ResultAny=no
ResultInactive=no
ResultActive=no

'man pklocalauthority' will tell you more about it.

Valosar 01-02-2013 01:21 PM

Jefro I think the point is he doesn't want it shutdown because it is his webserver/dns which is only useful when it is on ;) I find this interesting as I've got two small children 4/5 who use my computer for playing educational games. I've given them easy to remember passwords and user names so they can get practice in at a young age with this sort of thing. They like to shut the computer off when they're done as well, I'm also running on a Debian based distro (mint 14 in this case) Let us know what solution you end up using and how effective it is. If he is really stuborn he can just turn off the power supply or the power source (unplug it for example) My children figured that out recently and enjoy the clicky sound it makes when you turn off the power supply directly <sigh>

dinkus223 01-03-2013 02:51 AM

Thanks Lennie, that' where I was headed. Glad to know I was on the right track with my research. ConsoleKit is something I never used until learning that the shutdown button is routed through dbus.


All times are GMT -5. The time now is 03:29 AM.