polkit, formerly PolicyKit, is an authorization framework for Linux that decides whether an unprivileged process may ask a privileged system service to perform a specific action, such as mounting a disk, changing the network configuration or rebooting the machine. In the domain of Linux permissions it complements file permissions and sudo by controlling access to services rather than to files or whole commands.
Instead of running an entire program as root, polkit lets a small privileged service perform one well-defined operation on behalf of the user, after checking a policy that may allow it, deny it or require the user or an administrator to authenticate first.
How polkit authorizes an action
polkit works through a three-party model: a subject that wants something done, a mechanism that can do it with privileges, and the polkitd authority daemon that decides. Communication between the parties usually runs over the D-Bus system bus.
A typical sequence looks like this. A desktop application asks a mechanism such as systemd-logind or NetworkManager to perform an action. The mechanism asks polkitd whether the calling process is authorized for that action identifier. If authentication is required, polkitd contacts the session’s authentication agent, which shows a password dialog, and only then returns its answer.
The roles in this exchange are summarized below.
| Component | Role | Example |
|---|---|---|
| Subject | Unprivileged process requesting an action | A file manager or a CLI tool |
| Mechanism | Privileged service that performs the action | udisksd, systemd-logind, NetworkManager |
| polkitd | Authority that evaluates policy | Runs as a dedicated system user |
| Authentication agent | Asks the user for credentials | Desktop dialog or pkttyagent in a terminal |
| Action | Named operation with default rules | org.freedesktop.login1.reboot |
Actions, implicit authorizations and rules
Every privileged operation is declared as an action in an XML policy file under /usr/share/polkit-1/actions/. Each action carries implicit authorizations that apply by default, specified separately for three kinds of subjects: any client, inactive local sessions and active local sessions.
| Value | Meaning | Typical use |
|---|---|---|
| yes | Allowed without authentication | Suspend for the active local user |
| no | Always denied | Remote sessions for sensitive actions |
| auth_self | User must enter own password | Mounting an internal disk |
| auth_admin | An administrator must authenticate | Changing system time or users |
| auth_self_keep | Own password, cached briefly | Repeated package operations |
| auth_admin_keep | Administrator password, cached briefly | Several firewall changes in a row |
Administrators override these defaults with JavaScript rules files in /etc/polkit-1/rules.d/. Rules are evaluated in lexical order of file names, across both /etc and /usr/share, and the first rule returning a result wins. The older .pkla INI-style files of the local authority backend were used by polkit versions before 0.106 and still appear on some long-term-support distributions.
A rule usually tests the action identifier and a property of the subject, most often group membership. For example, a rule can return polkit.Result.YES when the action ID starts with org.freedesktop.udisks2. and the subject is in the storage group, which grants passwordless disk mounting to that group only.
polkit compared with sudo and file permissions
polkit, sudo and traditional file permissions all control what a user may do, but they operate at different levels of granularity. Confusing them leads to configurations that are either too permissive or puzzling to debug.
| Mechanism | What it controls | Granularity | Configuration |
|---|---|---|---|
| polkit | Requests to privileged services | Per action identifier | Rules in rules.d |
| sudo | Running commands as another user | Per command and arguments | sudoers via visudo |
| File permissions | Read, write and execute on files | Per file, owner and group | chmod, chown, Linux ACL |
| setuid | Program always runs as its owner | Whole executable | File mode bit |
The key difference is least privilege. With sudo, the command runs as root in full; with polkit, only the service code for one operation holds privileges, and the requesting program stays unprivileged. The pkexec utility offers a sudo-like way to run a whole program as another user through polkit, but it is a setuid binary and carries comparable risks.
Inspecting and configuring polkit
Administrators use a small set of command-line tools to see which actions exist, test decisions and supply authentication outside a graphical session.
- pkaction lists registered actions; with
--verboseit shows the implicit authorizations of each. - pkcheck asks polkitd whether a given process is authorized for an action, which is useful in scripts and debugging.
- pkttyagent provides a text-mode authentication agent for SSH sessions and servers without a desktop.
- journalctl -u polkit shows the daemon log, including errors in JavaScript rules files.
On headless servers, administrators often see an authentication failure without any prompt, because no agent is registered for the session. Running the command through sudo, starting pkttyagent or writing a targeted rule for an administrative group such as wheel or sudo resolves the problem.
Security considerations and common mistakes
Because polkit grants access to root-level operations, errors in rules or in polkit itself have high impact. The most widely known example is CVE-2021-4034, called PwnKit, a memory corruption flaw in pkexec that allowed any local user to gain root on most distributions until it was patched in January 2022.
| Mistake | Consequence | Fix |
|---|---|---|
| Broad rule matching all actions | Group gets near-root power | Match specific action IDs |
| Editing files in /usr/share | Changes lost on package update | Place rules in /etc/polkit-1/rules.d |
| Syntax error in a rules file | Rule silently ignored | Check the polkit journal after edits |
| Unpatched pkexec | Local privilege escalation | Update polkit or remove the setuid bit |
| Assuming sudoers controls GUI actions | Unexpected prompts or access | Review polkit rules separately |
A sound policy grants the narrowest action set to the smallest group, keeps auth_admin for system-wide changes and is reviewed whenever new services are installed, because each package can add its own actions.
The simple explanation
polkit is like a receptionist at a secure office. Regular programs cannot walk into the back rooms where important system work is done. Instead, they ask a trusted staff member, such as the service that manages disks, to do one specific task for them.
Before the staff member acts, the receptionist checks a rulebook. Some requests are fine right away, some need you to show your ID by typing a password, and some are refused. The benefit is that programs get exactly the help they need and nothing more.
How it is used in practice
A university computer lab runs 40 Linux workstations shared by students. The lab administrator wants students to mount USB drives and shut down machines at the end of a session, but not to change network settings, install packages or manage other users.
The administrator places one rules file in /etc/polkit-1/rules.d/ that returns YES for the udisks2 mount actions and for login1 power-off when the subject is in a students group and in an active local session. Every other action keeps its auth_admin default, so attempts to alter network or package settings trigger an administrator password prompt that students cannot satisfy.
No student receives sudo rights, and the outcome is a lab where routine tasks work without passwords while system configuration stays protected. When a polkit security update is released, the administrator patches all workstations centrally on the same day.