b95810
Index: shadow-4.5/libmisc/chkname.c
b95810
===================================================================
b95810
--- shadow-4.5.orig/libmisc/chkname.c
b95810
+++ shadow-4.5/libmisc/chkname.c
b95810
@@ -47,27 +47,46 @@
b95810
 #include "chkname.h"
b95810
 
9f90df
 static bool is_valid_name (const char *name)
b95810
-{
b95810
+{      
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)
b95810
Index: shadow-4.5/man/groupadd.8.xml
b95810
===================================================================
b95810
--- shadow-4.5.orig/man/groupadd.8.xml
b95810
+++ shadow-4.5/man/groupadd.8.xml
b95810
@@ -256,10 +256,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.
b95810
Index: shadow-4.5/man/useradd.8.xml
b95810
===================================================================
b95810
--- shadow-4.5.orig/man/useradd.8.xml
b95810
+++ shadow-4.5/man/useradd.8.xml
b95810
@@ -633,10 +633,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.