Centos7/Redhat7 禁止普通用户关机/重启
# vim /etc/polkit-1/rules.d/55-inhibit-shutdown.rulespolkit.addRule(function(action, subject) {
if (action.id.indexOf("org.freedesktop.login1.power-off") == 0 ||action.id.indexOf("org.freedesktop.login1.reboot") == 0) {
try {
// user-may-reboot exits with success (exit code 0)// only if the passed username is authorizedpolkit.spawn(["/usr/local/bin/user-may-reboot",subject.user]);return polkit.Result.YES;} catch (error) {
// Nope, but do allow admin authenticationreturn polkit.Result.AUTH_ADMIN;}}
});