Blame SOURCES/shadow-4.1.5.1-goodname.patch

9f90df
diff -up shadow-4.1.5.1/libmisc/chkname.c.goodname shadow-4.1.5.1/libmisc/chkname.c
9f90df
--- shadow-4.1.5.1/libmisc/chkname.c.goodname	2009-07-13 00:24:45.000000000 +0200
57b0e3
+++ shadow-4.1.5.1/libmisc/chkname.c	2018-04-24 16:32:40.970529916 +0200
57b0e3
@@ -49,25 +49,44 @@
9f90df
 static bool is_valid_name (const char *name)
9f90df
 {
9f90df
 	/*
9f90df
-	 * User/group names must match [a-z_][a-z0-9_-]*[$]
9f90df
-	 */
9f90df
-	if (('\0' == *name) ||
9f90df
-	    !((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) {
9f90df
+         * User/group names must match gnu e-regex:
9f90df
+         *    [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?
9f90df
+         *
9f90df
+         * as a non-POSIX, extension, allow "$" as the last char for
9f90df
+         * sake of Samba 3.x "add machine script"
57b0e3
+         *
57b0e3
+         * Also do not allow fully numeric names or just "." or "..".
9f90df
+         */
57b0e3
+	int numeric;
57b0e3
+
57b0e3
+	if ('\0' == *name ||
57b0e3
+	    ('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
57b0e3
+			      '\0' == name[1])) ||
57b0e3
+	    !((*name >= 'a' && *name <= 'z') ||
57b0e3
+	      (*name >= 'A' && *name <= 'Z') ||
57b0e3
+	      (*name >= '0' && *name <= '9') ||
57b0e3
+	      *name == '_' ||
57b0e3
+	      *name == '.')) {
9f90df
 		return false;
9f90df
 	}
9f90df
 
57b0e3
+	numeric = isdigit(*name);
57b0e3
+
9f90df
 	while ('\0' != *++name) {
9f90df
-		if (!(( ('a' <= *name) && ('z' >= *name) ) ||
9f90df
-		      ( ('0' <= *name) && ('9' >= *name) ) ||
9f90df
-		      ('_' == *name) ||
9f90df
-		      ('-' == *name) ||
9f90df
-		      ( ('$' == *name) && ('\0' == *(name + 1)) )
57b0e3
+		if (!((*name >= 'a' && *name <= 'z') ||
57b0e3
+		      (*name >= 'A' && *name <= 'Z') ||
57b0e3
+		      (*name >= '0' && *name <= '9') ||
57b0e3
+		      *name == '_' ||
57b0e3
+		      *name == '.' ||
57b0e3
+		      *name == '-' ||
57b0e3
+		      (*name == '$' && name[1] == '\0')
57b0e3
 		     )) {
9f90df
 			return false;
9f90df
 		}
57b0e3
+		numeric &= isdigit(*name);
9f90df
 	}
57b0e3
 
57b0e3
-	return true;
3bb5d4
+	return !numeric || getenv("SHADOW_ALLOW_ALL_NUMERIC_USER") != NULL;
57b0e3
 }
57b0e3
 
57b0e3
 bool is_valid_user_name (const char *name)
9f90df
diff -up shadow-4.1.5.1/man/groupadd.8.xml.goodname shadow-4.1.5.1/man/groupadd.8.xml
9f90df
--- shadow-4.1.5.1/man/groupadd.8.xml.goodname	2012-05-25 13:45:27.000000000 +0200
9f90df
+++ shadow-4.1.5.1/man/groupadd.8.xml	2012-09-19 18:43:53.492160653 +0200
3bb5d4
@@ -259,10 +259,14 @@
9f90df
    <refsect1 id='caveats'>
9f90df
      <title>CAVEATS</title>
9f90df
      <para>
9f90df
-       Groupnames must start with a lower case letter or an underscore,
9f90df
-       followed by lower case letters, digits, underscores, or dashes.
9f90df
-       They can end with a dollar sign.
9f90df
-       In regular expression terms: [a-z_][a-z0-9_-]*[$]?
3bb5d4
+       Groupnames may contain only lower and upper case letters, digits,
3bb5d4
+       underscores, or dashes. They can end with a dollar sign.
3bb5d4
+
3bb5d4
+       Dashes are not allowed at the beginning of the groupname.
3bb5d4
+       Fully numeric groupnames and groupnames . or .. are
3bb5d4
+       also disallowed.
3bb5d4
+
3bb5d4
+       In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
9f90df
      </para>
9f90df
      <para>
3bb5d4
        Groupnames may only be up to &GROUP_NAME_MAX_LENGTH; characters long.
9f90df
diff -up shadow-4.1.5.1/man/useradd.8.xml.goodname shadow-4.1.5.1/man/useradd.8.xml
9f90df
--- shadow-4.1.5.1/man/useradd.8.xml.goodname	2012-05-25 13:45:29.000000000 +0200
9f90df
+++ shadow-4.1.5.1/man/useradd.8.xml	2012-09-19 18:43:53.493160675 +0200
9f90df
@@ -366,7 +366,7 @@
9f90df
 	</term>
9f90df
 	<listitem>
9f90df
 	  <para>
9f90df
-	    Do no create the user's home directory, even if the system
9f90df
+	    Do not create the user's home directory, even if the system
9f90df
 	    wide setting from <filename>/etc/login.defs</filename>
9f90df
 	    (<option>CREATE_HOME</option>) is set to
9f90df
 	    <replaceable>yes</replaceable>.
3bb5d4
@@ -654,10 +654,16 @@
9f90df
     </para>
9f90df
 
9f90df
     <para>
9f90df
-      Usernames must start with a lower case letter or an underscore,
9f90df
-      followed by lower case letters, digits, underscores, or dashes.
9f90df
-      They can end with a dollar sign.
9f90df
-      In regular expression terms: [a-z_][a-z0-9_-]*[$]?
3bb5d4
+      Usernames may contain only lower and upper case letters, digits,
3bb5d4
+      underscores, or dashes. They can end with a dollar sign.
3bb5d4
+
3bb5d4
+      Dashes are not allowed at the beginning of the username.
3bb5d4
+      Fully numeric usernames and usernames . or .. are
3bb5d4
+      also disallowed. It is not recommended to use usernames beginning
3bb5d4
+      with . character as their home directories will be hidden in
3bb5d4
+      the <command>ls</command> output.
3bb5d4
+
3bb5d4
+      In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
9f90df
     </para>
3bb5d4
     <para>
3bb5d4
       Usernames may only be up to 32 characters long.