Skip to content

Commit

Permalink
nixos/sudo: default rule should be first
Browse files Browse the repository at this point in the history
In /etc/sudoers, the last-matched rule will override all
previously-matched rules. Thus, make the default rule show up first (but
still allow some wiggle room for a user to `mkBefore` it), before any
user-defined rules.

(cherry picked from commit 13e2c75)
  • Loading branch information
cole-h committed Jun 18, 2020
1 parent 87cde1c commit 30c703c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nixos/modules/security/sudo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ in

config = mkIf cfg.enable {

security.sudo.extraRules = [
# We `mkOrder 600` so that the default rule shows up first, but there is
# still enough room for a user to `mkBefore` it.
security.sudo.extraRules = mkOrder 600 [
{ groups = [ "wheel" ];
commands = [ { command = "ALL"; options = (if cfg.wheelNeedsPassword then [ "SETENV" ] else [ "NOPASSWD" "SETENV" ]); } ];
}
Expand Down

0 comments on commit 30c703c

Please sign in to comment.