summaryrefslogtreecommitdiffstats
path: root/src/shared/hostname-setup.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* hostname: introduce gethostname_full() and use it in various gethostname() ↵Yu Watanabe2021-08-121-1/+0
| | | | variants
* hostnamed: rename FallbackHostname to DefaultHostnameZbigniew Jędrzejewski-Szmek2021-02-221-1/+1
| | | | | | | | | This follows the addition of DEFAULT_HOSTNAME= in os-release. The distinction between the value from os-release or the env var and the compile-time setting is not made in the api: HostnameSource is "default" is all cases. I think that this level of detail is not needed, because the users of this mostly care whether the hostname was set by user configuration or not.
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* hostnamectl: show hint when user try to set transient hostname but static ↵Yu Watanabe2021-02-091-1/+3
| | | | hostname is already used
* hostnamed,shared/hostname-setup: expose the origin of the current hostnameZbigniew Jędrzejewski-Szmek2020-12-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In hostnamed this is exposed as a dbus property, and in the logs in both places. This is of interest to network management software and such: if the fallback hostname is used, it's not as useful as the real configured thing. Right now various programs try to guess the source of hostname by looking at the string. E.g. "localhost" is assumed to be not the real hostname, but "fedora" is. Any such attempts are bound to fail, because we cannot distinguish "fedora" (a fallback value set by a distro), from "fedora" (received from reverse dns), from "fedora" read from /etc/hostname. /run/systemd/fallback-hostname is written with the fallback hostname when either pid1 or hostnamed sets the kernel hostname to the fallback value. Why remember the fallback value and not the transient hostname in /run/hostname instead? We have three hostname types: "static", "transient", fallback". – Distinguishing "static" is easy: the hostname that is set matches what is in /etc/hostname. – Distingiushing "transient" and "fallback" is not easy. And the "transient" hostname may be set outside of pid1+hostnamed. In particular, it may be set by container manager, some non-systemd tool in the initramfs, or even by a direct call. All those mechanisms count as "transient". Trying to get those cases to write /run/hostname is futile. It is much easier to isolate the "fallback" case which is mostly under our control. And since the file is only used as a flag to mark the hostname as fallback, it can be hidden inside of our /run/systemd directory. For https://bugzilla.redhat.com/show_bug.cgi?id=1892235.
* shared/hostname-setup: add mode where we check what would be set, without doingZbigniew Jędrzejewski-Szmek2020-12-161-1/+2
| | | | This allows the 'unsafe' mark to be removed from the test.
* Move hostname setup logic to new shared/hostname-setup.[ch]Zbigniew Jędrzejewski-Szmek2020-12-161-0/+13
| | | | | | | | | | No functional change, just moving a bunch of things around. Before we needed a rather complicated setup to test hostname_setup(), because the code was in src/core/. When things are moved to src/shared/ we can just test it as any function. The test is still "unsafe" because hostname_setup() may modify the hostname.
* hostname-setup: move to core/Lennart Poettering2012-04-121-27/+0
|
* move more common files to shared/ and add them to shared.laKay Sievers2012-04-121-0/+27