41955fa
Index: shadow-4.5/libmisc/chkname.c
41955fa
===================================================================
41955fa
--- shadow-4.5.orig/libmisc/chkname.c
41955fa
+++ shadow-4.5/libmisc/chkname.c
b90f1c3
@@ -47,27 +47,46 @@
d29b2a8
 #include "chkname.h"
d29b2a8
 
ea53f7c
 static bool is_valid_name (const char *name)
d29b2a8
-{
d29b2a8
+{      
ea53f7c
 	/*
ea53f7c
-	 * User/group names must match [a-z_][a-z0-9_-]*[$]
ea53f7c
-	 */
ea53f7c
-	if (('\0' == *name) ||
ea53f7c
-	    !((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) {
ea53f7c
+         * User/group names must match gnu e-regex:
ea53f7c
+         *    [a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?
ea53f7c
+         *
ea53f7c
+         * as a non-POSIX, extension, allow "$" as the last char for
ea53f7c
+         * sake of Samba 3.x "add machine script"
d29b2a8
+         *
b90f1c3
+         * Also do not allow fully numeric names or just "." or "..".
ea53f7c
+         */
d29b2a8
+	int numeric;
d29b2a8
+
b90f1c3
+	if ('\0' == *name ||
b90f1c3
+	    ('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
b90f1c3
+			      '\0' == name[1])) ||
b90f1c3
+	    !((*name >= 'a' && *name <= 'z') ||
b90f1c3
+	      (*name >= 'A' && *name <= 'Z') ||
b90f1c3
+	      (*name >= '0' && *name <= '9') ||
b90f1c3
+	      *name == '_' ||
b90f1c3
+	      *name == '.')) {
ea53f7c
 		return false;
ea53f7c
 	}
ea53f7c
 
d29b2a8
+	numeric = isdigit(*name);
d29b2a8
+
ea53f7c
 	while ('\0' != *++name) {
ea53f7c
-		if (!(( ('a' <= *name) && ('z' >= *name) ) ||
ea53f7c
-		      ( ('0' <= *name) && ('9' >= *name) ) ||
ea53f7c
-		      ('_' == *name) ||
ea53f7c
-		      ('-' == *name) ||
ea53f7c
-		      ( ('$' == *name) && ('\0' == *(name + 1)) )
b90f1c3
+		if (!((*name >= 'a' && *name <= 'z') ||
b90f1c3
+		      (*name >= 'A' && *name <= 'Z') ||
b90f1c3
+		      (*name >= '0' && *name <= '9') ||
b90f1c3
+		      *name == '_' ||
b90f1c3
+		      *name == '.' ||
b90f1c3
+		      *name == '-' ||
b90f1c3
+		      (*name == '$' && name[1] == '\0')
b90f1c3
 		     )) {
ea53f7c
 			return false;
ea53f7c
 		}
d29b2a8
+		numeric &= isdigit(*name);
ea53f7c
 	}
d29b2a8
 
d29b2a8
-	return true;
d29b2a8
+	return !numeric;
d29b2a8
 }
d29b2a8
 
d29b2a8
 bool is_valid_user_name (const char *name)
41955fa
Index: shadow-4.5/man/groupadd.8.xml
41955fa
===================================================================
41955fa
--- shadow-4.5.orig/man/groupadd.8.xml
41955fa
+++ shadow-4.5/man/groupadd.8.xml
f38d60a
@@ -256,10 +256,14 @@
44a40b2
    <refsect1 id='caveats'>
44a40b2
      <title>CAVEATS</title>
44a40b2
      <para>
44a40b2
-       Groupnames must start with a lower case letter or an underscore,
44a40b2
-       followed by lower case letters, digits, underscores, or dashes.
44a40b2
-       They can end with a dollar sign.
44a40b2
-       In regular expression terms: [a-z_][a-z0-9_-]*[$]?
f38d60a
+       Groupnames may contain only lower and upper case letters, digits,
f38d60a
+       underscores, or dashes. They can end with a dollar sign.
f38d60a
+
f38d60a
+       Dashes are not allowed at the beginning of the groupname.
f38d60a
+       Fully numeric groupnames and groupnames . or .. are
f38d60a
+       also disallowed.
f38d60a
+
f38d60a
+       In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
44a40b2
      </para>
44a40b2
      <para>
f38d60a
        Groupnames may only be up to &GROUP_NAME_MAX_LENGTH; characters long.
41955fa
Index: shadow-4.5/man/useradd.8.xml
41955fa
===================================================================
41955fa
--- shadow-4.5.orig/man/useradd.8.xml
41955fa
+++ shadow-4.5/man/useradd.8.xml
f38d60a
@@ -633,10 +633,16 @@
44a40b2
     </para>
44a40b2
 
44a40b2
     <para>
44a40b2
-      Usernames must start with a lower case letter or an underscore,
44a40b2
-      followed by lower case letters, digits, underscores, or dashes.
44a40b2
-      They can end with a dollar sign.
44a40b2
-      In regular expression terms: [a-z_][a-z0-9_-]*[$]?
f38d60a
+      Usernames may contain only lower and upper case letters, digits,
f38d60a
+      underscores, or dashes. They can end with a dollar sign.
f38d60a
+
f38d60a
+      Dashes are not allowed at the beginning of the username.
f38d60a
+      Fully numeric usernames and usernames . or .. are
f38d60a
+      also disallowed. It is not recommended to use usernames beginning
f38d60a
+      with . character as their home directories will be hidden in
f38d60a
+      the <command>ls</command> output.
f38d60a
+
f38d60a
+      In regular expression terms: [a-zA-Z0-9_.][a-zA-Z0-9_.-]*[$]?
44a40b2
     </para>
f38d60a
     <para>
f38d60a
       Usernames may only be up to 32 characters long.