hostnamed: rename FallbackHostname to DefaultHostname
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.
This commit is contained in:
@@ -152,13 +152,13 @@ void hostname_update_source_hint(const char *hostname, HostnameSource source) {
|
||||
* notice if somebody sets the hostname directly (not going through hostnamed).
|
||||
*/
|
||||
|
||||
if (source == HOSTNAME_FALLBACK) {
|
||||
r = write_string_file("/run/systemd/fallback-hostname", hostname,
|
||||
if (source == HOSTNAME_DEFAULT) {
|
||||
r = write_string_file("/run/systemd/default-hostname", hostname,
|
||||
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_ATOMIC);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to create \"/run/systemd/fallback-hostname\": %m");
|
||||
log_warning_errno(r, "Failed to create \"/run/systemd/default-hostname\": %m");
|
||||
} else
|
||||
unlink_or_warn("/run/systemd/fallback-hostname");
|
||||
unlink_or_warn("/run/systemd/default-hostname");
|
||||
}
|
||||
|
||||
int hostname_setup(bool really) {
|
||||
@@ -204,13 +204,13 @@ int hostname_setup(bool really) {
|
||||
}
|
||||
|
||||
if (enoent)
|
||||
log_info("No hostname configured, using fallback hostname.");
|
||||
log_info("No hostname configured, using default hostname.");
|
||||
|
||||
hn = b = get_default_hostname();
|
||||
if (!hn)
|
||||
return log_oom();
|
||||
|
||||
source = HOSTNAME_FALLBACK;
|
||||
source = HOSTNAME_DEFAULT;
|
||||
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ int hostname_setup(bool really) {
|
||||
static const char* const hostname_source_table[] = {
|
||||
[HOSTNAME_STATIC] = "static",
|
||||
[HOSTNAME_TRANSIENT] = "transient",
|
||||
[HOSTNAME_FALLBACK] = "fallback",
|
||||
[HOSTNAME_DEFAULT] = "default",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(hostname_source, HostnameSource);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
typedef enum HostnameSource {
|
||||
HOSTNAME_STATIC, /* from /etc/hostname */
|
||||
HOSTNAME_TRANSIENT, /* a transient hostname set through systemd, hostnamed, the container manager, or otherwise */
|
||||
HOSTNAME_FALLBACK, /* the compiled-in fallback was used */
|
||||
HOSTNAME_DEFAULT, /* the os-release default or the compiled-in fallback were used */
|
||||
_HOSTNAME_INVALID = -EINVAL,
|
||||
} HostnameSource;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user