mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
* configcore: relax validation rules for hostname The strict hostname validation rules in combination with the fact that we now use the external configuration is broken. If the hostname can be set externally via the hostnamectl command we cannot have a validaton that is stricter then what hostnamectl is doing. This PR changes two things: 1. Only validate the hostname if it's set to in FSOnly apply mode, i.e. when no hostnamectl call is issued [1]. 2. Directly pass the hostname to hostnamectl and let it handle invalid names. It has a concept of "static" and "pretty" hostname and will apply even invalid hostnames as "pretty" hostnames. However it will simplify/filter the pretty hostname so that it becomes a valid static hostname. Because of this our logic to detect if the hostname has changed needs to be tweaked to talk to hostnamectl instead of using the "hostname" command that only gets the "static" hostname view. This should fix the issues around hostname setting. [1] https://github.com/systemd/systemd/blob/main/src/basic/hostname-util.c#L85 * conficore: improve comment * configcore: add more tests * tests: update spread tests for new and more flexible hostname handling * configcore: fix typo (thanks to Miguel)