0

作为 nagios 用户,我无法执行 systemctl。追踪到pkexec,我得到:

-sh-4.2$ pkexec systemctl reload nagios
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/systemctl' as the super user

但是,我有一个非常非常宽松的 polkit 规则(它不是生产系统)

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units") {
        var verb = action.lookup("verb");
        if (verb == "start" || verb == "stop" || verb == "restart" || verb == "reload") {
            return polkit.Result.YES;
        }
    }
});

我在重新启动 polkit.service 时仔细检查它是否编译有什么问题?

OS : RHEL7
Sytemd version 219
PolKit version : 0.112

谢谢,

泽维尔

4

2 回答 2

0

似乎组合 Sytemd 219 + PolKit 0.112 不支持“动词”语句。在规则中添加了一些日志记录向我展示了这一点:

/etc/polkit-1/rules.d/01-nagios.rules:7: verb=undefined

看起来像 Polkit 0.112 中的一个错误。

泽维尔

于 2021-07-06T12:19:11.947 回答
0

这不是 Polkit 中的错误;而是这个版本的 Systemd 中的错误(或至少是一个限制)。原因是“动作”是由使用 Polkit 的机制提供的,在这种情况下是由 SystemD 提供的。

您可以在 polkit(8) 中进行交叉检查

请参阅 systemd 发行说明 ( https://github.com/systemd/systemd/blob/main/NEWS )

与 226 的变化:

    * When systemd requests a polkit decision when managing units it
      will now add additional fields to the request, including unit
      name and desired operation. This enables more powerful polkit
      policies, that make decisions depending on these parameters.

所以对于 RHEL7 之类的东西,我想这意味着使用 sudo 来解决这个问题,而这在 RHEL8 中确实可以很好地工作。

惭愧,我期待着使用它。

于 2022-02-28T07:34:50.493 回答