Polkit: Difference between revisions

imported>Tkuwill
m I wrote the code by myself. Reference: sed manual.
imported>Mweinelt
reboot/poweroff for unprivileged users
Line 6: Line 6:


Polkit is disabled by default. If you wish to enable it, you can set <code>security.polkit.enable</code> to true.
Polkit is disabled by default. If you wish to enable it, you can set <code>security.polkit.enable</code> to true.
== Reboot/poweroff for unprivileged users ==
With the following rule, we can grant the permissions `reboot` and `poweroff` a machine to users in the <code>
users</code> group.
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
  security.polkit.extraConfig = ''
    polkit.addRule(function(action, subject) {
      if (
        subject.isInGroup("users")
          && (
            action.id == "org.freedesktop.login1.reboot" ||
            action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
            action.id == "org.freedesktop.login1.power-off" ||
            action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
            action.id == "org.freedesktop.login1.hibernate-multiple-sessions"
          )
        )
      {
        return polkit.Result.YES;
      }
    })
  '';
</nowiki>}}


== Authentication agents ==
== Authentication agents ==