diff --git a/NEWS b/NEWS index 8fc5ce73ff2..b917262495e 100644 --- a/NEWS +++ b/NEWS @@ -184,8 +184,8 @@ CHANGES WITH 248: ignored. The goal is to honour configuration as specified by the user. - * systemd-hostnamed now exports the fallback hostname and the source of - the configured hostname ("static", "transient", or "fallback") as + * systemd-hostnamed now exports the default hostname and the source of + the configured hostname ("static", "transient", or "default") as D-Bus properties. * systemd-hostnamed now exports the HardwareVendor and HardwareModel diff --git a/man/org.freedesktop.hostname1.xml b/man/org.freedesktop.hostname1.xml index 5b5f4fb3a71..3a5088ededc 100644 --- a/man/org.freedesktop.hostname1.xml +++ b/man/org.freedesktop.hostname1.xml @@ -63,7 +63,7 @@ node /org/freedesktop/hostname1 { readonly s StaticHostname = '...'; readonly s PrettyHostname = '...'; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") - readonly s FallbackHostname = '...'; + readonly s DefaultHostname = '...'; readonly s HostnameSource = '...'; readonly s IconName = '...'; readonly s Chassis = '...'; @@ -124,7 +124,7 @@ node /org/freedesktop/hostname1 { - + @@ -183,13 +183,15 @@ node /org/freedesktop/hostname1 { set this setting will be the empty string. Applications should then find a suitable fallback, such as the dynamic hostname. - The FallbackHostname property exposes the fallback hostname (configured at - compilation time). + The DefaultHostname property exposes the default hostname (configured through + os-release5, or a + fallback set at compilation time). The HostnameSource property exposes the origin of the currently configured hostname. One of static (set from /etc/hostname), transient (a non-permanent hostname from an external source), - fallback (the compiled-in fallback value). + default (the value from os-release or the the compiled-in + fallback). The IconName property exposes the icon name following the XDG icon naming spec. If not set, information such as the chassis type (see below) is used to find a @@ -332,8 +334,8 @@ node /org/freedesktop/hostname1 { Limit the hostname to 63 chars, which is the length of a DNS label. If after stripping special chars the empty string is the result, you can pass this - as-is to systemd-hostnamed in which case it will automatically use - &FALLBACK_HOSTNAME;. + as-is to systemd-hostnamed in which case it will automatically use a suitable + fallback. Uppercase charaacters should be replaced with their lowercase equivalents. diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 9937d159f4e..2ece8b2fbd9 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -345,7 +345,7 @@ static int context_update_kernel_hostname( if (!hn) return log_oom(); - hns = HOSTNAME_FALLBACK; + hns = HOSTNAME_DEFAULT; } r = sethostname_idempotent(hn); @@ -539,7 +539,7 @@ static int property_get_static_hostname( return sd_bus_message_append(reply, "s", c->data[PROP_STATIC_HOSTNAME]); } -static int property_get_fallback_hostname( +static int property_get_default_hostname( sd_bus *bus, const char *path, const char *interface, @@ -581,16 +581,16 @@ static int property_get_hostname_source( else { /* If the hostname was not set by us, try to figure out where it came from. If we set - * it to the fallback hostname, the file will tell us. We compare the string because + * it to the default hostname, the file will tell us. We compare the string because * it is possible that the hostname was set by an older version that had a different * fallback, in the initramfs or before we reexecuted. */ - r = read_one_line_file("/run/systemd/fallback-hostname", &fallback); + r = read_one_line_file("/run/systemd/default-hostname", &fallback); if (r < 0 && r != -ENOENT) - log_warning_errno(r, "Failed to read /run/systemd/fallback-hostname, ignoring: %m"); + log_warning_errno(r, "Failed to read /run/systemd/default-hostname, ignoring: %m"); if (streq_ptr(fallback, hostname)) - c->hostname_source = HOSTNAME_FALLBACK; + c->hostname_source = HOSTNAME_DEFAULT; else c->hostname_source = HOSTNAME_TRANSIENT; } @@ -988,7 +988,7 @@ static const sd_bus_vtable hostname_vtable[] = { SD_BUS_PROPERTY("Hostname", "s", property_get_hostname, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("StaticHostname", "s", property_get_static_hostname, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("PrettyHostname", "s", property_get_machine_info_field, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), - SD_BUS_PROPERTY("FallbackHostname", "s", property_get_fallback_hostname, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("DefaultHostname", "s", property_get_default_hostname, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HostnameSource", "s", property_get_hostname_source, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("IconName", "s", property_get_icon_name, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), diff --git a/src/shared/hostname-setup.c b/src/shared/hostname-setup.c index 0cc1a268bdf..511aa7d0313 100644 --- a/src/shared/hostname-setup.c +++ b/src/shared/hostname-setup.c @@ -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); diff --git a/src/shared/hostname-setup.h b/src/shared/hostname-setup.h index 1fa0b6f333a..5ac7241a59f 100644 --- a/src/shared/hostname-setup.h +++ b/src/shared/hostname-setup.h @@ -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;