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

useradd suggests --badname when it won't help (username too long) #584

Open
orlitzky opened this issue Oct 11, 2022 · 8 comments
Open

useradd suggests --badname when it won't help (username too long) #584

orlitzky opened this issue Oct 11, 2022 · 8 comments

Comments

@orlitzky
Copy link

$ useradd --badname -d "/home/2022.txindependencehealthplan.com" -m "2022.txindependencehealthplan.com"
useradd: invalid user name '2022.txindependencehealthplan.com': use --badname to ignore
@hallyn
Copy link
Member

hallyn commented Oct 11, 2022

The length check (< 32 characters) is still enforced. If you drop 3 chars from the username, does it then proceed?

@orlitzky
Copy link
Author

Yes, but that's the wrong username :)

@orlitzky
Copy link
Author

Oh. I was thinking this was a regression from when --badnames had an "s" on it, but looking back at my notes, the --badnames was used only to allow the username to begin with a "2". The length was still a problem that I had to hack around in /etc/passwd, /etc/group, and /etc/shadow last year.

For something constructive... I suppose useradd shouldn't tell me to use --badname if it won't help?

@hallyn
Copy link
Member

hallyn commented Oct 11, 2022

Oh. I was thinking this was a regression from when --badnames had an "s" on it, but looking back at my notes, the --badnames was used only to allow the username to begin with a "2". The length was still a problem that I had to hack around in /etc/passwd, /etc/group, and /etc/shadow last year.

For something constructive... I suppose useradd shouldn't tell me to use --badname if it won't help?

Indeed, that's an unfortunate mis-direction.

@orlitzky orlitzky changed the title useradd --badname doesn't work? useradd suggests --badname when it won't help (username too long) Oct 11, 2022
@orlitzky
Copy link
Author

orlitzky commented May 5, 2024

I'm not sure if I changed something or if you changed something, but I noticed today that...

# useradd awsdlkfjawklegfhjskdjhfgsjkidfhgjksdkasdjhflasjdhgkjsdhfgklshdfkghdf

apparently works fine:

# tail -n1 /etc/passwd
awsdlkfjawklegfhjskdjhfgsjkidfhgjksdkasdjhflasjdhgkjsdhfgklshdfkghdf:x:1001:1001::/home/awsdlkfjawklegfhjskdjhfgsjkidfhgjksdkasdjhflasjdhgkjsdhfgklshdfkghdf:/bin/bash

(this is with shadow-4.14.2 on Gentoo). If the length limit is gone, then this issue is resolved.

@ikerexxe
Copy link
Collaborator

ikerexxe commented May 6, 2024

The username length limit has been moved to 256 to align with the kernel limit.

@orlitzky
Copy link
Author

orlitzky commented May 6, 2024

Thanks, I see it now in lib/chkname.c. Should https://github.com/shadow-maint/shadow/blob/master/man/useradd.8.xml#L730 be updated?

While you have to try a lot harder (at least on linux), I guess this suggestion is still misleading:

seradd: invalid user name 'wdfhaslkdghaskldhjklsadhgkljshdfkljghsdklfhgjksdhfgjklhsdlfkghskldfhgkljsdhfgklhsdklfghklsdfhgklshdfklghsdklfhgklshdfklghsdklfhgklsdhfgklhsdeklfjghsdklfhgklsdhfgkljhsdklfjghskldfhgksdhfgklhsdlkfghsdklfhglksdhfgklhsdfghoerhowthpqw39oejdgfneongfweuprhgwu9efnjgvpfuioehgnwerujghnweuiognweurgnwpeorngwernhwpernhpwernvpenwrpgnweprnhwwegnwonvcweiorngoe': use --badname to ignore

@ikerexxe
Copy link
Collaborator

ikerexxe commented May 7, 2024

Opened #986 to update it

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

3 participants