Re: document some useradd/groupadd caveats

Nicolas François <[email protected]> Sat, 27 Aug 2005 23:11:55 +0200
Newsgroups gmane.linux.pld.shadow.general
Message-ID <[email protected]>
On Mon, Aug 22, 2005 at 08:40:36PM -0400, [email protected] wrote:
> find attached a patch which documents the limitations shadow places on user 
> and group names
> -mike

> Index: libmisc/chkname.c
> ===================================================================
> RCS file: /cvsroot/shadow/libmisc/chkname.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 chkname.c
> --- libmisc/chkname.c	12 May 2003 05:29:14 -0000	1.8
> +++ libmisc/chkname.c	23 Aug 2005 00:39:16 -0000
> @@ -18,7 +18,7 @@ RCSID ("$Id: chkname.c,v 1.8 2003/05/12 
>  static int good_name (const char *name)
>  {
>  	/*
> -	 * User/group names must match [a-z_][a-z0-9_-]*
> +	 * User/group names must match [a-z_][a-z0-9_-$]*
>  	 */
>  	if (!*name || !((*name >= 'a' && *name <= 'z') || *name == '_'))
>  		return 0;

        while (*++name) {
                if (!((*name >= 'a' && *name <= 'z') ||
                      (*name >= '0' && *name <= '9') ||
                      *name == '_' || *name == '-' ||
                      (*name == '$' && *(name + 1) == '\0')))
                        return 0;
        }

'$' is only allowed in the last position.
The regular expression should be [a-z_][a-z0-9_-]*[$]?

The other regular expressions in the documentation should also be fixed,
and a note for the dollar sign can be put in parenthesis.

Best Regards,
-- 
Nekral