Overly strict NAME_REGEX rejects valid hostnames
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
curtin |
Invalid
|
Undecided
|
Unassigned | ||
curtin (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
subiquity (Ubuntu) |
Fix Released
|
Undecided
|
Jonathan Hunter |
Bug Description
All our servers' hostnames start with a location identifier, which is mostly numeric e.g. 123, 124 or sometimes 12A. A full hostname might be 12a-proxy-
We are switching to Ubuntu but have hit this bug in the 20.04 curtin installer, which prevents us setting the hostname during installation. (Tested on plain 20.04 and on 20.04.02)
Our workaround has been to set a dummy hostname on installation, and then change it back once curtin has finished - but that gets messy especially as we are now looking into cloud-init and automation, where this won't work.
The NAME_REGEX quoted by curtin is "[a-z_][a-z0-9_-]*" which correctly prevents hostnames starting with a hyphen.. but it also prevents otherwise perfectly valid hostnames that start with a number. (Interestingly, an underscore is not defined as a valid hostname character, but is included as valid in the regex above)
I believe the correct NAME_REGEX would be "[a-z0-
Thanks
Jonathan
Ref:
https:/
Each element of the hostname must be from 1 to 63 characters long
and the entire hostname, including the dots, can be at most 253
characters long. Valid characters for hostnames are ASCII(7)
letters from a to z, the digits from 0 to 9, and the hyphen (-).
A hostname may not start with a hyphen.
Changed in subiquity (Ubuntu): | |
assignee: | nobody → Jonathan Hunter (jmhunter) |
status: | New → Fix Committed |
Changed in curtin (Ubuntu): | |
status: | New → Invalid |
Changed in curtin: | |
status: | New → Invalid |
Changed in subiquity (Ubuntu): | |
status: | Fix Committed → Fix Released |
Hi,
Thank you for filing a bug and helping make Ubuntu better. I believe the regex restriction is happening in the Ubuntu Server Live Installer (subiquity). I've added that package to this bug.
Here's the source code in question you're hitting. /github. com/canonical/ subiquity/ blob/a76581cd2b 973b55e55c6ac05 b5bf47168493140 /subiquity/ ui/views/ identity. py#L110
https:/