Polkit (formerly PolicyKit)

From Kicksecure
Jump to navigation Jump to search

Polkit (formerly PolicyKit) provides a centralized way to define and manage policy rules for privileged operations performed by users on Linux systems. This documentation explains its role, potential issues when disabled, and methods for managing it.

Introduction[edit]

Documentation for this is incomplete. Contributions are happily considered! See this for potential alternatives.

Issues when disabling Polkit[edit]

  • Reboot and poweroff from the GUI are no longer possible. [1]
  • Removable media can no longer be mounted, as udisksd treats removable media mounting as a privileged operation.
  • Graphical user creation tools (e.g. users-admin from gnome-system-tools) no longer function properly. [2]
  • Flatpaks can no longer be installed user-locally. (flatpak --user install) [3]
  • Network configuration via nmtui or similar tools (likely including the network widget in the panel) will probably no longer be configurable, as NetworkManager treats network reconfiguration as a privileged operation.
  • System usually takes longer to boot, likely due to processes repeatedly failing to start polkit.

Disabling Polkit[edit]

Disabling Polkit can be useful for security hardening inside browser-only VMs or other scenarios where a user is not expected to perform any privileged operations via polkit.

How to disable polkit as an opt-in hardening option? Undocumented.

Development[edit]

Polkit could be disabled using a systemd drop-in configuration snippet, modifying polkit.service by adding ConditionKernelCommandLine or a similar parameter to prevent polkit from starting in user sessions (outside of the sysmaint session).

Untested.

Open file /usr/lib/systemd/system/polkit.service.d/99_sysmaint.conf in an editor with root rights.

Select your platform.

Kicksecure

See Open File with Root Rights for detailed instructions on why to use sudoedit for better security and how to use it.

Note: Mousepad (or the chosen text editor) must be closed before running the sudoedit command.

sudoedit /usr/lib/systemd/system/polkit.service.d/99_sysmaint.conf

Kicksecure for Qubes

NOTES:

sudoedit /usr/lib/systemd/system/polkit.service.d/99_sysmaint.conf

  • After applying this change, shutdown the Template.
  • All App Qubes based on the Template need to be restarted if they were already running.
  • This is a general procedure required for Qubes and unspecific to Kicksecure for Qubes.

Others and Alternatives

  • This is just an example. Other tools could achieve the same goal.
  • If this example does not work for you or if you are not using Kicksecure, please refer to this link.

sudoedit /usr/lib/systemd/system/polkit.service.d/99_sysmaint.conf

Paste.

ConditionKernelCommandLine=boot-role=sysmaint

Save.

Reboot.

Done.

polkit.service should now only be running in sysmaint session.

Forum Discussion[edit]

Footnotes[edit]

  1. This is because systemd treats rebooting as a privileged operation.
  2. Probably because accountsservice treats user creation as a privileged operation.
  3. Flatpak installation errors out:
    Warning: Failed to get revokefs-fuse socket from system-helper: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to get revokefs-fuse socket from system-helper: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to get revokefs-fuse socket from system-helper: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    Warning: Failed to get revokefs-fuse socket from system-helper: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    error: Failed to install org.gnome.Platform: Failed to activate service 'org.freedesktop.Flatpak.SystemHelper': timed out (service_start_timeout=25000ms)
    
Notification image

We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 13 year success story and maybe DONATE!