diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-05-21 17:19:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-05-21 17:19:58 +0200 |
commit | 344de60901f0e3ce0d2f112b7be97fc6d0e2f071 (patch) | |
tree | 37c5d0b7187f93b6d1cba911f8f134ff9fe6ce2f /src/core/hostname-setup.c | |
parent | 97f25a02ee3fd6934eec6341373bb22de09e1ce2 (diff) |
hostname-setup: also consider (ńone) an unset hostname
Diffstat (limited to 'src/core/hostname-setup.c')
-rw-r--r-- | src/core/hostname-setup.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c index 03b5f472a5..e3ea5fe767 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."); |