You are not logged in.
Hi,
Options for forbidding poweroffs and reboots when another user is logged-in highly appreciated. Say, when each user is working on his own tty locally (probably not simultaneously) or over ssh, remote-desktop, etc.
Thanks!
Last edited by vordoo (2020-12-14 12:00:08)
Offline
poweroff [OPTIONS...]
Power off the system.
Options:
--help Show this help
--halt Halt the machine
-p --poweroff Switch off the machine
--reboot Reboot the machine
-f --force Force immediate halt/power-off/reboot
-w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
-d --no-wtmp Don't write wtmp record
--no-wall Don't send wall message before halt/power-off/reboot
See the halt(8) man page for details.
it seems no option by poweroff command.
I think you can write your own script to achieve it.
Offline
... forbidding poweroffs and reboots
Forbidding and preventing are two very different things. You can use regular sudo/polkit configuration to *forbid* regular users from powering off and rebooting the machine.
However, if you want users to remain to be able to poweroff, then you need a warning system to *prevent* shutting down the machine when others are logged in. For example, you can wrap poweroff in a script that first checks for existing sessions and bails if it finds any.
If you want, you can combine both and use sudo/polkit to only grant access to the wrapper script for less privileged users.
Offline
However, if you want users to remain to be able to poweroff, then you need a warning system to *prevent* shutting down the machine when others are logged in. For example, you can wrap poweroff in a script that first checks for existing sessions and bails if it finds any.
Looking for an elegant-way/options of doing what you said, but not necessarily with a user warning: *Forbidding* (make impossible à la Webster Dictionary) poweroffs and reboots when another user is logged-in ;-)
With the wrapping option you must make sure all options are wraped: shutdown, poweroff, restart, reboot, whatever... Looking for a more generic option, if any.
Thanks!
Offline
https://bbs.archlinux.org/viewtopic.php?id=198904 (but only add the org.freedesktop.login1.power-off-multiple-sessions & org.freedesktop.login1.reboot-multiple-sessions action IDs.)
Para todos todo, para nosotros nada
Offline
https://bbs.archlinux.org/viewtopic.php?id=198904 (but only add the org.freedesktop.login1.power-off-multiple-sessions & org.freedesktop.login1.reboot-multiple-sessions action IDs.)
Thanks, you nailed it. For prosperity I'll add this link too (prevent non-root users from issuing shutdowns or reboots):
https://superuser.com/questions/354678/ … ns-or-rebo.
Last edited by vordoo (2020-12-14 11:57:55)
Offline