2006-01-27 Robert Love <rml@novell.com>
* src/backends/NetworkManagerSuSE.c: If DHCLIENT_SET_HOSTNAME is set but the DHCP server did not return a hostname, try to look up our name via DNS and set the system hostname to that. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1398 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2006-01-27 Robert Love <rml@novell.com>
|
||||||
|
|
||||||
|
* src/backends/NetworkManagerSuSE.c: If DHCLIENT_SET_HOSTNAME is set
|
||||||
|
but the DHCP server did not return a hostname, try to look up our
|
||||||
|
name via DNS and set the system hostname to that.
|
||||||
|
|
||||||
2006-01-27 Dan Williams <dcbw@redhat.com>
|
2006-01-27 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/backends/NetworkManagerRedHat.c
|
* src/backends/NetworkManagerRedHat.c
|
||||||
|
@@ -1023,6 +1023,8 @@ void nm_system_set_hostname (NMIP4Config *config)
|
|||||||
{
|
{
|
||||||
shvarFile *file;
|
shvarFile *file;
|
||||||
gchar *name, *buf, *hostname = NULL;
|
gchar *name, *buf, *hostname = NULL;
|
||||||
|
struct in_addr temp_addr;
|
||||||
|
struct hostent *host = NULL;
|
||||||
|
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (config != NULL);
|
||||||
|
|
||||||
@@ -1035,10 +1037,26 @@ void nm_system_set_hostname (NMIP4Config *config)
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
goto out_close;
|
goto out_close;
|
||||||
|
|
||||||
if (!strcmp (buf, "yes")) {
|
if (!strcmp (buf, "yes"))
|
||||||
|
{
|
||||||
hostname = nm_ip4_config_get_hostname (config);
|
hostname = nm_ip4_config_get_hostname (config);
|
||||||
if (hostname) {
|
if (!hostname)
|
||||||
nm_info ("Setting hostname to %s\n", hostname);
|
{
|
||||||
|
/* try to get hostname via dns */
|
||||||
|
temp_addr.s_addr = nm_ip4_config_get_address (config);
|
||||||
|
host = gethostbyaddr ((char *) &temp_addr, sizeof (temp_addr), AF_INET);
|
||||||
|
if (host)
|
||||||
|
{
|
||||||
|
hostname = g_strdup (host->h_name);
|
||||||
|
hostname = strtok (hostname, ".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nm_warning ("nm_system_set_hostname(): gethostbyaddr failed, h_errno = %d", h_errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostname)
|
||||||
|
{
|
||||||
|
nm_info ("Setting hostname to '%s'", hostname);
|
||||||
if (sethostname (hostname, strlen (hostname)) < 0)
|
if (sethostname (hostname, strlen (hostname)) < 0)
|
||||||
nm_warning ("Could not set hostname.");
|
nm_warning ("Could not set hostname.");
|
||||||
}
|
}
|
||||||
@@ -1050,4 +1068,3 @@ out_close:
|
|||||||
out_gfree:
|
out_gfree:
|
||||||
g_free (name);
|
g_free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user