X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fhostname-setup.c;h=03b0ce3b4dad805d94b2cb7de2afd3c9bb549e89;hp=8aa1cff1d30f23ad1a42826a487a7e8540a11beb;hb=2eec67acbb00593e414549a7e5b35eb7dd776b1b;hpb=e724b0639c43c2821613fc4f7f755f87c49a22e8
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index 8aa1cff1d..03b0ce3b4 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -19,10 +19,8 @@
along with systemd; If not, see .
***/
-#include
#include
#include
-#include
#include
#include "hostname-setup.h"
@@ -64,7 +62,7 @@ int hostname_setup(void) {
if (r == -ENOENT)
enoent = true;
else
- log_warning("Failed to read configured hostname: %s", strerror(-r));
+ log_warning_errno(r, "Failed to read configured hostname: %m");
hn = NULL;
} else
@@ -82,10 +80,8 @@ int hostname_setup(void) {
hn = "localhost";
}
- if (sethostname(hn, strlen(hn)) < 0) {
- log_warning("Failed to set hostname to <%s>: %m", hn);
- return -errno;
- }
+ if (sethostname_idempotent(hn) < 0)
+ return log_warning_errno(errno, "Failed to set hostname to <%s>: %m", hn);
log_info("Set hostname to <%s>.", hn);
return 0;