]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/chkhash.c: is_valid_hash(): Accept an empty hash
authorAlejandro Colomar <alx@kernel.org>
Thu, 15 Jan 2026 00:11:52 +0000 (01:11 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 23 Jan 2026 15:42:06 +0000 (16:42 +0100)
It represents a passwordless account.
That is discouraged, but accepted.

Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e")
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1124835>
Reported-by: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Reported-by: "Serge E. Hallyn" <serge@hallyn.com>
Reported-by: Adam Williamson <awilliam@redhat.com>
Co-authored-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/chkhash.c

index 71e0fb4ed6fab1efc3c0c52fc4b5bda04742955e..d0a8dc0119785f7417660336c8f78d598979db5b 100644 (file)
@@ -42,6 +42,10 @@ is_valid_hash(const char *hash)
 {
        hash = strprefix(hash, "!") ?: hash;
 
+       // Passwordless account; discouraged
+       if (streq(hash, ""))
+               return true;
+
        if (streq(hash, "*"))
                return true;