From ddc2549f87e3001f663d5179e9b6d7fe2e1f3b3f Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 7 Jan 2026 23:44:26 +0100 Subject: [PATCH] lib/chkhash.c: is_valid_hash(): Accept '*' as the hash 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: Closes: Reported-by: Chris Hofstaedtler Reviewed-by: Chris Hofstaedtler Cc: vinz Signed-off-by: Alejandro Colomar --- lib/chkhash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/chkhash.c b/lib/chkhash.c index cb45f3aa9..71e0fb4ed 100644 --- a/lib/chkhash.c +++ b/lib/chkhash.c @@ -7,6 +7,7 @@ #include #include +#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; -- 2.47.3