Allow power control from GNOME lock screen
I'm trying to find a way to allow rebooting a workstation from the screensaver for GNOME3 on CentOS 7. We have a computer lab that dual boots Windows and Linux and students need to be able to reboot computers into Windows when a class starts.
I've managed to allow rebooting from GDM and active sessions by implementing this polkit rule:
[root@C7-STUDENT ~]# cat /etc/polkit-1/rules.d/50-allow-user-shutdown.rules
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.power-off-multiple-sessions")
{
return polkit.Result.YES;
}
});
This allows rebooting from GDM and active sessions, but not from the screensaver or lock screen. Here's a picture of what I'm seeing:
I do appreciate that for most situations being able to reboot a workstation while someone is logged in is not desirable but in this case it's absolutely required. I would have assumed that the polkit "reboot-multiple-sessions" permission would allow this but that doesn't seem to be the case
The lock screen also appears if GDM times out which is not intuitive for users. If they click the power menu after waking the screen, they have no power-off options. If they hit Enter and then click the power menu, they can reboot the machine.