Commit 5471a6c6 authored by Jiří Klimeš's avatar Jiří Klimeš

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.
parent c1ce1b31
......@@ -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)
/* 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",
g_free (unmanaged);
g_free (keyfile);
......@@ -2127,12 +2127,11 @@ test_read_wired_ipv6_only (void)
/* 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",
/* 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), ==, "");
g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 1), ==, "");
g_assert_cmpstr (nm_setting_ip6_config_get_dns_search (s_ip6, 2), ==, "");
g_free (unmanaged);
g_free (keyfile);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment