Skip to content

Commit

Permalink
nixos/systemd-sysusers: assert against password and hashedPassword
Browse files Browse the repository at this point in the history
Regardless of mutable or immutable users, systemd-sysupdate never
updates existing user records and thus will for example never change
passwords for you.

It only support initial passwords and now actively asserts agains other
paswords.
  • Loading branch information
nikstur committed Jul 21, 2024
1 parent 2710a49 commit 2ca0453
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nixos/modules/system/boot/systemd/sysusers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ in
assertion = config.users.mutableUsers -> config.system.etc.overlay.enable;
message = "config.users.mutableUsers requires config.system.etc.overlay.enable.";
}
] ++ lib.mapAttrsToList
(username: opts: {
] ++ (lib.mapAttrsToList
(_username: opts: {
assertion = !opts.isNormalUser;
message = "systemd-sysusers doesn't create normal users. You can currently only use it to create system users.";
})
userCfg.users;
userCfg.users)
++ lib.mapAttrsToList
(username: opts: {
assertion = (opts.password == opts.initialPassword || opts.password == null) &&
(opts.hashedPassword == opts.initialHashedPassword || opts.hashedPassword == null);
message = "${username} uses password or hashedPassword. systemd-sysupdate only supports initial passwords. It'll never update your passwords.";
})
systemUsers;

systemd = {

Expand Down

0 comments on commit 2ca0453

Please sign in to comment.