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:
Michal Sekletar
2014-10-27 10:37:46 +01:00
parent caa2f4c0c9
commit 605f81a896
5 changed files with 25 additions and 3 deletions
+1 -1
View File
@@ -1289,7 +1289,7 @@ static int setup_hostname(void) {
if (arg_share_system)
return 0;
if (sethostname(arg_machine, strlen(arg_machine)) < 0)
if (sethostname_idempotent(arg_machine) < 0)
return -errno;
return 0;