Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2459

Raspberry Pi OS • Re: adduser/ NAME_REGEX value.

$
0
0
adduser per documentation uses NAME_REGEX to determine valid User IDs. The issue is contrary to the documentation NAME_REGEX does not appear to have a value (default or otherwise) as an environment variable. I reflashed RasPI Bookworm64 for a RasPI4b and confirmed this. It was originally discovered after loading Bullseye32 and Bookworm 32 & 64 using PINN for a RasPI3.

adduser.conf(5) states

NAME_REGEX
Non-system user- and groupnames are checked against this regular expression. If the name doesn't match this regexp, user and group creation in adduser(8) is refused unless --allow-bad-names is set. With --allow-bad-names set, weaker checks are performed. Defaults to the most conservative ^[a-z][-a-z0-9_]*$. See SYS_NAME_REGXEX and Valid names, below, for more information.

...


VALID NAMES

Historically, adduser(8) and addgroup(8) enforced conformity to IEEE Std 1003.1-2001, which allows only the following characters to appear in group- and usernames: letters, digits, underscores, periods, at signs (@) and dashes. The name may not start with a dash or @. The "$" sign is allowed at the end of usernames to allow typical Samba machine accounts.

The default settings for NAME_REGEX and SYS_NAME_REGEX allow usernames to contain lowercase letters and numbers, plus dash (-) and underscore (_); the name must begin with a letter (or an underscore for system users).

The least restrictive policy, available by using the --allow-all-names option, simply makes the same checks as useradd(8): cannot start with a dash, plus sign, or tilde; and cannot contain a colon, comma, slash, or whitespace.

This option can be used to create confusing or misleading names; use it with caution.

Please note that regardless of the regular expressions used to evaluate the username, it may be a maximum of 32 bytes; this may be less than 32 visual characters when using Unicode glyphs in the username.
Someone should decide if this is a documentation or error message problem I used env and echo "${NAME_REGEX}" to assure the value did not exist.
I think this is more a misunderstanding on your part as to what is meant by NAME_REGEX having a default value.

If you define NAME_REGEX then whatever value you give it will be used, however if it isn't defined then the default string will be used. That is why the line in /etc/adduser.conf that would otherwise define NAME_REGEX to be the default string is commented out, by not defining it you will implicitly get the default.

Statistics: Posted by Paeryn — Thu Dec 19, 2024 4:34 am



Viewing all articles
Browse latest Browse all 2459

Trending Articles