mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 02:40:17 +01:00
ifcfg-rh: if IPv4 is disabled put DNS domains (DOMAIN) into IPv6 (rh #1004866)
The problem is that there is only a single variable in ifcfg file holding dns domains - DOMAIN. Thus NetworkManager writes both IPv4 and IPv6 dns-search into it. While reading there is no way to distinguish between IPv4 and IPv6 values, so the DOMAIN value is read and only put into IPv4 dns-search. But, when IPv4 is disabled or invalid, the domains got lost. So in such case we put DOMAIN variable into IPv6 instead. https://bugzilla.redhat.com/show_bug.cgi?id=1004866
This commit is contained in:
parent
c1ce1b3185
commit
5471a6c678
2 changed files with 43 additions and 7 deletions
|
|
@ -4449,6 +4449,35 @@ uuid_from_file (const char *filename)
|
|||
return uuid;
|
||||
}
|
||||
|
||||
static void
|
||||
check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6)
|
||||
{
|
||||
if (!s_ip6)
|
||||
return;
|
||||
|
||||
/* If there is no IPv4 config or it doesn't contain DNS searches,
|
||||
* read DOMAIN and put the domains into IPv6.
|
||||
*/
|
||||
if (!s_ip4 || nm_setting_ip4_config_get_num_dns_searches (NM_SETTING_IP4_CONFIG (s_ip4)) == 0) {
|
||||
/* DNS searches */
|
||||
char *value = svGetValue (ifcfg, "DOMAIN", FALSE);
|
||||
if (value) {
|
||||
char **searches = g_strsplit (value, " ", 0);
|
||||
if (searches) {
|
||||
char **item;
|
||||
for (item = searches; *item; item++) {
|
||||
if (strlen (*item)) {
|
||||
if (!nm_setting_ip6_config_add_dns_search (NM_SETTING_IP6_CONFIG (s_ip6), *item))
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate DNS domain '%s'", *item);
|
||||
}
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
g_free (value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NMConnection *
|
||||
connection_from_file (const char *filename,
|
||||
const char *network_file, /* for unit tests only */
|
||||
|
|
@ -4614,6 +4643,7 @@ connection_from_file (const char *filename,
|
|||
} else if (utils_ignore_ip_config (connection)) {
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP6 configuration");
|
||||
g_object_unref (s_ip6);
|
||||
s_ip6 = NULL;
|
||||
} else {
|
||||
const char *method;
|
||||
|
||||
|
|
@ -4631,9 +4661,16 @@ connection_from_file (const char *filename,
|
|||
} else if (s_ip4 && utils_ignore_ip_config (connection)) {
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP4 configuration");
|
||||
g_object_unref (s_ip4);
|
||||
s_ip4 = NULL;
|
||||
} else if (s_ip4)
|
||||
nm_connection_add_setting (connection, s_ip4);
|
||||
|
||||
/* There is only one DOMAIN variable and it is read and put to IPv4 config
|
||||
* But if IPv4 is disabled or the config fails for some reason, we read
|
||||
* DOMAIN and put the values into IPv6 config instead.
|
||||
*/
|
||||
check_dns_search_domains (parsed, s_ip4, s_ip6);
|
||||
|
||||
/* Bridge port? */
|
||||
s_port = make_bridge_port_setting (parsed);
|
||||
if (s_port)
|
||||
|
|
|
|||
|
|
@ -1974,7 +1974,7 @@ test_read_wired_ipv6_manual (void)
|
|||
"wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
|
||||
TEST_IFCFG_WIRED_IPV6_MANUAL,
|
||||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP6_CONFIG_DNS);
|
||||
NM_SETTING_IP6_CONFIG_DNS_SEARCH);
|
||||
|
||||
g_free (unmanaged);
|
||||
g_free (keyfile);
|
||||
|
|
@ -2127,12 +2127,11 @@ test_read_wired_ipv6_only (void)
|
|||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP6_CONFIG_DNS);
|
||||
|
||||
/* DNS domains - none as domains are stuffed to 'ipv4' setting */
|
||||
ASSERT (nm_setting_ip6_config_get_num_dns_searches (s_ip6) == 0,
|
||||
"wired-ipv6-only-verify-ip6", "failed to verify %s: unexpected %s / %s key value",
|
||||
TEST_IFCFG_WIRED_IPV6_MANUAL,
|
||||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP6_CONFIG_DNS);
|
||||
/* DNS domains should be in IPv6, because IPv4 is disabled */
|
||||
g_assert_cmpint (nm_setting_ip6_config_get_num_dns_searches (s_ip6), ==, 3);
|
||||
g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 0), ==, "lorem.com");
|
||||
g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 1), ==, "ipsum.org");
|
||||
g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 2), ==, "dolor.edu");
|
||||
|
||||
g_free (unmanaged);
|
||||
g_free (keyfile);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue