]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/chkhash.c: is_valid_hash(): Accept '*' as the hash
authorAlejandro Colomar <alx@kernel.org>
Wed, 7 Jan 2026 22:44:26 +0000 (23:44 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 8 Jan 2026 02:01:02 +0000 (20:01 -0600)
This is widely accepted as an invalid hash, to remove password access
for an account (that is, no passwords will match the "hash").

Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e")
Closes: <https://github.com/shadow-maint/shadow/issues/1483>
Closes: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1124835>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Cc: vinz <mmpx09@protonmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/chkhash.c

index cb45f3aa9f6c536ac1c98142763522ad04aba1d4..71e0fb4ed6fab1efc3c0c52fc4b5bda04742955e 100644 (file)
@@ -7,6 +7,7 @@
 #include <stddef.h>
 #include <string.h>
 
+#include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 
 
@@ -41,6 +42,9 @@ is_valid_hash(const char *hash)
 {
        hash = strprefix(hash, "!") ?: hash;
 
+       if (streq(hash, "*"))
+               return true;
+
        // Minimum hash length
        if (strlen(hash) < 13)
                return false;