Polkit: Difference between revisions

imported>Aaron C Hall
Inverse is true, see https://search.nixos.org/options?channel=22.05&show=security.polkit.enable&from=0&size=50&sort=relevance&type=packages&query=Polkit
imported>Chewie
Mention use of systemd user service to launch a polkit authentication agent
Line 12: Line 12:


For example, <code>polkit_gnome</code> is a GNOME-based authentication agent, but it will usually only autostart when used with GNOME, KDE, or Unity (examine its autostart file in <code>etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop</code> for details); otherwise you will need to start it yourself, e.g. by copying that autostart file to <code>~/.config/autostart/</code> and removing the parts that restrict it to GNOME/KDE/Unity.
For example, <code>polkit_gnome</code> is a GNOME-based authentication agent, but it will usually only autostart when used with GNOME, KDE, or Unity (examine its autostart file in <code>etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop</code> for details); otherwise you will need to start it yourself, e.g. by copying that autostart file to <code>~/.config/autostart/</code> and removing the parts that restrict it to GNOME/KDE/Unity.
Alternatively, you can start it on login by creating a systemd user service:
<syntaxhighlight lang="nix">
systemd = {
    user.services.polkit-gnome-authentication-agent-1 = {
    description = "polkit-gnome-authentication-agent-1";
    wants = [ "graphical-session.target" ];
    wantedBy = [ "graphical-session.target" ];
    after = [ "graphical-session.target" ];
    serviceConfig = {
      Type = "simple";
      ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
      Restart = "on-failure";
      RestartSec = 1;
      TimeoutStopSec = 10;
    };
  };
};
</syntaxhighlight>