Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some systems have stricter regex for valid usernames #62

Open
mesov opened this issue Mar 3, 2024 · 8 comments
Open

Some systems have stricter regex for valid usernames #62

mesov opened this issue Mar 3, 2024 · 8 comments

Comments

@mesov
Copy link

mesov commented Mar 3, 2024

On Debian and Ubuntu, uppercase letters and the dot symbol '.' are not valid User Name characters. So in some cases the User Name will pass the check but user creation will still fail.

user-admin/src/user-admin.c

Lines 290 to 295 in 094986c

if (! ((*c >= 'a' && *c <= 'z') ||
(*c >= 'A' && *c <= 'Z') ||
(*c >= '0' && *c <= '9') ||
(*c == '_') || (*c == '.') ||
(*c == '-' && c != UserName)))
valid = FALSE;

In Ubuntu 22.04 /etc/adduser.conf has #NAME_REGEX="^[a-z][-a-z0-9_]*\$"

@mesov mesov changed the title Some systems have stricter regexp for valid usernames Some systems have stricter regex for valid usernames Mar 3, 2024
@zhuyaliang
Copy link
Owner

zhuyaliang commented Mar 5, 2024

Please run usermod -l Test -- Test on Debian and Ubuntu and output the results of the run

@mesov
Copy link
Author

mesov commented Mar 7, 2024

Please run usermod -l Test -- Test on Debian and Ubuntu and output the results of the run

On Ubuntu 22.04, after adding a user with User Name "test" and Full Name "Test" I am getting usermod: user 'Test' does not exist. I have no Debian system at hand at the moment.

If I try to add a user "Test"/"Test" instead of "test"/"Test" I am getting this error message and no user is added:
running '/usr/sbin/adduser' failed: Child process exited with code 1

@zhuyaliang
Copy link
Owner

I don't have Debian and Ubuntu on hand, so I can't verify this issue at the moment. Accountsservice uses /usr/sbin/useradd to create users. usermod - l can detect whether the user name is legal.
Please try using useradd - m TestUser to verify if the user name can include uppercase letters. If the problem persists, I will install a virtual machine to fix it

@mesov
Copy link
Author

mesov commented Mar 8, 2024

I can now confirm that the behavior is the same on Debian 12 and Ubuntu 22.04: they both seem to be calling adduser instead of useradd, applying the stricter regex mentioned above that rejects uppercase letters, and throwing the error message.

Running useradd -m TestUser works on both: "TestUser" user is added, no error message, uppercase letters accepted.

@mesov
Copy link
Author

mesov commented Mar 8, 2024

This Debian patch may explain why accountsservice calls adduser instead of useradd on Debian 12 and Ubuntu 22.04:

https://sources.debian.org/patches/accountsservice/22.08.8-6/0002-create-and-manage-groups-like-on-a-debian-system.patch/

@zhuyaliang
Copy link
Owner

Thank you for your detailed explanation. I will try to fix this issue

@mesov
Copy link
Author

mesov commented Mar 11, 2024

Thank you for your prompt replies.

A patch to the Debian package has now been suggested, since the problem was created by a Debian modification to accountsservice: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065773.

@mesov
Copy link
Author

mesov commented Mar 15, 2024

I came up with some tentative suggestions to fix the issue, but maybe someone with Debian packaging skills could help with a downstream patch. Is @N0rbert is still around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants