[Bug 1916325] Re: Overly strict NAME_REGEX rejects valid hostnames
Ryan Harper
1916325 at bugs.launchpad.net
Tue Mar 16 22:34:03 UTC 2021
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.
https://github.com/canonical/subiquity/blob/a76581cd2b973b55e55c6ac05b5bf47168493140/subiquity/ui/views/identity.py#L110
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to subiquity in Ubuntu.
https://bugs.launchpad.net/bugs/1916325
Title:
Overly strict NAME_REGEX rejects valid hostnames
Status in curtin:
New
Status in curtin package in Ubuntu:
New
Status in subiquity package in Ubuntu:
New
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-01.mydomain.co.uk, for example.
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-9_][a-z0-9_-]*" -
i.e. adding 0-9 as valid characters at the start. (I've left the
underscore character in, also)
Thanks
Jonathan
Ref:
https://man7.org/linux/man-pages/man7/hostname.7.html#:~:text=Valid%20characters%20for%20hostnames%20are,to%20an%20address%20for%20use.
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.
To manage notifications about this bug go to:
https://bugs.launchpad.net/curtin/+bug/1916325/+subscriptions
More information about the foundations-bugs
mailing list