Check return value of sethostname(2)

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4082 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-09-19 17:40:48 +00:00
parent 3a0b1d645b
commit ba2ad655de

View file

@ -360,7 +360,11 @@ set_system_hostname (const char *new_hostname, const char *msg)
if (!update_etc_hosts (name)) {
/* error updating /etc/hosts; fallback to localhost.localdomain */
nm_info ("Setting system hostname to '" FALLBACK_HOSTNAME "' (error updating /etc/hosts)");
sethostname (FALLBACK_HOSTNAME, strlen (FALLBACK_HOSTNAME));
ret = sethostname (FALLBACK_HOSTNAME, strlen (FALLBACK_HOSTNAME));
if (ret != 0) {
nm_warning ("%s: couldn't set the fallback system hostname (%s): (%d) %s",
__func__, FALLBACK_HOSTNAME, errno, strerror (errno));
}
}
} else {
nm_warning ("%s: couldn't set the system hostname to '%s': (%d) %s",