]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: when booting up, initialize hostname to compile-time fallback hostname
authorLennart Poettering <lennart@poettering.net>
Thu, 16 Feb 2017 11:03:39 +0000 (12:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Feb 2017 09:19:26 +0000 (10:19 +0100)
When /etc/hostname isn't set, default to the configured compile-time
fallback hostname instead of "localhost" for the kernel hostname.

src/core/hostname-setup.c

index 68be52856b3f9e5f161cbae6441d4d4b96df34a9..845e31e1c596586c61834717cfa88336ac47e0d6 100644 (file)
 #include "util.h"
 
 int hostname_setup(void) {
-        int r;
         _cleanup_free_ char *b = NULL;
-        const char *hn;
         bool enoent = false;
+        const char *hn;
+        int r;
 
         r = read_hostname_config("/etc/hostname", &b);
         if (r < 0) {
@@ -56,7 +56,7 @@ int hostname_setup(void) {
                 if (enoent)
                         log_info("No hostname configured.");
 
-                hn = "localhost";
+                hn = FALLBACK_HOSTNAME;
         }
 
         r = sethostname_idempotent(hn);