useradd becomes stricter on username requirement
Closed this issue · 3 comments
During testing, I had problems using usernames like "userFromEnv" with the Alpine images:
useradd: invalid user name 'userFromEnv'
Looks like useradd
in Alpine are actually enforcing what is written in the man page:
Usernames must start with a lower case letter or an underscore, followed by lower case letters, digits, underscores, or dashes. They can end with a dollar sign. In regular expression terms: [a-z_][a-z0-9_-]*[$]?
This was not a problem in Debian. The man page starts with "It is usually recommended to only use usernames that ..." instead of "Usernames must ...".
This applies to alpine 3.6+ (useradd 4.2.1-r8), but not 3.5 (useradd 4.2.1-r11). Somewhere in-between those versions, a stricter username requirement was applied.
Earlier, I made a breaking change by forcing strict usernames, and that was not well received. I'm not sure what do to about this. The POSIX standard allows both lower and upper case. Maybe I have to use adduser
instead of useradd
.
I ran into this problem today and it took a few minutes of trial and error to figure out why the Docker container would not start.
[/usr/local/bin/create-sftp-user] Parsing user data: "MyUserNameHere:MyPasswordHere:1000:1000:builds"
useradd: invalid user name 'MyUserNameHere'
/usr/local/bin/create-sftp-user: Error on line 68: useradd "${useraddOptions[@]}" "$user"
/entrypoint: Error on line 60: create-sftp-user "$user"
It would be nice to see a more helpful error message when this happens. It should say something like "Usernames must be lowercase".
Thanks, good to see that this has become an option (shadow-maint/shadow@a2cd3e9)
It became available in Debian Bullseye, so I finally upgraded as well to make use of it.