Hi,
the useradd documentation says that a user name has a 32 character
limit. We should enforce this as well.
In useradd, this seems to apply to the UTF-8 representation of the user
name, that is, aaääääääääääääääää (two unaccented and 16 accented
characters) is too long while aaäääääääääääääää (two unaccented and 15
accented characters) is not. So putting this restriction inside our
regular expressions is not going to help. Maybe it's just ok to let
useradd enforce this? Currently this seems to work ok, but it looks like
a train wreck:
root@salida-unstable-buildd-amd64-ydvv:/srv# adduser --system abcdefghijabcdefghijabcdefghijabc
Adding system user `abcdefghijabcdefghijabcdefghijabc' (UID 101) ...
Adding new user `abcdefghijabcdefghijabcdefghijabc' (UID 101) with group `nogroup' ...
useradd: invalid user name 'abcdefghijabcdefghijabcdefghijabc': use --badname to ignore
adduser: `/usr/sbin/useradd -r -K SYS_UID_MIN=100 -K SYS_UID_MAX=999 -d /home/abcdefghijabcdefghijabcdefghijabc -g nogroup -s /usr/sbin/nologin -u 101 abcdefghijabcdefghijabcdefghijabc' returned error code 3. Exiting.
root@salida-unstable-buildd-amd64-ydvv:/srv# adduser --system abcdefghijabcdefghijabcdefghijab
Adding system user `abcdefghijabcdefghijabcdefghijab' (UID 101) ...
Adding new user `abcdefghijabcdefghijabcdefghijab' (UID 101) with group `nogroup' ...
Creating home directory `/home/abcdefghijabcdefghijabcdefghijab' ...
Greetings
Marc
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.18.8-zgws1 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8), LANGUAGE=en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages adduser depends on:
ii debconf [debconf-2.0] 1.5.79
ii passwd 1:4.11.1+dfsg1-2
adduser recommends no packages.
Versions of packages adduser suggests:
ii cron 3.0pl1-144
ii liblocale-gettext-perl 1.07-4+b2
ii perl 5.34.0-4
-- debconf information excluded
(new patch)
/h/d/adduser $ sudo adduser фффффффффффффффффффффффф
adduser: Usernames must be no more than 32 bytes in length;
note that if you are using Unicode characters, the
character
limit will be less than 32.
In the 3.121, the IEEE check will squash it.
In 3.22:
~/h/d/adduser $ sudo adduser фффффффффффффффффффффффф --allow-all-names
Allowing use of questionable username.
Adding user `фффффффффффффффффффффффф' ...
Adding new group `фффффффффффффффффффффффф' (1023) ...
groupadd: 'фффффффффффффффффффффффф' is not a valid group name
adduser: `/sbin/groupadd -g 1023 фффффффффффффффффффффффф' returned
error code 3. Exiting.
so, not ideal, but it does error.