Commit Graph

71 Commits

Author SHA1 Message Date
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Noah S-C
5c4858ad7b
More specific link to tag spec
Co-authored-by: Aleksana <alexander.huang.y@gmail.com>
2024-04-03 17:52:28 +01:00
Noah Santschi-Cooney
1a5acce391
nixos/sudo: update command options enum for newer sudo version
The enum of allowed command options (NOPASSWD, NOEXEC etc) had not been updated when bumping sudo version.
MAIL/NOMAIL were added in [1.8.13](https://www.sudo.ws/releases/legacy/#1.8.13), FOLLOW/NOFOLLOW were added in [1.8.15](https://www.sudo.ws/releases/legacy/#1.8.15) and INTERCEPT/NOINTERCEPT in [1.9.8](https://www.sudo.ws/releases/stable/#1.9.8)
2024-04-02 15:15:53 +01:00
nicoo
2eac5106f1 nixos/sudo: Remove unused enableSSHAgentAuth let-binding 2024-01-04 17:30:09 +00:00
nicoo
d5a8e667d2 nixos/sudo: Update assertion message 2023-11-14 12:25:55 +00:00
Yureka
b0206f9bf9 nixos/sudo: enable by default
The default was accidentally changed to false in #262790
2023-11-10 03:30:39 +01:00
nicoo
b942382216 nixos/sudo: refactor processing of cfg.extraRules 2023-11-08 19:41:39 +00:00
nicoo
1852b67bc6 nixos/sudo: Make the default rules' options configurable 2023-11-08 19:41:39 +00:00
nicoo
93011e31bd nixos/sudo: Handle root's default rule through extraRules
This makes things more uniform; moreover, users can now inject rules before this.
2023-11-08 19:41:39 +00:00
nicoo
77ed368b20 nixos/sudo: Refactor option definitions 2023-11-08 19:41:38 +00:00
nicoo
19e1420e13 nixos/sudo: Move support for pam_ssh_agent_auth(8) to PAM's NixOS module 2023-11-08 19:41:37 +00:00
nicoo
ad92951579 nixos/sudo: Don't include empty sections
This makes the generated sudoers a touch easier to read.
2023-11-05 17:23:41 +00:00
nicoo
6e15779fda nixos/sudo: fix security.sudo.package 2023-10-26 19:00:25 +00:00
Maciej Krüger
57d41f9751
nixos/sudo: revert sudo-rs 922926cfbc (partial #253876)
This reverts the module changes that were added
by the addition of sudo-rs (merge 922926cfbc) from the sudo module.

Individual commits reverted:
* 409d29ca73 2023-08-31 | [nicoo] nixos/sudo: Split up `configFile` into individual sections
* 454151375d 2023-09-04 | [nicoo] nixos/sudo: Don't include empty sections
* 8742134c80 2023-09-04 | [nicoo] nixos/sudo: Only keep SSH_AUTH_SOCK if used for authentication
* f5aadb56be 2023-09-07 | [nicoo] nixos/sudo: Refactor option definitions
* 8b9e867ac8 2023-09-07 | [nicoo] nixos/sudo: Refactor checks for Todd C. Miller's implemetation
* 3a95964fd5 2023-09-07 | [nicoo] nixos/sudo: Drop useless `lib.` qualifiers
* b1eab8ca53 2023-09-07 | [nicoo] nixos/sudo: Handle `root`'s default rule through `extraRules`
* 717e51a140 2023-09-07 | [nicoo] nixos/sudo: Make the default rules' options configurable
* c11da39117 2023-09-07 | [nicoo] nixos/sudo: Drop the sudoers comment for `extraRules`
* f0107b4f63 2023-09-07 | [nicoo] nixos/sudo: Check syntax using the configured package
* 914bf58369 2023-09-07 | [nicoo] nixos/{sudo, terminfo}: Adjust defaults for compatibility with `sudo-rs`
* f66eb0df3b 2023-09-07 | [nicoo] nixos/sudo: Only wrap `sudoedit` when using Miller's sudo
* d63eb55e81 2023-09-13 | [nicoo] nixos/sudo: Generate `sudo-i` PAM config for interactive use of `sudo-rs`
* d8d0b8019f 2023-09-13 | [nicoo] nixos/sudo: Add myself as maintainer (nbraud/nixos/sudo-rs)
2023-09-22 15:13:56 +02:00
nicoo
d8d0b8019f nixos/sudo: Add myself as maintainer 2023-09-18 18:03:58 +00:00
nicoo
d63eb55e81 nixos/sudo: Generate sudo-i PAM config for interactive use of sudo-rs 2023-09-18 18:03:58 +00:00
nicoo
f66eb0df3b nixos/sudo: Only wrap sudoedit when using Miller's sudo 2023-09-18 17:36:15 +00:00
nicoo
914bf58369 nixos/{sudo, terminfo}: Adjust defaults for compatibility with sudo-rs 2023-09-18 17:36:15 +00:00
nicoo
f0107b4f63 nixos/sudo: Check syntax using the configured package
This is preferable even for regular `sudo`, but will ensure the check is useful
when using `sudo-rs` in the future.

Also, dropped antediluvian comment about the syntax check being disabled,
when it was clearly not commented out:
  - introduced in 2007, commit 6d65f0ae03ae14f3e978d89959253d9a8f5e0ec1;
  - reverted in 2014, commit e68a5b265a,
    but without ammending the comments.
2023-09-18 17:36:15 +00:00
nicoo
c11da39117 nixos/sudo: Drop the sudoers comment for extraRules
All rules are now handled through `extraRules`,
and it is never empty so `optionalString` isn't needed either.
2023-09-18 17:36:15 +00:00
nicoo
717e51a140 nixos/sudo: Make the default rules' options configurable 2023-09-18 17:36:15 +00:00
nicoo
b1eab8ca53 nixos/sudo: Handle root's default rule through extraRules
This makes things more uniform, and simplifies compatibility with sudo-rs.

Moreover, users can not inject rules before this if they need to.
2023-09-18 17:35:45 +00:00
nicoo
3a95964fd5 nixos/sudo: Drop useless lib. qualifiers
Also normalise indentation for `mdDoc` to what's prevalent in this file.
2023-09-18 17:35:07 +00:00
nicoo
8b9e867ac8 nixos/sudo: Refactor checks for Todd C. Miller's implemetation 2023-09-18 17:35:07 +00:00
nicoo
f5aadb56be nixos/sudo: Refactor option definitions 2023-09-18 17:35:06 +00:00
nicoo
8742134c80 nixos/sudo: Only keep SSH_AUTH_SOCK if used for authentication
This will make compatibility with `sudo-rs` easier.
2023-09-18 17:35:06 +00:00
nicoo
454151375d nixos/sudo: Don't include empty sections
This makes the generated sudoers a touch easier to read.
2023-09-18 17:35:06 +00:00
nicoo
409d29ca73 nixos/sudo: Split up configFile into individual sections 2023-09-18 17:35:06 +00:00
nicoo
10b6e8ba21 nixos/sudo: Guard against security.sudo.package = pkgs.sudo-rs;
This is not unlikely to happen, given the enthusiasm shown by some users,
but we are not there yet, and this will save them from breaking their system.
2023-09-04 22:00:00 +00:00
Felix Buehler
933a41a73f treewide: use optional instead of 'then []' 2023-06-25 09:11:40 -03:00
pennae
bd56368848 nixos/*: md-convert hidden plaintext options
most of these are hidden because they're either part of a submodule that
doesn't have its type rendered (eg because the submodule type is used in
an either type) or because they are explicitly hidden. some of them are
merely hidden from nix-doc-munge by how their option is put together.
2022-08-31 16:32:54 +02:00
pennae
7e7d68a250 nixos/*: mark pre-existing markdown descriptions as mdDoc 2022-08-19 22:40:58 +02:00
pennae
61e93df189 nixos/*: automatically convert option docs to MD
once again using nix-doc-munge (69d080323a)
2022-08-03 22:46:41 +02:00
pennae
16102dce2f nixos/*: replace <code> in option docs with <literal>
markdown can't represent the difference without another extension and
both the html manual and the manpage render them the same, so keeping the
distinction is not very useful on its own. with the distinction removed
we can automatically convert many options that use <code> tags to markdown.

the manpage remains unchanged, html manual does not render
differently (but class names on code tags do change from "code" to "literal").
2022-08-03 21:03:23 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Luke Granger-Brown
1853015550 nixos/pam: add support for pam-ussh
pam-ussh allows authorizing using an SSH certificate stored in your
SSH agent, in a similar manner to pam-ssh-agent-auth, but for
certificates rather than raw public keys.
2022-03-13 17:31:46 +00:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Robert Schütz
5624aa9f81 nixos/sudo: add option execWheelOnly
By setting the executable's group to wheel and permissions to 4510, we
make sure that only members of the wheel group can execute sudo.
2021-05-08 23:48:00 +02:00
Maximilian Bosch
d2dc0ae203
nixos/sudo: add package option
The `package`-option is always useful if modifying a package in an
overlay would mean that a lot of other packages need to be rebuilt as
well.

In case of `sudo` this is actually the case: when having an override for
it (e.g. for `withInsults = true;`), you'd have to rebuild e.g. `zfs`
and `grub` although that's not strictly needed.
2020-10-01 13:00:52 +02:00
Cole Helbling
13e2c75c93
nixos/sudo: default rule should be first
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.
2020-06-17 17:48:51 -07:00
Silvan Mosberger
cb1f1b4260
nixos/sudo: Fix extraRules example rendering 2020-02-10 01:37:07 +01:00
rnhmjoj
1d61efb7f1 treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
Silvan Mosberger
478e7184f8
nixos/modules: Remove all usages of types.string
And replace them with a more appropriate type

Also fix up some minor module problems along the way
2019-08-31 18:19:00 +02:00
Symphorien Gibol
a915b33315 nixos: add preferLocalBuild=true; on derivations for config files 2019-02-22 20:11:27 +01:00
Matthew Bauer
1b40dda8a7
Merge pull request #42834 from Synthetica9/patch-1
security.sudo.extraRules: documentation fix
2018-07-23 11:29:18 -04:00
ivanbrennan
d08967a3a8
nixos/security.sudo: describe extraRules order
The order of sudoers entries is significant. The man page for sudoers(5)
notes:

  Where there are multiple matches, the last match is used (which is not
  necessarily the most specific match).

This module adds a rule for group "wheel" matching all commands. If you
wanted to add a more specific rule allowing members of the "wheel" group
to run command `foo` without a password, you'd need to use mkAfter to
ensure your rule comes after the more general rule.

  extraRules = lib.mkAfter [
    {
      groups = [ "wheel" ];
      commands = [
        {
          command = "${pkgs.foo}/bin/foo";
          options = [ "NOPASSWD" "SETENV" ];
        }
      ]
    }
  ];

Otherwise, when configuration options are merged, if the general rule
ends up after the specific rule, it will dictate the behavior even when
running the `foo` command.
2018-07-01 15:50:51 -04:00
Patrick Hilhorst
38b7233f83
Update sudo.nix
Updated example for security.sudo.extraRules to match comment
2018-07-01 13:23:55 +02:00
giraffito
b9639d7e1f
nixos/security: fix description of sudo.wheelNeedsPassword
the previous description mistakenly described the opposite semantics
2018-03-16 21:50:46 +00:00
Shea Levy
fe406d66b2
nixos: sudo: Use build-time visudo for syntax check. 2018-02-28 15:01:33 -05:00
Leon Schuermann
f297ddb5c9 sudo: define extra rules in Nix language (#33905) 2018-01-17 14:56:08 +00:00