Answers:
如另一个问题所述,您可以通过PolicyKit的本地权限系统控制这些操作。
如果您创建的文件/etc/polkit-1/50-local.d/restrict-shutdown.pkla
内容如下:
[Disable shutdown/etc for group restricted]
Identity=unix-group:restricted
Action=org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.restart;org.freedesktop.upower.suspend;org.freedesktop.upower.hibernate
ResultAny=no
ResultInactive=no
ResultActive=no
这将阻止组中的任何成员restricted
执行匹配的操作。或者,如果要限制单个用户,请替换unix-group:restricted
为unix-user:user1;unix-user:user2;...
。与该策略不匹配的任何用户都应具有默认行为。
以根用户身份创建和编辑此文件:
/etc/polkit-1/localauthority/50-local.d/power-management.pkla
复制并粘贴以下内容:
[Disable shutdown/restart for users jim jane]
Identity=unix-user:jim;unix-user:jane
Action=org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions;org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions
ResultAny=no
ResultInactive=no
ResultActive=no
[Disable suspend/hibernate for users jim jane]
Identity=unix-user:a;unix-user:vvpinker
Action=org.freedesktop.login1.suspend;org.freedesktop.login1.suspend-multiple-sessions;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=no
ResultInactive=no
ResultActive=no