如果有其他用户通过ssh登录,则禁用shutdown / suspend
我记得在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"
问题仍然存在,当有多个用户登录时,是否可以禁止关机或暂停(不重写pm-suspend或halt(或其他hack))?
更新 (感谢enzotib):
我不应编辑原始答案中列出的文件,因为软件包更新可能会覆盖您的更改。
相反,应使用位于/var/lib/polkit-1/localauthority/
配置文件来配置PolicyKit,详见pklocalauthority
手册页。
原始答案:
随着HAL的弃用,现在由/usr/share/polkit-1/actions/org.freedesktop.consolekit.policy
控制
将下面显示的两个操作部分中的auth_admin_keep
设置为auth_admin_keep
(默认设置为auth_admin_keep
):
Stop the system when multiple users are logged in System policy prevents stopping the system when other users are logged in no no
…
Restart the system when multiple users are logged in System policy prevents restarting the system when other users are logged in no no