Hi!

On Wed, Apr 26, 2006 at 08:36:51PM +0200, Nicolas François wrote:
> On Wed, Apr 26, 2006 at 04:10:36PM +0100, Reuben Thomas wrote:
> >        On Debian, the constraints on the username are lowered:
> >        Usernames must neither start by a dash ('-') nor contain a
> >        colon (':') or an end of line ('\n'). However, 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, underscores, dashes, and dollar signs. In
> >        regular expression terms: [a-z_][a-z0-9_-]*[$]

oops, actually should be smth. like:
                                            and are only followed by
        lower case letters, underscores, dashes, decimal digits and
        optionally terminated by dollar sign. In regular expression
        terms: ^[a-z_][a-z0-9_-]*[$]?$

> Thanks for pointing this.
> 
> The [a-z_][a-z0-9_-]*[$] regular expression is what is usually permitted.

Nicolas, looks that Reuben was right about this regexp
-- more correct one is ^[a-z_][a-z0-9_-]*[$]?$
i.e. ^[a-z_][a-z0-9_-]*\$?$

Let's look into original source code (libmisc/chkname.c):
        /*
         * 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;
        }


Therefore, the manpage text should read not 'dollar signs'
but 'optional dollar sign' (at end of user/groupname).
Also, digits are indeed allowed but not mentioned there.

-- 
WBR,
xrgtn

Reply via email to