|
Lines 1023-1028
Link Here
|
| 1023 |
{ |
1023 |
{ |
| 1024 |
shvarFile *file; |
1024 |
shvarFile *file; |
| 1025 |
gchar *name, *buf, *hostname = NULL; |
1025 |
gchar *name, *buf, *hostname = NULL; |
|
|
1026 |
struct in_addr temp_addr; |
| 1027 |
struct hostent *host; |
| 1026 |
|
1028 |
|
| 1027 |
g_return_if_fail (config != NULL); |
1029 |
g_return_if_fail (config != NULL); |
| 1028 |
|
1030 |
|
|
Lines 1037-1044
Link Here
|
| 1037 |
|
1039 |
|
| 1038 |
if (!strcmp (buf, "yes")) { |
1040 |
if (!strcmp (buf, "yes")) { |
| 1039 |
hostname = nm_ip4_config_get_hostname (config); |
1041 |
hostname = nm_ip4_config_get_hostname (config); |
| 1040 |
if (hostname) { |
1042 |
if (!hostname) { |
| 1041 |
nm_info ("Setting hostname to %s\n", hostname); |
1043 |
/* try to get hostname via dns */ |
|
|
1044 |
temp_addr.s_addr = nm_ip4_config_get_address(config); |
| 1045 |
if ( (host = gethostbyaddr((char *)&temp_addr, sizeof(temp_addr), AF_INET)) == NULL ) { |
| 1046 |
nm_warning( "nm_system_set_hostname: gethostbyaddr failed, h_errno = %d", h_errno); |
| 1047 |
} |
| 1048 |
else { |
| 1049 |
hostname = g_strdup(host->h_name); |
| 1050 |
hostname = strtok(hostname, "."); |
| 1051 |
} |
| 1052 |
} |
| 1053 |
if (hostname) |
| 1054 |
{ |
| 1055 |
nm_info ("Setting hostname to '%s'", hostname); |
| 1042 |
if (sethostname (hostname, strlen (hostname)) < 0) |
1056 |
if (sethostname (hostname, strlen (hostname)) < 0) |
| 1043 |
nm_warning ("Could not set hostname."); |
1057 |
nm_warning ("Could not set hostname."); |
| 1044 |
} |
1058 |
} |