X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fhostname-setup.c;h=e3ea5fe767f8a8440f0a895087622d153510ea2c;hb=ca5dc4b67dd6956bea663ade032352a58bf163c6;hp=03b5f472a55287ce31c4c547265d5e203f74f94c;hpb=fb3d2b8fec7c705d8027e6967adae0c2a86acf31;p=elogind.git diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c index 03b5f472a..e3ea5fe76 100644 --- a/src/core/hostname-setup.c +++ b/src/core/hostname-setup.c @@ -151,31 +151,20 @@ int hostname_setup(void) { r = read_hostname(&b); if (r < 0) { + hn = NULL; + if (r == -ENOENT) enoent = true; else log_warning("Failed to read configured hostname: %s", strerror(-r)); - - hn = NULL; } else hn = b; - if (!hn) { - /* Don't override the hostname if it is unset and not - * explicitly configured */ - - char *old_hostname = NULL; - - old_hostname = gethostname_malloc(); - if (old_hostname) { - bool already_set; - - already_set = old_hostname[0] != 0; - free(old_hostname); - - if (already_set) - goto finish; - } + if (isempty(hn)) { + /* Don't override the hostname if it is already set + * and not explicitly configured */ + if (hostname_is_set()) + goto finish; if (enoent) log_info("No hostname configured.");