Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2305.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ In addition to numerous new and upgraded packages, this release has the followin

- `nixos-rebuild` now supports an extra `--specialisation` option that can be used to change specialisation for `switch` and `test` commands.

- `libxcrypt`, the library providing the `crypt(3)` password hashing function, is now built without support for algorithms not flagged [`strong`](https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf#L48). This affects the availability of password hashing algorithms used for system login (`login(1)`, `passwd(1)`), but also Apache2 Basic-Auth, Samba, OpenLDAP, and [many other packages](https://github.com/search?q=repo%3ANixOS%2Fnixpkgs%20libxcrypt&type=code).

## New Services {#sec-release-23.05-new-services}

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
Expand Down
13 changes: 8 additions & 5 deletions nixos/modules/config/users-groups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ in {

###### implementation

config = {
config = let
cryptSchemeIdPatternGroup = "(${lib.concatStringsSep "|" pkgs.libxcrypt.enabledCryptSchemeIds})";
in {

users.users = {
root = {
Expand Down Expand Up @@ -601,15 +603,16 @@ in {
text = ''
users=()
while IFS=: read -r user hash tail; do
if [[ "$hash" = "$"* && ! "$hash" =~ ^\$(y|gy|7|2b|2y|2a|6)\$ ]]; then
if [[ "$hash" = "$"* && ! "$hash" =~ ^\''$${cryptSchemeIdPatternGroup}\$ ]]; then
users+=("$user")
fi
done </etc/shadow

if (( "''${#users[@]}" )); then
echo "
WARNING: The following user accounts rely on password hashes that will
be removed in NixOS 23.05. They should be renewed as soon as possible."
WARNING: The following user accounts rely on password hashing algorithms
that have been removed. They need to be renewed as soon as possible, as
they do prevent their users from logging in."
printf ' - %s\n' "''${users[@]}"
fi
'';
Expand Down Expand Up @@ -716,7 +719,7 @@ in {
let
sep = "\\$";
base64 = "[a-zA-Z0-9./]+";
id = "[a-z0-9-]+";
id = cryptSchemeIdPatternGroup;
value = "[a-zA-Z0-9/+.-]+";
options = "${id}(=${value})?(,${id}=${value})*";
scheme = "${id}(${sep}${options})?";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/security/pam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ let
optionalString config.services.homed.enable ''
password sufficient ${config.systemd.package}/lib/security/pam_systemd_home.so
'' + ''
password sufficient pam_unix.so nullok sha512
password sufficient pam_unix.so nullok yescrypt
'' +
optionalString config.security.pam.enableEcryptfs ''
password optional ${pkgs.ecryptfs}/lib/security/pam_ecryptfs.so
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/x11/display-managers/gdm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ in

account sufficient pam_unix.so

password requisite pam_unix.so nullok sha512
password requisite pam_unix.so nullok yescrypt

session optional pam_keyinit.so revoke
session include login
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/x11/display-managers/lightdm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ in

account sufficient pam_unix.so

password requisite pam_unix.so nullok sha512
password requisite pam_unix.so nullok yescrypt

session optional pam_keyinit.so revoke
session include login
Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/pam/test_chfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"auth sufficient pam_rootok.so",
"auth sufficient pam_unix.so likeauth try_first_pass",
"password sufficient @@pam_krb5@@/lib/security/pam_krb5.so use_first_pass",
"password sufficient pam_unix.so nullok sha512",
"password sufficient pam_unix.so nullok yescrypt",
"session optional @@pam_krb5@@/lib/security/pam_krb5.so",
"session required pam_env.so conffile=/etc/pam/environment readenv=0",
"session required pam_unix.so",
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/docker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ rec {
cat > /etc/pam.d/other <<EOF
account sufficient pam_unix.so
auth sufficient pam_rootok.so
password requisite pam_unix.so nullok sha512
password requisite pam_unix.so nullok yescrypt
session required pam_unix.so
EOF
fi
Expand Down
19 changes: 16 additions & 3 deletions pkgs/development/libraries/libxcrypt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ stdenv.mkDerivation rec {
];

configureFlags = [
"--enable-hashes=all"
# Update the enabled crypt scheme ids in passthru when the enabled hashes change
"--enable-hashes=strong"
"--enable-obsolete-api=glibc"
"--disable-failure-tokens"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [
Expand All @@ -30,8 +31,20 @@ stdenv.mkDerivation rec {

doCheck = true;

passthru.tests = {
inherit (nixosTests) login shadow;
passthru = {
tests = {
inherit (nixosTests) login shadow;
};
enabledCryptSchemeIds = [
# https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf
"y" # yescrypt
"gy" # gost_yescrypt
"7" # scrypt
"2b" # bcrypt
"2y" # bcrypt_y
"2a" # bcrypt_a
"6" # sha512crypt
];
};

meta = with lib; {
Expand Down
8 changes: 3 additions & 5 deletions pkgs/os-specific/linux/pam/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib, stdenv, buildPackages, fetchurl, flex, cracklib, db4, gettext, audit
{ lib, stdenv, buildPackages, fetchurl, flex, cracklib, db4, gettext, audit, libxcrypt
, nixosTests
, withLibxcrypt ? true, libxcrypt
}:

stdenv.mkDerivation rec {
Expand All @@ -20,9 +19,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ flex ]
++ lib.optional stdenv.buildPlatform.isDarwin gettext;

buildInputs = [ cracklib db4 ]
++ lib.optional stdenv.buildPlatform.isLinux audit
++ lib.optional withLibxcrypt libxcrypt;
buildInputs = [ cracklib db4 libxcrypt ]
++ lib.optional stdenv.buildPlatform.isLinux audit;

enableParallelBuilding = true;

Expand Down