簡體   English   中英

盡管有足夠的規則,Policy Kit 不允許重新啟動服務

[英]Policy Kit does not allow to restart a service, despite an adequate rule

作為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

謝謝,

澤維爾

似乎組合 Sytemd 219 + PolKit 0.112 不支持“動詞”語句。 向規則添加了一些日志記錄向我展示了這一點:

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

看起來像是 Polkit 0.112 中的一個錯誤。

澤維爾

這不是 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 中工作得很好。

遺憾的是,我很期待使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM