默认情况下,谁可以使用 pkexec 获得 root 权限?

Nat*_*dge 6 root policykit

我今天了解到,可以pkexec从命令行以类似于 的方式sudo使用 root 权限执行程序。我很好奇如何pkexec决定允许谁这样做。

手册页pkexec(1)

默认情况下,除非存在相关程序的操作定义文件,否则需要 org.freedesktop.policykit.exec 授权。

对于不熟悉 policykit 的人来说,解析这有点困难。但是稍微猜测一下,让我们来看看/usr/share/polkit-1/actions/org.freedesktop.policykit.policy. 在该org.freedesktop.policykit.exec部分中,我们看到了字符串auth_admin

参考polkit(8),我们看到:

auth_admin

需要管理用户的身份验证。

在这个意义上,谁才是“管理用户”?进行哪些测试来确定用户是否是“管理员”?配置文件越来越难以找到和理解。

我知道这是可配置的。我想知道 Ubuntu 15.04 的默认设置。

mur*_*uru 6

默认情况下,它是sudo组的成员和 root 用户,凭借以下文件/etc/polkit/localauthority.conf.d/

$ tail /etc/polkit-1/localauthority.conf.d/*
==> /etc/polkit-1/localauthority.conf.d/50-localauthority.conf <==
# Configuration file for the PolicyKit Local Authority.
#
# DO NOT EDIT THIS FILE, it will be overwritten on update.
#
# See the pklocalauthority(8) man page for more information
# about configuring the Local Authority.
#

[Configuration]
AdminIdentities=unix-user:0

==> /etc/polkit-1/localauthority.conf.d/51-ubuntu-admin.conf <==
[Configuration]
AdminIdentities=unix-group:sudo;unix-group:admin
Run Code Online (Sandbox Code Playgroud)

第一个文件授予对 UID 0 ( root) 的访问权限,第二个文件授予组sudoadmin. admin并没有真正用于 Ubuntu,而是sudo用于授予访问权限的组sudo