git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/users-groups: add assertion for ":" in hashes
commit99899e2e464845da34638ab35125943e8445bce0 authorrnhmjoj <rnhmjoj@inventati.org> dateThu 25 Jun 2020, 02:00 (6 years ago) parent751c2ed
1 file changed+11−1
nixos/modules/config/users-groups.nix+11−1
nixos/modules/config/users-groups.nix+11−1
@@ -606,7 +606,17 @@ in {
606606 Neither the root account nor any wheel user has a password or SSH authorized key.
607607 You must set one to prevent being locked out of your system.'';
608608 }
609− ];
609+ ] ++ flip mapAttrsToList cfg.users (name: user:
610+ {
611+ assertion = (user.hashedPassword != null)
612+ -> (builtins.match ".*:.*" user.hashedPassword == null);
613+ message = ''
614+ The password hash of user "${name}" contains a ":" character.
615+ This is invalid and would break the login system because the fields
616+ of /etc/shadow (file where hashes are stored) are colon-separated.
617+ Please check the value of option `users.users."${name}".hashedPassword`.'';
618+ }
619+ );
610620
611621 warnings =
612622 builtins.filter (x: x != null) (