View | Details | Raw Unified | Return to bug 144324
Collapse All | Expand All

(-)a/src/backends/NetworkManagerSuSE.c (-3 / +21 lines)
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 = NULL;
1026
1028
1027
	g_return_if_fail (config != NULL);
1029
	g_return_if_fail (config != NULL);
1028
1030
Lines 1035-1044 Link Here
1035
	if (!buf)
1037
	if (!buf)
1036
		goto out_close;
1038
		goto out_close;
1037
1039
1038
	if (!strcmp (buf, "yes")) {
1040
	if (!strcmp (buf, "yes")) 
1041
	{
1039
		hostname = nm_ip4_config_get_hostname (config);
1042
		hostname = nm_ip4_config_get_hostname (config);
1040
		if (hostname) {
1043
		if (!hostname)
1041
			nm_info ("Setting hostname to %s\n", hostname);
1044
		{
1045
			/* try to get hostname via dns */
1046
			temp_addr.s_addr = nm_ip4_config_get_address (config);
1047
			if ((host = gethostbyaddr ((char *)&temp_addr, sizeof (temp_addr), AF_INET)) == NULL)
1048
			{
1049
				nm_warning ("nm_system_set_hostname: gethostbyaddr failed, h_errno = %d", h_errno);
1050
			} 
1051
			else
1052
			{
1053
				hostname = g_strdup (host->h_name);
1054
				hostname = strtok (hostname, ".");	
1055
			}
1056
		}
1057
		if (hostname)
1058
		{
1059
			nm_info ("Setting hostname to '%s'", hostname);
1042
			if (sethostname (hostname, strlen (hostname)) < 0)
1060
			if (sethostname (hostname, strlen (hostname)) < 0)
1043
				nm_warning ("Could not set hostname.");
1061
				nm_warning ("Could not set hostname.");
1044
		}
1062
		}

Return to bug 144324