1 Star 0 Fork 37

wjiang/shadow

forked from src-openEuler/shadow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
limit-username-length-to-32.patch 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
zhangsn 提交于 2025-01-17 10:07 +08:00 . fix: limit username length to 32
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fwo/shadow.git
git@gitee.com:fwo/shadow.git
fwo
shadow
shadow
master

搜索帮助