代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 76176de0889c3e8b9b3a176da24e4f8dbbd380a3 Mon Sep 17 00:00:00 2001
From: Jan Synacek <jsynacek@redhat.com>
Date: Wed, 2 Oct 2019 11:59:41 +0200
Subject: [PATCH] basic/user-util: allow dots in user names
(based on commit 1a29610f5fa1bcb2eeb37d2c6b79d8d1a6dbb865)
Resolves: #1717603
---
src/basic/user-util.c | 9 ++++++---
src/test/test-user-util.c | 8 ++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index c533f67025..d92969c966 100644
--- a/src/basic/user-util.c
+++ b/src/basic/user-util.c
@@ -575,11 +575,14 @@ bool valid_user_group_name(const char *u) {
/* Checks if the specified name is a valid user/group name. Also see POSIX IEEE Std 1003.1-2008, 2016 Edition,
* 3.437. We are a bit stricter here however. Specifically we deviate from POSIX rules:
*
- * - We don't allow any dots (this would break chown syntax which permits dots as user/group name separator)
* - We require that names fit into the appropriate utmp field
* - We don't allow empty user names
*
* Note that other systems are even more restrictive, and don't permit underscores or uppercase characters.
+ *
+ * jsynacek: We now allow dots in user names. The checks are not exhaustive as user names like "..." are allowed
+ * and valid according to POSIX, but can't be created using useradd. However, ".user" can be created. Let's not
+ * complicate the code by adding additional checks for weird corner cases like these, as they don't really matter here.
*/
if (isempty(u))
@@ -587,14 +590,14 @@ bool valid_user_group_name(const char *u) {
if (!(u[0] >= 'a' && u[0] <= 'z') &&
!(u[0] >= 'A' && u[0] <= 'Z') &&
- u[0] != '_')
+ u[0] != '_' && u[0] != '.')
return false;
for (i = u+1; *i; i++) {
if (!(*i >= 'a' && *i <= 'z') &&
!(*i >= 'A' && *i <= 'Z') &&
!(*i >= '0' && *i <= '9') &&
- !IN_SET(*i, '_', '-'))
+ !IN_SET(*i, '_', '-', '.'))
return false;
}
diff --git a/src/test/test-user-util.c b/src/test/test-user-util.c
index c1428fab02..9114d30b8c 100644
--- a/src/test/test-user-util.c
+++ b/src/test/test-user-util.c
@@ -71,8 +71,6 @@ static void test_valid_user_group_name(void) {
assert_se(!valid_user_group_name("-1"));
assert_se(!valid_user_group_name("-kkk"));
assert_se(!valid_user_group_name("rööt"));
- assert_se(!valid_user_group_name("."));
- assert_se(!valid_user_group_name("eff.eff"));
assert_se(!valid_user_group_name("foo\nbar"));
assert_se(!valid_user_group_name("0123456789012345678901234567890123456789"));
assert_se(!valid_user_group_name_or_id("aaa:bbb"));
@@ -83,6 +81,8 @@ static void test_valid_user_group_name(void) {
assert_se(valid_user_group_name("_kkk"));
assert_se(valid_user_group_name("kkk-"));
assert_se(valid_user_group_name("kk-k"));
+ assert_se(valid_user_group_name(".moo"));
+ assert_se(valid_user_group_name("eff.eff"));
assert_se(valid_user_group_name("some5"));
assert_se(!valid_user_group_name("5some"));
@@ -102,8 +102,6 @@ static void test_valid_user_group_name_or_id(void) {
assert_se(!valid_user_group_name_or_id("-1"));
assert_se(!valid_user_group_name_or_id("-kkk"));
assert_se(!valid_user_group_name_or_id("rööt"));
- assert_se(!valid_user_group_name_or_id("."));
- assert_se(!valid_user_group_name_or_id("eff.eff"));
assert_se(!valid_user_group_name_or_id("foo\nbar"));
assert_se(!valid_user_group_name_or_id("0123456789012345678901234567890123456789"));
assert_se(!valid_user_group_name_or_id("aaa:bbb"));
@@ -114,6 +112,8 @@ static void test_valid_user_group_name_or_id(void) {
assert_se(valid_user_group_name_or_id("_kkk"));
assert_se(valid_user_group_name_or_id("kkk-"));
assert_se(valid_user_group_name_or_id("kk-k"));
+ assert_se(valid_user_group_name_or_id(".moo"));
+ assert_se(valid_user_group_name_or_id("eff.eff"));
assert_se(valid_user_group_name_or_id("some5"));
assert_se(!valid_user_group_name_or_id("5some"));
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。