Commit graph

147 commits

Author SHA1 Message Date
Bjørn Forsman fa8ace3618 nixos: don't implicitly map missing user groups to nogroup
Before: `users.users.user1.group = "group-not-defined-anywhere-else"`
would result in user1 having the primary group `nogroup`, assigned at
activation time and only with a (easy to miss) warning from the
activation script. This behaviour is a security issue becase no files
should be owned by `nogroup` and it allows for unrelated users (and
services) to accidentally have access to files they shouldn't have.

After: The configuration above results in this eval error:
  - The following users have a primary group that is undefined: user1
  Hint: Add this to your NixOS config:
    users.groups.group-not-defined-anywhere-else = {};
2023-10-06 19:33:01 +02:00
Artturi 713af20167
Merge pull request #241518 from Gerg-L/use-xdg-base-directories 2023-09-25 00:45:31 +03:00
rnhmjoj 205b56cffc
nixos/user-groups: fixup of 5666a378 2023-09-13 11:44:19 +02:00
rnhmjoj 5666a378cb
nixos/users-groups: rename passwordFile in hashedPasswordFile
This avoids the possible confusion with `passwordFile` being the file
version of `password`, while it should contain the password hash.

Fixes issue #165858.
2023-09-08 21:19:40 +02:00
Ramses 76f8cf18d1 nixos/update-users-groups: no need to include extra package
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-09-03 11:26:37 +02:00
r-vdp d560a5e07d nixos/update-users-groups: fix cross compilation
Since #246772, cross compiled NixOS is broken because the DateTime perl
package that was used in the update-users-groups.pl script depends on
Testutf8 which does not cross compile (see #198548).

This PR drops the DateTime dependency in favour of TimePiece, which has
less dependencies and whose closure does cross compile.
2023-09-03 11:26:37 +02:00
Franz Pletz da37904672
Merge pull request #246772 from R-VdP/nixos-user-expiry
nixos/update-users-groups: add support for account expiry
2023-08-26 02:41:34 +02:00
Gerg-L bf383adf0a nixos/user-groups: Add to $NIX_PROFILES paths 2023-07-18 23:33:18 -04:00
Lily Foster e9207b0501
nixos/*: unhide remaining systemd stage-1 options
These options were missed in NixOS/nixpkgs#226237, but they all were
specifically added for systemd stage-1.
2023-07-03 08:41:38 -04:00
Victor Engmark b0a9abedea refactor: Use dummy variable name for unused value
As recommended by ShellCheck
<https://github.com/koalaman/shellcheck/wiki/SC2034>.
2023-06-08 15:11:35 +12:00
Will Fancher e70b42bf61 systemd-initrd: Add users and groups with static IDs. 2023-04-12 13:55:50 -04:00
Jan Tojnar 5a3eb4f6fe nixos/users-groups: Fix password scheme validation
0d7cd66652 broke validation for hashes with options
such as those generated with `mkpasswd --method=sha-512 --rounds=1000000`:

    $6$rounds=1000000$xpzZ6Rfg873gZnDY$RxS7lpVnohfDrrKG3lt9UFHED1KoiPGzH7zQv/HzwalZepo/IfFtxw05ap25duEJSKYhC14.Fn9eXszEpWVtF.

This fixes it.
2023-04-03 02:16:07 +02:00
github-actions[bot] f2ead7fbda
Merge master into staging-next 2023-03-24 12:01:43 +00:00
Ryan Lahfa a119bfc80d
Merge pull request #211603 from farcaller/fish
Assert that fish configuration is enabled if any user has fish as their shell
2023-03-24 12:05:22 +01:00
Martin Weinelt 0d7cd66652
nixos/users-groups: Update password scheme validation
Updates the warnings message for statefully set up passwords, now that
weak algorithms have been removed from our libxcrypt package.

Additionall we now add proper validation for hashing schemes used in
`hashedPassword`.

Neither will prevent a rebuiild, but instead issue a warning, that this
requires immediate remediation, or else users will be unable to login.

Reuses the crypt scheme ids as provided by the libxcrypt package.
2023-03-13 07:54:27 +01:00
Lily Foster c56e5ef801 nixos/users-groups: update option description to clarify initial* option precedence 2023-02-25 14:27:35 -05:00
Sandro d26c778ade
Merge pull request #153127 from eyJhb/user-uids-fix
nixos/users+nixos/lightdm: fixed users starting at 1000, and system users below 1000
2023-01-30 11:32:10 +01:00
Vladimir Pouzanov 631b7f6f88 Add support for the other shells 2023-01-19 16:59:11 +00:00
Vladimir Pouzanov 59296fbbc3 Assert that fish configuration is enabled if any user has fish as their shell.
Suggested-By: matthiasbeyer
2023-01-19 16:28:54 +00:00
pennae 4c1cfbdb84 modules: add mkAliasOptionModuleMD
mkAliasOptionModule should not default to mdDoc descriptions because
that can break out-of-tree users of documentation infrastructure. add an
explicitly-MD variant for now, to be removed some time after the MD
transition is complete.
2023-01-05 02:33:13 +01:00
Sandro 73c0b5c4e8 nixos/users-groups: make isNormalUser description readable 2022-12-27 18:23:21 +01:00
figsoda 7dfc2a1369 nixos/user-groups: remove unnecessary parentheses 2022-11-30 17:58:55 -05:00
zimbatm 9da75fdaf1
nixos/update-users-groups: add support for account expiry
Introduce a `users.users.<name>.expires` option to allows setting an
expiry date to user accounts.

This is useful when members should gain temporary access and you don't
want to have to roll out another system update to disable them.
2022-11-30 21:09:41 +01:00
Martin Weinelt 78155df21d
nixos/users-groups: Warn about deprecated hashes at activation
To allow for a reasonably fast deprecation of weak password hashing
schemes we provide an activation script that checks existing hashes in
/etc/shadow and issues a warning for user accounts that still rely on
deprecated hashes.

Co-Authored-By: oxalica <oxalicc@pm.me>
2022-11-19 14:07:59 +01:00
Martin Weinelt f391e6dbcc
nixos/user: Don't recommend mkpasswd methods
Instead rely on the default, which at this time is yescrypt.
2022-11-19 14:07:59 +01:00
Franz Pletz 32e7482074
nixos/tests/shadow: new hashes support with libxcrypt 2022-10-09 18:09:41 +02:00
pennae 7f6d0d1674 nixos/users-groups: convert remaining descriptions to MD
manpage is unchanged, html change is only in whitespace
2022-08-27 19:18:29 +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 3aebb4a2be nixos/*: normalize link format
make (almost) all links appear on only a single line, with no
unnecessary whitespace, using double quotes for attributes. this lets us
automatically convert them to markdown easily.

the few remaining links are extremely long link in a gnome module, we'll
come back to those at a later date.
2022-08-03 21:57:46 +02:00
pennae 9c8531c8a5 nixos/*: replace <replaceable>s with «thing»
we can't embed syntactic annotations of this kind in markdown code
blocks without yet another extension. replaceable is rare enough to make
this not much worth it, so we'll go with «thing» instead. the module
system already uses this format for its placeholder names in attrsOf
paths.
2022-08-03 21:08:58 +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
Klemens Nanni 574a90771f lib.types, nixos/users: Make passwdEntry available
More nixpkgs code such as `boot.initrd.systemd.emergencyAccess` defines
options that takes hashed passwords, so move the type definition from
modules/ into lib/.

The type definition itself stays unchanged.
2022-06-25 16:34:47 +04:00
Janne Heß e9bdd5fa74
Merge pull request #168168 from fedeinthemix/home-mode
nixos/users-group: Add 'homeMode' option.
2022-05-23 12:27:49 +02:00
Jared Baur 5463b86d03
nixos/users: Fix typo 2022-05-22 22:13:39 -07:00
Federico Beffa 311aa6d05d nixos/users-group: Update description of 'homeMode' option. 2022-05-14 11:59:44 +02:00
Federico Beffa 9fc01af1cc nixos/users-group: Add 'homeMode' option. 2022-04-11 13:16:38 +02:00
eyjhb db74bf5375
nixos/users: isSystemUser below 1000 above 400
To reflect changes done in 23d920c8f0
2022-02-26 22:53:03 +01:00
Robert Hensing e3cfad0b9e nixos/users: Fix type error
Fixes what seems to be a programming error that went undetected by
me and @pasqui23

See https://github.com/NixOS/nixpkgs/issues/158279
2022-02-05 22:38:56 +01:00
Pasquale 07abf6942f
nixos/users:added users.allowLoginless
Correct the assertion logic

Fixed indentation

Better wording od allowLoginless' description

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>

Better formatting

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>

allowLoginless -> allowNoPasswordLogin

Clarified users.allowNoPasswordLogin's  description

Clarified assertion expression

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>

Reworded assertion message to gude to safer alternative
2022-02-05 16:00:55 +01:00
Nikolay Amiantov f2c5970a76 users-groups service: add autoSubUidGidRange option
Previously we allocated subuids automatically for all normal users.
Make this explicitly configurable, so that one can use this for system
users too (or explicitly disable for normal users). Also don't allocate
automatically by default if a user already has ranges specified statically.
2022-01-09 09:43:55 +03:00
Artturin fc4df13e26 nixos: add sgx group with gid 304
fix Unknown group 'sgx', ignoring message from udev
2021-12-05 01:37:43 +02:00
Naïm Favier 2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Guillaume Girol 3592034595
Merge pull request #133166 from symphorien/nonogroup
Don't default to nogroup for the primary group of users.
2021-09-13 18:29:21 +00:00
Janne Heß a851b4d20e
nixos/users-groups: Add dry mode 2021-09-07 10:30:42 +02:00
Guillaume Girol 0f15a8f489 nixos/users-groups: don't default users.users.<name>.group to nogroup
this is unsafe, as many distinct services may be running as the same
nogroup group.
2021-09-03 21:22:07 +02:00
Silvan Mosberger ea00f991c0 nixos/users: Populate group members option
This change makes it so that accessing config.users.groups.*.members isn't
empty by default, but instead contains all the users whose `extraGroups`
includes that group, allowing fancy things like

  { config, ... }: {
    users.groups.libvirt.members = config.users.groups.wheel.members;
  }

to add all users in the wheel group to the libvirt group
2021-08-08 18:40:06 +02:00
Ben Siraphob b63a54f81c
Merge pull request #110742 from siraben/deprecate-fold 2021-07-27 15:13:31 +07:00
Alyssa Ross 9e400a8b93 nixos/users-groups: check format of passwd entries
Things will get quite broken if an /etc/passwd entry contains a
colon (which terminates a field), or a newline (which terminates a
record).  I know because I just accidentally made a user whose home
directory path contained a newline!

So let's make sure that can't happen.
2021-04-22 13:18:38 +00:00
Symphorien Gibol 7a87973b4c nixos/users: require one of users.users.name.{isSystemUser,isNormalUser}
As the only consequence of isSystemUser is that if the uid is null then
it's allocated below 500, if a user has uid = something below 500 then
we don't require isSystemUser to be set.

Motivation: https://github.com/NixOS/nixpkgs/issues/112647
2021-04-14 20:40:00 +02:00