I'm trying to configure Polkit rules on Ubuntu MATE 24.04 to require admin authentication for shutdown/reboot actions in the graphical interface. My current rules:
polkit.addAdminRule(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 ["unix-user:root"];
}
});
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.power-off-multiple-sessions"
) {
if (subject.user == "root") {
return polkit.Result.YES;
}
return polkit.Result.AUTH_ADMIN_KEEP;
}
});
Observed Behavior:
GUI shutdown button skips authentication and logs out immediately.
CLI commands like pkexec shutdown or pkexec poweroff correctly prompt for authentication.
Questions:
Is there a MATE-specific policy or action ID I might be missing?
Why does the GUI bypass authentication while CLI respects the rules?
I want the GUI shutdown/reboot button in MATE to require secondary authentication (e.g., password prompt) for non-admin users.
Thank you for any insights!
For clarity, here are the details of my environment:
Ubuntu Version:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
MATE Desktop Packages:
mate-desktop-common/noble,now 1.26.2-1.1build3 all
mate-desktop-environment-core/noble,now 1.26.0+1ubuntu6 all
mate-desktop/noble,now 1.26.2-1.1build3 amd64
mate-polkit-common/noble,now 1.26.1-4build3 all
mate-polkit/noble,now 1.26.1-4build3 amd64
mate-power-manager-common/noble,now 1.26.1-1build4 all
mate-power-manager/noble,now 1.26.1-1build4 amd64
mate-session-manager/noble,now 1.26.1-2build2 amd64
polkitd/noble-updates,now 124-2ubuntu1.24.04.2 amd64
ubuntu-mate-desktop/noble,now 1.296 amd64
systemd Version:
systemd 255 (255.4-1ubuntu8.5)