public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/shadow-utils] rawhide: Backport PR #1772 to fix bogus hash check failures in Turkish (#2548931)
@ 2026-10-16  1:31 Adam Williamson
  0 siblings, 0 replies; only message in thread
From: Adam Williamson @ 2026-10-16  1:31 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/shadow-utils
Branch : rawhide
Commit : 8b82b21e779362694d5c5e84d0b88adc7edbbd75
Author : Adam Williamson <adamwill@fedoraproject.org>
Date   : 2026-10-15T18:30:52-07:00
Stats  : +93/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/shadow-utils/c/8b82b21e779362694d5c5e84d0b88adc7edbbd75?branch=rawhide

Log:
Backport PR #1772 to fix bogus hash check failures in Turkish (#2548931)

---
diff --git a/0001-Force-C-locale-before-regcomp-regexec.patch b/0001-Force-C-locale-before-regcomp-regexec.patch
new file mode 100644
index 0000000..b66e66f
--- /dev/null
+++ b/0001-Force-C-locale-before-regcomp-regexec.patch
@@ -0,0 +1,84 @@
+From a6484f6f43e7f017bf76cc493feedcd4ae6c97d4 Mon Sep 17 00:00:00 2001
+From: Alexey Tikhonov <atikhono@redhat.com>
+Date: Wed, 14 Oct 2026 15:07:17 +0200
+Subject: [PATCH] Force C locale before `regcomp()` & `regexec()`
+
+Some locales collate the Latin letters so that some characters fall
+outside [a-z]/[A-Za-z], (for example, 'tr_TR' and 'i'/'I')
+and this wrongly rejects valid hashes.
+Force the C locale for both compiling and executing the regex.
+---
+ lib/chkhash.c | 38 +++++++++++++++++++++++++++++---------
+ 1 file changed, 29 insertions(+), 9 deletions(-)
+
+diff --git a/lib/chkhash.c b/lib/chkhash.c
+index 3a0f246d..a58ec398 100644
+--- a/lib/chkhash.c
++++ b/lib/chkhash.c
+@@ -2,6 +2,7 @@
+ 
+ #include "chkhash.h"
+ 
++#include <locale.h>
+ #include <regex.h>
+ #include <stdbool.h>
+ #include <stddef.h>
+@@ -14,18 +15,37 @@
+ /*
+  * match_regex - return true if match, false if not
+  */
+-bool 
+-match_regex(const char *pattern, const char *string) 
++bool
++match_regex(const char *pattern, const char *string)
+ {
+ 	regex_t regex;
+-	int result;
+-
+-	if (regcomp(&regex, pattern, REG_EXTENDED) != 0)
++	int result = REG_NOMATCH;
++	locale_t current_locale;
++	locale_t c_locale;
++
++	/*
++	 * Some locales collate the Latin letters so that some characters fall
++	 * outside [a-z]/[A-Za-z], (for example, 'tr_TR' and 'i'/'I')
++	 * and this wrongly rejects valid hashes.
++	 * Force the C locale for both compiling and executing the regex.
++	 */
++	c_locale = newlocale(LC_ALL_MASK, "C", (locale_t) 0);
++	if (c_locale == (locale_t) 0) {
++		return false;
++	}
++	current_locale = uselocale(c_locale);
++	if (current_locale == (locale_t) 0) {
++		freelocale(c_locale);
+ 		return false;
++	}
+ 
+-	result = regexec(&regex, string, 0, NULL, 0);
+-	regfree(&regex);
++	if (regcomp(&regex, pattern, REG_EXTENDED) == 0) {
++		result = regexec(&regex, string, 0, NULL, 0);
++		regfree(&regex);
++	}
+ 
++	uselocale(current_locale);
++	freelocale(c_locale);
+ 	return result == 0;
+ }
+ 
+@@ -35,8 +55,8 @@ match_regex(const char *pattern, const char *string)
+  *
+  * regex from: https://man.archlinux.org/man/crypt.5.en
+  */
+-bool 
+-is_valid_hash(const char *hash) 
++bool
++is_valid_hash(const char *hash)
+ {
+ 	// Password temporarily locked
+ 	hash = strprefix(hash, "!") ?: hash;
+-- 
+2.55.0
+

diff --git a/shadow-utils.spec b/shadow-utils.spec
index 7bc7e8b..9f13390 100644
--- a/shadow-utils.spec
+++ b/shadow-utils.spec
@@ -1,7 +1,7 @@
 Summary: Utilities for managing accounts and shadow password files
 Name: shadow-utils
 Version: 4.20.0
-Release: 1%{?dist}
+Release: 2%{?dist}
 Epoch: 2
 License: BSD-3-Clause AND GPL-2.0-or-later
 URL: https://github.com/shadow-maint/shadow
@@ -20,6 +20,11 @@ Source7: passwd.pamd
 %global _ld_strict_symbol_defs 1
 
 ### Patches ###
+# https://github.com/shadow-maint/shadow/pull/1772
+# https://bugzilla.redhat.com/show_bug.cgi?id=2548931
+# Force C locale before regcomp() and regexec()
+# Fixes bogus invalid hash results in Turkish
+Patch: 0001-Force-C-locale-before-regcomp-regexec.patch
 
 ### Dependencies ###
 Requires: audit-libs >= 1.6.5
@@ -264,6 +269,9 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libsubid.a
 %{_libdir}/libsubid.so
 
 %changelog
+* Thu Oct 15 2026 Adam Williamson <adamwill@fedoraproject.org> - 2:4.20.0-2
+- Backport PR #1772 to fix bogus hash check failures in Turkish (#2548931)
+
 * Wed Jul 29 2026 Iker Pedrosa <ipedrosa@redhat.com> - 2:4.20.0-1
 - Rebase to version 4.20.0
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-16  1:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16  1:31 [rpms/shadow-utils] rawhide: Backport PR #1772 to fix bogus hash check failures in Turkish (#2548931) Adam Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox