![允许用户重新启动 systemd 服务的 Polkit 规则](https://linux22.com/image/200757/%E5%85%81%E8%AE%B8%E7%94%A8%E6%88%B7%E9%87%8D%E6%96%B0%E5%90%AF%E5%8A%A8%20systemd%20%E6%9C%8D%E5%8A%A1%E7%9A%84%20Polkit%20%E8%A7%84%E5%88%99.png)
我/etc/polkit-1/rules.d/00-manage-docker-daemon.rules
使用以下规则创建了文件,以允许“agroup”的成员管理(停止/启动/重新启动)docker.service(Centos 7):
// Allow agroup members to manage docker.service;
// fall back to implicit authorization otherwise.
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "docker.service") &&
subject.isInGroup("agroup"))
{
return polkit.Result.YES;
}
});
我已经重新启动了“polkit”systemd 服务(我不确定是否需要),不幸的是,“agroup”的用户成员无法运行命令 - 系统会提示他们输入 root 密码:
$ id
uid=17870(user) gid=17870(user) groups=17870(user),17897(agroup) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ systemctl restart docker.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
如何让这些东西发挥作用?我的配置中是否缺少任何内容?