Den*_*rko 15 ssh shutdown 11.04
我记得在 9.04 左右的 ubuntu 版本中,如果有其他用户登录,可以禁用用户关闭(也可能挂起)系统。类似 policykit 或类似的东西。
可以在 11.04 做吗?
谢谢
编辑:
如果有人需要(自担风险),/usr/lib/pm-utils/bin/pm-action 中的小改动将允许用户挂起机器,如果他只是用户登录或用户将运行 sudo pm-suspend。可能不是最好的代码,但现在有效。
diff -r 805887c5c0f6 pm-action
--- a/pm-action Wed Jun 29 23:32:01 2011 +0200
+++ b/pm-action Wed Jun 29 23:37:23 2011 +0200
@@ -47,6 +47,14 @@
exit 1
fi
+if [ "$(id -u )" == 0 -o `w -h | cut -f 1 -d " " | sort | uniq | wc -l` -eq 1 ]; then
+ echo "either youre root or root isnt here and youre only user, continuing" 1>&2
+ else
+ echo "Not suspending, root is here or there is more users" 1>&2
+ exit 2
+ fi
+
+
remove_suspend_lock()
{
release_lock "${STASHNAME}.lock"
Run Code Online (Sandbox Code Playgroud)
问题仍然存在,是否可以在有多个用户登录时禁止关闭或挂起(无需重写 pm-suspend 或halt(或其他黑客))?
更新(感谢 enzotib):
不应编辑我在原始答案中列出的文件,因为包更新可能会覆盖您的更改。
PolicyKit 应使用放置在 中的配置文件进行配置/var/lib/polkit-1/localauthority/
,如手册页中详述pklocalauthority
。
原答案:
随着 HAL 的弃用,现在它被控制在/usr/share/polkit-1/actions/org.freedesktop.consolekit.policy
allow_active
在如下所示的两个操作部分中设置为(默认no
设置为):auth_admin_keep
<action id="org.freedesktop.consolekit.system.stop-multiple-users">
<description>Stop the system when multiple users are logged in</description>
<message>System policy prevents stopping the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>
</defaults>
</action>
Run Code Online (Sandbox Code Playgroud)
...
<action id="org.freedesktop.consolekit.system.restart-multiple-users">
<description>Restart the system when multiple users are logged in</description>
<message>System policy prevents restarting the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>
</defaults>
</action>
Run Code Online (Sandbox Code Playgroud)