Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering committed May 20, 2020
1 parent 6dc155e commit a5e453c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/hostname/hostnamed.c
Expand Up @@ -309,9 +309,15 @@ static int context_update_kernel_hostname(

assert(c);

r = gethostname_strict(&current);
if (r < 0 && r != -ENXIO) /* ignore error if nothing is set yet */
return r;
if (!transient_hostname) {
/* If no transient hostname is passed in, then let's check what is currently set. */

r = gethostname_strict(&current);
if (r < 0 && r != -ENXIO) /* ignore error if nothing is set yet */
return r;

transient_hostname = current;
}

static_hn = c->data[PROP_STATIC_HOSTNAME];

Expand All @@ -324,10 +330,6 @@ static int context_update_kernel_hostname(
else if (!isempty(transient_hostname))
hn = transient_hostname;

/* ... what is already set comes next (note that gethostname_strict() above already filters out a few "unset" syntaxes) ... */
else if (current)
hn = current;

/* ... fallback to static "localhost.*" ignored above ... */
else if (!isempty(static_hn))
hn = static_hn;
Expand Down

0 comments on commit a5e453c

Please sign in to comment.