wq242424

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

2018-08-09 12:04  丨o聽乄雨o丨  阅读(302)  评论(0编辑  收藏  举报
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

不用重启,命令就会运行

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2021-11-29
  • 2022-01-02
  • 2021-12-20
  • 2021-12-05
  • 2021-11-08
  • 2021-12-22
  • 2021-09-27
猜你喜欢
  • 2021-10-06
  • 2021-11-17
  • 2021-12-23
  • 2021-11-23
  • 2021-11-29
  • 2021-11-30
  • 2021-10-12
相关资源
相似解决方案