Blame SOURCES/shadow-4.6-goodname.patch

186eda
diff -up shadow-4.6/libmisc/chkname.c.goodname shadow-4.6/libmisc/chkname.c
186eda
--- shadow-4.6/libmisc/chkname.c.goodname	2020-10-23 12:50:47.202529031 +0200
186eda
+++ shadow-4.6/libmisc/chkname.c	2020-10-23 12:54:54.604692559 +0200
186eda
@@ -49,25 +49,44 @@
9f13c6
 static bool is_valid_name (const char *name)
186eda
 {
9f13c6
 	/*
9f13c6
-	 * User/group names must match [a-z_][a-z0-9_-]*[$]
9f13c6
-	 */
9f13c6
-	if (('\0' == *name) ||
9f13c6
-	    !((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) {
9f13c6
+         * User/group names must match gnu e-regex:
9f13c6
+         *    [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?
9f13c6
+         *
9f13c6
+         * as a non-POSIX, extension, allow "$" as the last char for
9f13c6
+         * sake of Samba 3.x "add machine script"
9f13c6
+         *
9f13c6
+         * Also do not allow fully numeric names or just "." or "..".
9f13c6
+         */
9f13c6
+	int numeric;
9f13c6
+
9f13c6
+	if ('\0' == *name ||
9f13c6
+	    ('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
9f13c6
+			      '\0' == name[1])) ||
9f13c6
+	    !((*name >= 'a' && *name <= 'z') ||
9f13c6
+	      (*name >= 'A' && *name <= 'Z') ||
9f13c6
+	      (*name >= '0' && *name <= '9') ||
9f13c6
+	      *name == '_' ||
9f13c6
+	      *name == '.')) {
9f13c6
 		return false;
9f13c6
 	}
9f13c6
 
9f13c6
+	numeric = isdigit(*name);
9f13c6
+
9f13c6
 	while ('\0' != *++name) {
9f13c6
-		if (!(( ('a' <= *name) && ('z' >= *name) ) ||
9f13c6
-		      ( ('0' <= *name) && ('9' >= *name) ) ||
9f13c6
-		      ('_' == *name) ||
9f13c6
-		      ('-' == *name) ||
9f13c6
-		      ( ('$' == *name) && ('\0' == *(name + 1)) )
9f13c6
+		if (!((*name >= 'a' && *name <= 'z') ||
9f13c6
+		      (*name >= 'A' && *name <= 'Z') ||
9f13c6
+		      (*name >= '0' && *name <= '9') ||
9f13c6
+		      *name == '_' ||
9f13c6
+		      *name == '.' ||
9f13c6
+		      *name == '-' ||
9f13c6
+		      (*name == '$' && name[1] == '\0')
9f13c6
 		     )) {
9f13c6
 			return false;
9f13c6
 		}
9f13c6
+		numeric &= isdigit(*name);
9f13c6
 	}
9f13c6
 
9f13c6
-	return true;
9f13c6
+	return !numeric;
9f13c6
 }
9f13c6
 
9f13c6
 bool is_valid_user_name (const char *name)
186eda
diff -up shadow-4.6/man/groupadd.8.xml.goodname shadow-4.6/man/groupadd.8.xml
186eda
--- shadow-4.6/man/groupadd.8.xml.goodname	2018-04-29 18:42:37.000000000 +0200
186eda
+++ shadow-4.6/man/groupadd.8.xml	2020-10-23 12:50:47.202529031 +0200
186eda
@@ -273,10 +273,14 @@
9f13c6
    <refsect1 id='caveats'>
9f13c6
      <title>CAVEATS</title>
9f13c6
      <para>
9f13c6
-       Groupnames must start with a lower case letter or an underscore,
9f13c6
-       followed by lower case letters, digits, underscores, or dashes.
9f13c6
-       They can end with a dollar sign.
9f13c6
-       In regular expression terms: [a-z_][a-z0-9_-]*[$]?
186eda
+       Groupnames may begin with lower and upper case letters, digits,
186eda
+       underscores, or periods. They may continue with all the aforementioned
186eda
+       characters, or dashes. Finally, they can end with a dollar sign.
9f13c6
+
186eda
+       Fully numeric groupnames and groupnames containing only . or .. are
186eda
+       disallowed.
9f13c6
+
9f13c6
+       In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
9f13c6
      </para>
9f13c6
      <para>
9f13c6
        Groupnames may only be up to &GROUP_NAME_MAX_LENGTH; characters long.
186eda
diff -up shadow-4.6/man/useradd.8.xml.goodname shadow-4.6/man/useradd.8.xml
186eda
--- shadow-4.6/man/useradd.8.xml.goodname	2018-04-29 18:42:37.000000000 +0200
186eda
+++ shadow-4.6/man/useradd.8.xml	2020-10-23 12:50:47.202529031 +0200
186eda
@@ -650,10 +650,16 @@
9f13c6
     </para>
9f13c6
 
9f13c6
     <para>
9f13c6
-      Usernames must start with a lower case letter or an underscore,
9f13c6
-      followed by lower case letters, digits, underscores, or dashes.
9f13c6
-      They can end with a dollar sign.
9f13c6
-      In regular expression terms: [a-z_][a-z0-9_-]*[$]?
186eda
+      Usernames may begin with lower and upper case letters, digits,
186eda
+      underscores, or periods. They may continue with all the aforementioned
186eda
+      characters, or dashes. Finally, they can end with a dollar sign.
9f13c6
+
186eda
+      Fully numeric usernames and usernames containing only . or .. are
186eda
+      disallowed. It is not recommended to use usernames beginning
9f13c6
+      with . character as their home directories will be hidden in
9f13c6
+      the <command>ls</command> output.
9f13c6
+
9f13c6
+      In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
9f13c6
     </para>
9f13c6
     <para>
9f13c6
       Usernames may only be up to 32 characters long.