and this tool distinguish three different hostnames: the high-level "pretty" hostname which might include
all kinds of special characters (e.g. "Lennart's Laptop"), the "static" hostname which is the
user-configured hostname (e.g. "lennarts-laptop"), and the transient hostname which is a fallback value
- received from network configuration (e.g. "node12345678"). If a static hostname is set, and is valid
- (something other than localhost), then the transient hostname is not used.</para>
+ received from network configuration (e.g. "node12345678"). If a static hostname is set to a valid value,
+ then the transient hostname is not used.</para>
<para>Note that the pretty hostname has little restrictions on the characters and length used, while the static and
transient hostnames are limited to the usually accepted characters of Internet domain names, and 64 characters at
return strdup("computer");
}
-static bool hostname_is_useful(const char *hn) {
- return !isempty(hn) && !is_localhost(hn);
-}
-
static int context_update_kernel_hostname(
Context *c,
const char *transient_hn) {
- const char *static_hn, *hn;
+ const char *hn;
struct utsname u;
int r;
isempty(u.nodename) || streq(u.nodename, "(none)") ? NULL : u.nodename;
}
- static_hn = c->data[PROP_STATIC_HOSTNAME];
-
- /* /etc/hostname with something other than "localhost"
- * has the highest preference ... */
- if (hostname_is_useful(static_hn))
- hn = static_hn;
+ /* /etc/hostname has the highest preference ... */
+ if (c->data[PROP_STATIC_HOSTNAME])
+ hn = c->data[PROP_STATIC_HOSTNAME];
/* ... the transient hostname, (ie: DHCP) comes next ... */
else if (!isempty(transient_hn))
hn = transient_hn;
- /* ... fallback to static "localhost.*" ignored above ... */
- else if (!isempty(static_hn))
- hn = static_hn;
-
/* ... and the ultimate fallback */
else
hn = FALLBACK_HOSTNAME;