2005-06-15 Dan Williams <dcbw@redhat.com>
Patch from Thom May: * src/backends/NetworkManagerDebian.c - Update debian backend for static IP nameservers git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@670 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -421,7 +421,83 @@ typedef struct DebSystemConfigData
|
||||
} DebSystemConfigData;
|
||||
|
||||
/*
|
||||
* nm_system_device_update_config_info
|
||||
* set_ip4_config_from_resolv_conf
|
||||
*
|
||||
* Add nameservers and search names from a resolv.conf format file.
|
||||
*
|
||||
*/
|
||||
static void set_ip4_config_from_resolv_conf (const char *filename, NMIP4Config *ip4_config)
|
||||
{
|
||||
char * contents = NULL;
|
||||
char ** split_contents = NULL;
|
||||
int i, len;
|
||||
|
||||
g_return_if_fail (filename != NULL);
|
||||
g_return_if_fail (ip4_config != NULL);
|
||||
|
||||
if (!g_file_get_contents (filename, &contents, NULL, NULL) || (contents == NULL))
|
||||
return;
|
||||
|
||||
if (!(split_contents = g_strsplit (contents, "\n", 0)))
|
||||
goto out;
|
||||
|
||||
len = g_strv_length (split_contents);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
char *line = split_contents[i];
|
||||
|
||||
/* Ignore comments */
|
||||
if (!line || (line[0] == ';'))
|
||||
continue;
|
||||
|
||||
line = g_strstrip (line);
|
||||
if ((strncmp (line, "search", 6) == 0) && (strlen (line) > 6))
|
||||
{
|
||||
char *searches = g_strdup (line + 7);
|
||||
char **split_searches = NULL;
|
||||
|
||||
if (!searches || !strlen (searches))
|
||||
continue;
|
||||
|
||||
/* Allow space-separated search domains */
|
||||
if (split_searches == g_strsplit (searches, " ", 0))
|
||||
{
|
||||
int m, srch_len;
|
||||
|
||||
srch_len = g_strv_length (split_searches);
|
||||
for (m = 0; m < srch_len; m++)
|
||||
{
|
||||
if (split_searches[m])
|
||||
nm_ip4_config_add_domain (ip4_config, split_searches[m]);
|
||||
}
|
||||
g_strfreev (split_searches);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Only 1 item, add the whole line */
|
||||
nm_ip4_config_add_domain (ip4_config, searches);
|
||||
}
|
||||
|
||||
g_free (searches);
|
||||
}
|
||||
else if ((strncmp (line, "nameserver", 10) == 0) && (strlen (line) > 10))
|
||||
{
|
||||
guint32 addr = (guint32) (inet_addr (line + 11));
|
||||
|
||||
if (addr != (guint32) -1)
|
||||
nm_ip4_config_add_nameserver (ip4_config, addr);
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (split_contents);
|
||||
|
||||
out:
|
||||
g_free (contents);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_get_system_config
|
||||
*
|
||||
* Retrieve any relevant configuration info for a particular device
|
||||
* from the system network configuration information. Clear out existing
|
||||
@@ -488,6 +564,9 @@ void* nm_system_device_get_system_config (NMDevice *dev)
|
||||
nm_ip4_config_set_broadcast (sys_data->config, broadcast);
|
||||
}
|
||||
|
||||
if (!sys_data->use_dhcp)
|
||||
set_ip4_config_from_resolv_conf (SYSCONFDIR"/resolv.conf", sys_data->config);
|
||||
|
||||
#if 0
|
||||
nm_debug ("------ Config (%s)", nm_device_get_iface (dev));
|
||||
nm_debug (" DHCP=%d\n", use_dhcp);
|
||||
|
Reference in New Issue
Block a user