]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamed: rename FallbackHostname to DefaultHostname 18704/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 20 Feb 2021 17:54:24 +0000 (18:54 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 22 Feb 2021 19:10:55 +0000 (20:10 +0100)
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.

NEWS
man/org.freedesktop.hostname1.xml
src/hostname/hostnamed.c
src/shared/hostname-setup.c
src/shared/hostname-setup.h

diff --git a/NEWS b/NEWS
index 8fc5ce73ff2f0f6e1d6eab21ebdeb7800bb778b0..b917262495e0ee44b1860e7a28cddd526421472c 100644 (file)
--- 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
index 5b5f4fb3a719672f45e30eab7dd582db22bb9178..3a5088ededcf2e6ca617b2bf5414ab74e6a0303e 100644 (file)
@@ -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 {
 
     <variablelist class="dbus-property" generated="True" extra-ref="PrettyHostname"/>
 
-    <variablelist class="dbus-property" generated="True" extra-ref="FallbackHostname"/>
+    <variablelist class="dbus-property" generated="True" extra-ref="DefaultHostname"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="HostnameSource"/>
 
@@ -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.</para>
 
-    <para>The <varname>FallbackHostname</varname> property exposes the fallback hostname (configured at
-    compilation time).</para>
+    <para>The <varname>DefaultHostname</varname> property exposes the default hostname (configured through
+    <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>, or a
+    fallback set at compilation time).</para>
 
     <para>The <varname>HostnameSource</varname> property exposes the origin of the currently configured
     hostname. One of <literal>static</literal> (set from <filename>/etc/hostname</filename>),
     <literal>transient</literal> (a non-permanent hostname from an external source),
-    <literal>fallback</literal> (the compiled-in fallback value).</para>
+    <literal>default</literal> (the value from <filename>os-release</filename> or the the compiled-in
+    fallback).</para>
 
     <para>The <varname>IconName</varname> property exposes the <emphasis>icon name</emphasis> 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 {
       <listitem><para>Limit the hostname to 63 chars, which is the length of a DNS label.</para></listitem>
 
       <listitem><para>If after stripping special chars the empty string is the result, you can pass this
-      as-is to <filename>systemd-hostnamed</filename> in which case it will automatically use
-      <literal>&FALLBACK_HOSTNAME;</literal>.</para></listitem>
+      as-is to <filename>systemd-hostnamed</filename> in which case it will automatically use a suitable
+      fallback.</para></listitem>
 
       <listitem><para>Uppercase charaacters should be replaced with their lowercase equivalents.
       </para></listitem>
index 9937d159f4e271157ff85f7a8c1f2a00cf9d2aeb..2ece8b2fbd9bbf0f8ab697ae45f9f3811bd4b676 100644 (file)
@@ -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),
index 0cc1a268bdfac5b05988d73f6ebcd00612850c5e..511aa7d0313cb40e37cc6c23f5a8a21972fd71f6 100644 (file)
@@ -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);
index 1fa0b6f333a60fd55d4b2145b211e383180bcebe..5ac7241a59fae20f297eef41a8bb26bfe74b94cd 100644 (file)
@@ -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;