public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Adam Williamson <adamwill@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/shadow-utils] rawhide: Backport PR #1772 to fix bogus hash check failures in Turkish (#2548931)
Date: Fri, 16 Oct 2026 01:31:32 GMT	[thread overview]
Message-ID: <179211429265.1.12190132228143740924.rpms-shadow-utils-8b82b21e7793@fedoraproject.org> (raw)

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
 

                 reply	other threads:[~2026-10-16  1:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179211429265.1.12190132228143740924.rpms-shadow-utils-8b82b21e7793@fedoraproject.org \
    --to=adamwill@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox