polkit的配置

标签:
linux杂谈 |
分类: linux |
做了n多的系统版本了,可是每次配置polkit的时候几乎都会忘,今天就整理一下要点。
看看系统进程,
zhentu actions # pgrep polkit -lf
4303 /usr/lib/polkit-1/polkitd --no-debug
4585 /usr/libexec/polkit-gnome-authentication-agent-1
有两个进程,一个是agent,另一个是polkit服务。 agent包含监听接口和一个用户界面(对话窗口),允许用户输入密码。 Authentication Agent API Reference是polkit提供的agent开发接口。
http://www.freedesktop.org/software/polkit/docs/latest/polkit-architecture.png
"polkit — Authorization Manager"是其官方注解,可以翻译为“授权管理”。包含开发接口,有时间需要研究一下thunar/udisk、nm-applet的实现逻辑。
常用的是polkit的配置修改:
1,AUTHORIZATION RULES,利用javascript脚本实现,
看看系统进程,
zhentu actions # pgrep polkit -lf
4303 /usr/lib/polkit-1/polkitd --no-debug
4585 /usr/libexec/polkit-gnome-authentication-agent-1
有两个进程,一个是agent,另一个是polkit服务。 agent包含监听接口和一个用户界面(对话窗口),允许用户输入密码。 Authentication Agent API Reference是polkit提供的agent开发接口。
http://www.freedesktop.org/software/polkit/docs/latest/polkit-architecture.png
"polkit — Authorization Manager"是其官方注解,可以翻译为“授权管理”。包含开发接口,有时间需要研究一下thunar/udisk、nm-applet的实现逻辑。
常用的是polkit的配置修改:
1,AUTHORIZATION RULES,利用javascript脚本实现,
/usr/share/polkit-1/rules.d
用于让应用程序添加授权规则,比如下面的network
manager的:
// Let users in plugdev group modify NetworkManager
polkit.addRule(function(action, subject) {
if
(action.id ==
"org.freedesktop.NetworkManager.settings.modify.system"
&&
subject.isInGroup("plugdev") &&
subject.active) {
return "yes";
}
});
//把用户加入plugdev组就不用输入密码了
和程序开发的关系较大,系统使用者不要修改,可以参考。
2,ACTIONS
和用户关系很大,/usr/share/polkit-1/actions/*.policy
org.freedesktop.consolekit.policy
——关机
org.freedesktop.NetworkManager.policy ——网络配置
org.freedesktop.policykit.policy
—— run a program as another user,决定pkexec的密码需求
org.freedesktop.udisks2.policy
—— 磁盘挂载
org.freedesktop.upower.policy
—— Hibernate and suspend
org.freedesktop.upower.qos.policy —— latency
org.gnome.gconf.defaults.policy —— gnome
gconf
文件中对每个action都详细的注解,一看便知。可能需要修改的地方是这些:
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_self</allow_active>
设置取值有:
|
Not authorized. |
|
Authorized. |
|
Authentication by the owner of the session that the client originates from is required. |
|
Authentication by an administrative user is required. |
|
Like |
|
Like |
典型的场景是把
allow_active的设置从
auth_admin(root密码)改成
auth_self(当前用户密码)或者yes(不要密码)。
前一篇:哪些人不宜提前还房贷