From b323141ee90f0c87d2cadfab25e21ae71da20fd8 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 15 Jan 2026 01:11:52 +0100 Subject: [PATCH] lib/chkhash.c: is_valid_hash(): Accept an empty hash It represents a passwordless account. That is discouraged, but accepted. Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e") Link: Reported-by: Marc 'Zugschlus' Haber Reported-by: "Serge E. Hallyn" Reported-by: Adam Williamson Co-authored-by: "Serge E. Hallyn" 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 71e0fb4ed..d0a8dc011 100644 --- a/lib/chkhash.c +++ b/lib/chkhash.c @@ -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; -- 2.47.3