Step 1: Wait several months until Debian Stretch is released – you need at least systemd v227, with commits 2ac3930f (polkit checking for /sbin/halt
) and 88ced61b (extended polkit data for systemctl halt
etc.)
Step 2: Create a polkit rule in… Actually, no, that won't be enough because even Stretch still has polkit v0.105, which did not support the JS-based rules yet; only the considerably more limited .pkla
format. That said, v0.113 is finally in "experimental".
But if you happen to upgrade to systemd ≥v227 and polkit ≥v0.113, a rule such as this should work:
/* copy to /etc/polkit-1/rules.d/systemd-allow-halt.rules */ polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.systemd1.manage-units" && action.lookup("unit") == "halt.service") { return polkit.Result.YES; } });
So, teach yourself to type systemctl poweroff
instead. "Halt" isn't the normal shutdown command; it's the command to literally halt the machine – without powering it off. It's not very useful.
If you do find it useful, use sudo instead:
# /etc/sudoers ALL ALL=(root) NOPASSWD: /usr/bin/systemctl halt, /sbin/halt