blob: cc833362e9afed41d291f0d7b5f9fca44d364b48 [file] [log] [blame]
From ca472d6866e545aaa70a70020e3226f236a8aafc Mon Sep 17 00:00:00 2001
From: Shan Hai <shan.hai@windriver.com>
Date: Tue, 13 Sep 2016 13:45:46 +0800
Subject: [PATCH] shadow: use relaxed usernames
The groupadd from shadow does not allow upper case group names, the
same is true for the upstream shadow. But distributions like
Debian/Ubuntu/CentOS has their own way to cope with this problem,
this patch is picked up from CentOS release 7.0 to relax the usernames
restrictions to allow the upper case group names, and the relaxation is
POSIX compliant because POSIX indicate that usernames are composed of
characters from the portable filename character set [A-Za-z0-9._-].
Upstream-Status: Pending
Signed-off-by: Shan Hai <shan.hai@windriver.com>
---
libmisc/chkname.c | 30 ++++++++++++++++++------------
man/groupadd.8.xml | 6 ------
man/useradd.8.xml | 8 +-------
3 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/libmisc/chkname.c b/libmisc/chkname.c
index 90f185c..65762b4 100644
--- a/libmisc/chkname.c
+++ b/libmisc/chkname.c
@@ -55,22 +55,28 @@ static bool is_valid_name (const char *name)
}
/*
- * User/group names must match [a-z_][a-z0-9_-]*[$]
- */
-
- if (('\0' == *name) ||
- !((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) {
+ * User/group names must match gnu e-regex:
+ * [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?
+ *
+ * as a non-POSIX, extension, allow "$" as the last char for
+ * sake of Samba 3.x "add machine script"
+ */
+ if ( ('\0' == *name) ||
+ !((*name >= 'a' && *name <= 'z') ||
+ (*name >= 'A' && *name <= 'Z') ||
+ (*name >= '0' && *name <= '9') ||
+ (*name == '_') || (*name == '.')
+ )) {
return false;
}
while ('\0' != *++name) {
- if (!(( ('a' <= *name) && ('z' >= *name) ) ||
- ( ('0' <= *name) && ('9' >= *name) ) ||
- ('_' == *name) ||
- ('-' == *name) ||
- ('.' == *name) ||
- ( ('$' == *name) && ('\0' == *(name + 1)) )
- )) {
+ if (!( (*name >= 'a' && *name <= 'z') ||
+ (*name >= 'A' && *name <= 'Z') ||
+ (*name >= '0' && *name <= '9') ||
+ (*name == '_') || (*name == '.') || (*name == '-') ||
+ (*name == '$' && *(name + 1) == '\0')
+ )) {
return false;
}
}
diff --git a/man/groupadd.8.xml b/man/groupadd.8.xml
index 1e58f09..d804b61 100644
--- a/man/groupadd.8.xml
+++ b/man/groupadd.8.xml
@@ -272,12 +272,6 @@
<refsect1 id='caveats'>
<title>CAVEATS</title>
- <para>
- Groupnames must start with a lower case letter or an underscore,
- followed by lower case letters, digits, underscores, or dashes.
- They can end with a dollar sign.
- In regular expression terms: [a-z_][a-z0-9_-]*[$]?
- </para>
<para>
Groupnames may only be up to &GROUP_NAME_MAX_LENGTH; characters long.
</para>
diff --git a/man/useradd.8.xml b/man/useradd.8.xml
index a16d730..c0bd777 100644
--- a/man/useradd.8.xml
+++ b/man/useradd.8.xml
@@ -366,7 +366,7 @@
</term>
<listitem>
<para>
- Do no create the user's home directory, even if the system
+ Do not create the user's home directory, even if the system
wide setting from <filename>/etc/login.defs</filename>
(<option>CREATE_HOME</option>) is set to
<replaceable>yes</replaceable>.
@@ -660,12 +660,6 @@
the user account creation request.
</para>
- <para>
- Usernames must start with a lower case letter or an underscore,
- followed by lower case letters, digits, underscores, or dashes.
- They can end with a dollar sign.
- In regular expression terms: [a-z_][a-z0-9_-]*[$]?
- </para>
<para>
Usernames may only be up to 32 characters long.
</para>