Goal: Relaxed usernames/groupnames checking patch.

Status wrt upstream: Debian specific. Not to be used upstream

Details:
 Allows any non-empty user/grounames that don't contain ':' and '\n'
 characters and don't start with '-'. This patch is more restrictive
 than original Karl's version. closes: #264879
 Also closes: #377844
 
 Comments from Karl Ramm (shadow 1:4.0.3-9, 20 Aug 2003 02:06:50 -0400):
 
 I can't come up with a good justification as to why characters other
 than ':'s and '\0's should be disallowed in group and usernames (other
 than '-' as the leading character).  Thus, the maintenance tools don't
 anymore.  closes: #79682, #166798, #171179

Index: shadow-4.0.18.1/libmisc/chkname.c
===================================================================
--- shadow-4.0.18.1.orig/libmisc/chkname.c	2005-08-31 19:24:57.000000000 +0200
+++ shadow-4.0.18.1/libmisc/chkname.c	2006-09-17 12:25:11.379482737 +0200
@@ -17,6 +17,7 @@
 #endif
 static int good_name (const char *name)
 {
+#if 0
 	/*
 	 * User/group names must match [a-z_][a-z0-9_-]*[$]
 	 */
@@ -30,6 +31,16 @@
 		      (*name == '$' && *(name + 1) == '\0')))
 			return 0;
 	}
+#endif
+	/*
+	 * Allow more relaxed user/group names in Debian -- ^[^-:\n][^:\n]*$
+	 */
+	if (!*name || *name == '-')
+		return 0;
+	do
+		if (*name == ':' || *name == '\n')
+			return 0;
+	while (*++name);
 
 	return 1;
 }
Index: shadow-4.0.18.1/man/useradd.8.xml
===================================================================
--- shadow-4.0.18.1.orig/man/useradd.8.xml	2006-07-24 07:48:36.000000000 +0200
+++ shadow-4.0.18.1/man/useradd.8.xml	2006-09-17 12:25:11.383482768 +0200
@@ -172,6 +172,7 @@
 	    valid in conjunction with the <option>-m</option> option. The
 	    default is to not create the directory and to not copy any
 	    files.
+	    This option may not function correctly if the username has a / in it.
 	  </para>
 	</listitem>
       </varlistentry>
@@ -353,9 +354,13 @@
     </para>
 
     <para>
-      Usernames must begin with a lower case letter or an underscore, and
-      only lower case letters, underscores, dashes, and dollar signs may
-      follow. In regular expression terms: [a-z_][a-z0-9_-]*[$]
+      It is usually recommended to only use usernames that begin with
+      a lower case letter or an underscore, and are only followed by lower
+      case letters, digits, underscores, dashes, and optionally terminated by
+      a dollar sign. In regular expression terms: [a-z_][a-z0-9_-]*[$]?
+      On Debian, the only constraints are that usernames must neither start with a
+      dash ('-') nor contain a colon (':')
+      or an end of line ('\n').
     </para>
   </refsect1>
 
