A leading '!' means that the account is locked.
Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e")
Link: <https://github.com/shadow-maint/shadow/issues/1483>
Link: <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>
Cherry-picked-from:
87ec7a52ab25 (2026-01-07; "lib/chkhash.c: is_valid_hash(): Accept a leading '!'")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
#include <stddef.h>
#include <string.h>
+#include "string/strcmp/strprefix.h"
+
/*
* match_regex - return true if match, false if not
bool
is_valid_hash(const char *hash)
{
+ hash = strprefix(hash, "!") ?: hash;
+
// Minimum hash length
if (strlen(hash) < 13)
return false;