From aa4895b6f0b4df1188c36a9aad9e73b94736bced Mon Sep 17 00:00:00 2001 From: hugel <2712504175@qq.com> Date: Sat, 8 Feb 2025 10:08:34 +0800 Subject: [PATCH] limit username length to 32 (cherry picked from commit 430589ba91cf502f377b2743886f421dbe49b11a) --- limit-username-length-to-32.patch | 41 +++++++++++++++++++++++++++++++ shadow.spec | 6 ++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 limit-username-length-to-32.patch diff --git a/limit-username-length-to-32.patch b/limit-username-length-to-32.patch new file mode 100644 index 0000000..23e9f3a --- /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 c359c32..33068b7 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 -- Gitee