Blame SOURCES/shadow-4.5-goodname.patch

9f13c6
Index: shadow-4.5/libmisc/chkname.c
9f13c6
===================================================================
9f13c6
--- shadow-4.5.orig/libmisc/chkname.c
9f13c6
+++ shadow-4.5/libmisc/chkname.c
9f13c6
@@ -47,27 +47,46 @@
9f13c6
 #include "chkname.h"
9f13c6
 
9f13c6
 static bool is_valid_name (const char *name)
9f13c6
-{
9f13c6
+{      
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)
9f13c6
Index: shadow-4.5/man/groupadd.8.xml
9f13c6
===================================================================
9f13c6
--- shadow-4.5.orig/man/groupadd.8.xml
9f13c6
+++ shadow-4.5/man/groupadd.8.xml
9f13c6
@@ -256,10 +256,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_-]*[$]?
9f13c6
+       Groupnames may contain only lower and upper case letters, digits,
9f13c6
+       underscores, or dashes. They can end with a dollar sign.
9f13c6
+
9f13c6
+       Dashes are not allowed at the beginning of the groupname.
9f13c6
+       Fully numeric groupnames and groupnames . or .. are
9f13c6
+       also 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.
9f13c6
Index: shadow-4.5/man/useradd.8.xml
9f13c6
===================================================================
9f13c6
--- shadow-4.5.orig/man/useradd.8.xml
9f13c6
+++ shadow-4.5/man/useradd.8.xml
9f13c6
@@ -633,10 +633,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_-]*[$]?
9f13c6
+      Usernames may contain only lower and upper case letters, digits,
9f13c6
+      underscores, or dashes. They can end with a dollar sign.
9f13c6
+
9f13c6
+      Dashes are not allowed at the beginning of the username.
9f13c6
+      Fully numeric usernames and usernames . or .. are
9f13c6
+      also 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.