From 87ec7a52ab25dd6e91253c274fd651f16844cf2a Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 7 Jan 2026 23:39:53 +0100 Subject: [PATCH] lib/chkhash.c: is_valid_hash(): Accept a leading '!' A leading '!' means that the account is locked. Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e") Link: Link: 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 668705007..cb45f3aa9 100644 --- a/lib/chkhash.c +++ b/lib/chkhash.c @@ -7,6 +7,8 @@ #include #include +#include "string/strcmp/strprefix.h" + /* * match_regex - return true if match, false if not @@ -37,6 +39,8 @@ match_regex(const char *pattern, const char *string) bool is_valid_hash(const char *hash) { + hash = strprefix(hash, "!") ?: hash; + // Minimum hash length if (strlen(hash) < 13) return false; -- 2.47.3