diff --git a/limit-username-length-to-32.patch b/limit-username-length-to-32.patch new file mode 100644 index 0000000000000000000000000000000000000000..23e9f3a836c29c221464148e006f1b70be02394e --- /dev/null +++ b/limit-username-length-to-32.patch @@ -0,0 +1,41 @@ +From cb569337f22de160d61df0bdb7c06f17517835ab Mon Sep 17 00:00:00 2001 +From: zhangshaoning +Date: Thu, 16 Jan 2025 16:30:09 +0800 +Subject: [PATCH] limit username length to 32 + +--- + lib/chkname.c | 4 ++-- + lib/chkname.h | 4 ++++ + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/lib/chkname.c b/lib/chkname.c +index 2b83361..ae6180f 100644 +--- a/lib/chkname.c ++++ b/lib/chkname.c +@@ -75,9 +75,9 @@ static bool is_valid_name (const char *name) + bool is_valid_user_name (const char *name) + { + /* +- * User names length are limited by the kernel ++ * User names length are limited by USER_NAME_MAX_LENGTH + */ +- if (strlen (name) > sysconf(_SC_LOGIN_NAME_MAX)) { ++ if (strlen (name) > USER_NAME_MAX_LENGTH) { + return false; + } + +diff --git a/lib/chkname.h b/lib/chkname.h +index 0771347..4af8f32 100644 +--- a/lib/chkname.h ++++ b/lib/chkname.h +@@ -25,3 +25,7 @@ extern bool is_valid_user_name (const char *name); + extern bool is_valid_group_name (const char *name); + + #endif ++ ++#ifndef USER_NAME_MAX_LENGTH ++#define USER_NAME_MAX_LENGTH 32 ++#endif +-- +2.18.2 + diff --git a/shadow.spec b/shadow.spec index c359c32b97d3ea045d662349ffeca829100f0d48..33068b712b8e9344a8e8197718406544159bbea5 100644 --- a/shadow.spec +++ b/shadow.spec @@ -1,6 +1,6 @@ Name: shadow Version: 4.14.3 -Release: 5 +Release: 6 Epoch: 2 License: BSD and GPLv2+ Summary: Tools for managing accounts and shadow password files @@ -23,6 +23,7 @@ Patch3: shadow-libsubid-Dealocate-memory-on-exit.patch Patch4: backport-lib-idmapping.c--Use-long-constants-in-prctl-2.patch Patch5: backport-man-lastlog-remove-wrong-use-of-keyword-term.patch Patch6: backport-lib-csrand.c-Fix-the-lower-part-of-the-domain-of-csr.patch +Patch7: limit-username-length-to-32.patch BuildRequires: gcc, libselinux-devel, audit-libs-devel, libsemanage-devel BuildRequires: libacl-devel, libattr-devel @@ -192,6 +193,9 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libsubid.{la,a} %{_mandir}/*/* %changelog +* Sat Feb 8 2025 hugel - 2:4.14.3-6 +- limit username length to 32 + * Mon Dec 16 2024 beta - 2:4.14.3-5 - backport patches from upstream