Skip to content

Make tmpfiles respect configured group name and document security implications#555

Merged
jrybar-rh merged 2 commits intopolkit-org:mainfrom
jtojnar:tmpfiles-fixes
Mar 6, 2025
Merged

Make tmpfiles respect configured group name and document security implications#555
jrybar-rh merged 2 commits intopolkit-org:mainfrom
jtojnar:tmpfiles-fixes

Conversation

@jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Mar 2, 2025

Summary

Follow up to #442 (comment).

  • Make tmpfiles respect configured polkit group name
  • Document the security implications for tmpfiles.d entry

Detailed description and/or reproducer

Make tmpfiles respect configured polkit group name

We allow changing the polkit daemon user through the -Dpolkitd_user Meson option.
When this is used, the tmpfiles.d config will refer to a non-existent group.
For example, NixOS builds polkit with -Dpolkitd_user=polkituser.

Let’s substitute the polkitd_user value into the config.

We do not have a separate option for the group name since, by convention,
the group name matches the user name. This is also enforced by our sysusers.d config:
https://www.freedesktop.org/software/systemd/man/latest/sysusers.d.html#u

Document the security implications for tmpfiles.d entry

Quoting from https://www.github.com/polkit-org/polkit/pull/442#issuecomment-2692718825:

The tmpfiles.d is used to create polkit subdirectory in /etc, because the directory needs specific ownership mode, it needs to be owned by root and only readable by root and polkitd group. This is for security reasons, so that polkit daemon cannot change .rules files in case of getting hijacked. It should have as minimal privileges as possible. The subdirectory is pre-created so no administrator omits to set the appropriate mode and ownership.

jtojnar added 2 commits March 2, 2025 16:13
We allow changing the polkit daemon user through the `-Dpolkitd_user` Meson option.
When this is used, the tmpfiles.d config will refer to a non-existent group.
For example, NixOS builds polkit with `-Dpolkitd_user=polkituser`.

Let’s substitute the `polkitd_user` value into the config.

We do not have a separate option for the group name since, by convention,
the group name matches the user name. This is also enforced by our `sysusers.d` config:
https://www.freedesktop.org/software/systemd/man/latest/sysusers.d.html#u
Quoting from <https://www.github.com/polkit-org/polkit/pull/442#issuecomment-2692718825>:

> The tmpfiles.d is used to create polkit subdirectory in /etc, because the directory needs specific ownership mode, it needs to be owned by root and only readable by root and polkitd group. This is for security reasons, so that polkit daemon cannot change .rules files in case of getting hijacked. It should have as minimal privileges as possible. The subdirectory is pre-created so no administrator omits to set the appropriate mode and ownership.
@jrybar-rh jrybar-rh merged commit c33c3b2 into polkit-org:main Mar 6, 2025
40 checks passed
@jtojnar jtojnar deleted the tmpfiles-fixes branch March 10, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants