chiark / gitweb /
hostname-util: default to the compile time default hostname in gethostname_malloc()
authorLennart Poettering <lennart@poettering.net>
Thu, 16 Feb 2017 11:02:17 +0000 (12:02 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:36 +0000 (17:58 +0200)
Currently, if the hostname is not set gethostname_malloc() defaults to
the "sysname", which is "linux" on Linux. Let's change that to also
honour the compile-time fallback hostname as specified on the configure
command line.

src/basic/hostname-util.c

index 5aebd89e34af753b414391616f6595cf79d17ea5..63329d53b265f15644811616c8701aa66101341b 100644 (file)
@@ -57,7 +57,11 @@ char* gethostname_malloc(void) {
         assert_se(uname(&u) >= 0);
 
         if (isempty(u.nodename) || streq(u.nodename, "(none)"))
         assert_se(uname(&u) >= 0);
 
         if (isempty(u.nodename) || streq(u.nodename, "(none)"))
-                return strdup(u.sysname);
+#if 0 /// elogind has no hostnamed and such nonsense
+                return strdup(FALLBACK_HOSTNAME);
+#else
+                return strdup("localhost");
+#endif // 0
 
         return strdup(u.nodename);
 }
 
         return strdup(u.nodename);
 }