关闭图形界面下普通用户关机重启命令- 7.x - CentOS

vim /etc/polkit-1/rules.d/55-inhibit-shutdown.rules
polkit.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 authorized
            polkit.spawn(["/usr/local/bin/user-may-reboot",
                          subject.user]);
            return polkit.Result.YES;
        } catch (error) {
            // Nope, but do allow admin authentication
            return polkit.Result.AUTH_ADMIN;
        }
    }
});
chmod 755 55-inhibit-shutdown.rules

不用重启,命令就会运行

猜你喜欢

转载自www.cnblogs.com/wq242424/p/9448120.html
今日推荐