我想阻止用户在其他用户登录时开始关机或重启.用户可以是TTY用户(Ctrl Alt F3)或来自客户端主机的ssh用户.
在OpenBSD中,我将polkit org.xfce.session.policy与规则文件一起使用以防止此类操作.
我需要在Debian Testing(又名Buster)中找到如何做到这一点.
我找到了带有操作的org.freedesktop.login1.policy
> org.freedesktop.login1.power-off
> org.freedesktop.login1.power-off-multiple-sessions.
并为这些操作制作了规则文件,但它不会阻止关闭或重新启动.
在我看来,polkit对这些行为不负责任.
我不知道在哪里寻找这个;也许是systemd或PAM?
编辑
在OpenBSD和NetBSD上,默认情况下,不允许任何人从GUI关闭或重新启动.
您必须在/usr/local/share/polkit-1/rules.d/中创建一个规则文件,如下所示:
polkit.addRule (function (action, subject) {
if (action.id == "org.xfce.session.xfsm-shutdown-helper")
{
return polkit.Result.YES;
}
});
在Debian上,默认情况下,所有用户都可以从GUI关闭或重新启动.
org.xfce.session.xfsm-shutdown-helper或org.freedesktop.login1.power-off没有规则文件.
我尝试使用return polkit.Result.NO添加我的规则文件;无济于事
在debian上,我使用lightdm和BSD,我使用xdm.