!165 [sync] PR-163: limit username length to 32

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2025-02-08 07:54:15 +00:00 committed by Gitee
commit ea100d677d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From cb569337f22de160d61df0bdb7c06f17517835ab Mon Sep 17 00:00:00 2001
From: zhangshaoning <zhangshaoning@uniontech.com>
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

View File

@ -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 <gengqihu2@h-partners.com> - 2:4.14.3-6
- limit username length to 32
* Mon Dec 16 2024 beta <beta@yfqm.date> - 2:4.14.3-5
- backport patches from upstream