Files
snapd/tests/nested
Michael Vogt ca2e0df0c0 configcore: relax validation rules for hostname
* 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)
2021-12-02 10:41:07 +01:00
..
2021-09-10 17:49:27 -03:00