Overly strict NAME_REGEX rejects valid hostnames

Bug #1916325 reported by Jonathan Hunter on 2021-02-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
curtin (Ubuntu)

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)



       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 post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers