util: introduce sethostname_idempotent
Function queries system hostname and applies changes only when necessary. Also, migrate all client of sethostname to sethostname_idempotent while at it.
This commit is contained in:
@@ -82,7 +82,7 @@ int hostname_setup(void) {
|
||||
hn = "localhost";
|
||||
}
|
||||
|
||||
if (sethostname(hn, strlen(hn)) < 0) {
|
||||
if (sethostname_idempotent(hn) < 0) {
|
||||
log_warning("Failed to set hostname to <%s>: %m", hn);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user