summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-01 14:00:01 +0200
committerThomas Haller <thaller@redhat.com>2015-10-05 17:12:50 +0200
commitda0ded49279cce454c9aefeccd6943e7d58f3475 (patch)
tree21f9f49dab41d634e493c44ac2b96acab5625a42
parent7182304684250a8b52664f6bee34747a05e41bd5 (diff)
downloadNetworkManager-da0ded49279cce454c9aefeccd6943e7d58f3475.tar.gz
config: drop global-dns.enable option in favor of .config.enable
No longer support disabling the global-dns configuration via the "enable" option. Instead, the user can put the entire dns-configuration in one separate snippet, and disable it altogether with ".config.enable".
-rw-r--r--man/NetworkManager.conf.xml.in8
-rw-r--r--src/nm-config-data.c2
-rw-r--r--src/nm-config.c32
-rw-r--r--src/nm-config.h3
-rw-r--r--src/tests/config/Makefile.am1
-rw-r--r--src/tests/config/global-dns-disabled.conf8
-rw-r--r--src/tests/config/global-dns-invalid.conf1
-rw-r--r--src/tests/config/test-config.c7
8 files changed, 32 insertions, 30 deletions
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index 0fccc84dc6..f7bcd1a359 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -643,14 +643,6 @@ ipv6.ip6-privacy=1
<para>
<variablelist>
<varlistentry>
- <term><varname>enable</varname></term>
- <listitem>
- <para>
- Whether the global DNS configuration should be used.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
<term><varname>searches</varname></term>
<listitem>
<para>
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index a9b9891e46..66b1da5916 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -731,7 +731,7 @@ load_global_dns (GKeyFile *keyfile, gboolean internal)
: NM_CONFIG_KEYFILE_GROUPPREFIX_GLOBAL_DNS_DOMAIN;
domain_prefix_len = strlen (domain_prefix);
- if (!keyfile || !nm_config_keyfile_get_boolean (keyfile, group, NM_CONFIG_KEYFILE_KEY_GLOBAL_DNS_ENABLE, FALSE))
+ if (!nm_config_keyfile_has_global_dns_config (keyfile, internal))
return NULL;
conf = g_malloc0 (sizeof (NMGlobalDnsConfig));
diff --git a/src/nm-config.c b/src/nm-config.c
index f8c4ee817d..f070ff9756 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -1066,6 +1066,34 @@ _keyfile_serialize_section (GKeyFile *keyfile, const char *group)
return g_string_free (str, FALSE);
}
+gboolean
+nm_config_keyfile_has_global_dns_config (GKeyFile *keyfile, gboolean internal)
+{
+ gs_strfreev char **groups = NULL;
+ guint g;
+ const char *prefix;
+
+ if (!keyfile)
+ return FALSE;
+ if (g_key_file_has_group (keyfile,
+ internal
+ ? NM_CONFIG_KEYFILE_GROUP_GLOBAL_DNS
+ : NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS))
+ return TRUE;
+
+ groups = g_key_file_get_groups (keyfile, NULL);
+ if (!groups)
+ return FALSE;
+
+ prefix = internal ? NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN : NM_CONFIG_KEYFILE_GROUPPREFIX_GLOBAL_DNS_DOMAIN;
+
+ for (g = 0; groups[g]; g++) {
+ if (g_str_has_prefix (groups[g], prefix))
+ return TRUE;
+ }
+ return FALSE;
+}
+
/**
* intern_config_read:
* @filename: the filename where to store the internal config
@@ -1219,7 +1247,7 @@ out:
* deletion of options from user configuration may cause the
* internal options to appear again.
*/
- if (nm_config_keyfile_get_boolean (keyfile_conf, NM_CONFIG_KEYFILE_GROUP_GLOBAL_DNS, NM_CONFIG_KEYFILE_KEY_GLOBAL_DNS_ENABLE, FALSE)) {
+ if (nm_config_keyfile_has_global_dns_config (keyfile_conf, FALSE)) {
if (g_key_file_remove_group (keyfile_intern, NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS, NULL))
needs_rewrite = TRUE;
for (g = 0; groups && groups[g]; g++) {
@@ -1497,8 +1525,6 @@ nm_config_set_global_dns (NMConfig *self, NMGlobalDnsConfig *global_dns, GError
goto done;
/* Set new values */
- g_key_file_set_string (keyfile, NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS, NM_CONFIG_KEYFILE_KEY_GLOBAL_DNS_ENABLE, "yes");
-
nm_config_keyfile_set_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS,
"searches", nm_global_dns_config_get_searches (global_dns),
-1);
diff --git a/src/nm-config.h b/src/nm-config.h
index 59a3e854b2..eb195138bd 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -63,7 +63,6 @@ G_BEGIN_DECLS
#define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet"
#define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend"
-#define NM_CONFIG_KEYFILE_KEY_GLOBAL_DNS_ENABLE "enable"
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
#define NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH "auto_refresh"
@@ -145,6 +144,8 @@ void nm_config_keyfile_set_string_list (GKeyFile *keyfile,
const char *key,
const char *const* strv,
gssize len);
+gboolean nm_config_keyfile_has_global_dns_config (GKeyFile *keyfile, gboolean internal);
+
GSList *nm_config_get_match_spec (const GKeyFile *keyfile, const char *group, const char *key, gboolean *out_has_key);
void _nm_config_sort_groups (char **groups, gsize ngroups);
diff --git a/src/tests/config/Makefile.am b/src/tests/config/Makefile.am
index 4f3d7805d8..80f923c46e 100644
--- a/src/tests/config/Makefile.am
+++ b/src/tests/config/Makefile.am
@@ -30,7 +30,6 @@ TESTS = test-config
EXTRA_DIST = \
NetworkManager.conf \
bad.conf \
- global-dns-disabled.conf \
global-dns-invalid.conf \
conf.d/00-overrides.conf \
conf.d/10-more.conf \
diff --git a/src/tests/config/global-dns-disabled.conf b/src/tests/config/global-dns-disabled.conf
deleted file mode 100644
index 53ccd832e2..0000000000
--- a/src/tests/config/global-dns-disabled.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-[global-dns]
-enable=no
-searches=foo.com
-options=timeout:5
-
-[global-dns-domain-*]
-servers=1.2.3.4
-options=myoption
diff --git a/src/tests/config/global-dns-invalid.conf b/src/tests/config/global-dns-invalid.conf
index 10ecc9b04c..e490f609cc 100644
--- a/src/tests/config/global-dns-invalid.conf
+++ b/src/tests/config/global-dns-invalid.conf
@@ -1,7 +1,6 @@
# Invalid configuration, since there isn't a default domain section
[global-dns]
-enable=yes
searches=foo.com
options=timeout:5
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 5eee306a9e..ed6f875740 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -305,13 +305,6 @@ test_config_global_dns (void)
g_object_unref (config);
- /* Check that a file without "enable=yes" gives a NULL configuration */
- config = setup_config (NULL, SRCDIR "/global-dns-disabled.conf", "", NULL,
- "/no/such/dir", "", NULL);
- dns = nm_config_data_get_global_dns_config (nm_config_get_data_orig (config));
- g_assert (!dns);
- g_object_unref (config);
-
/* Check that a file without a default domain section gives a NULL configuration */
config = setup_config (NULL, SRCDIR "/global-dns-invalid.conf", "", NULL,
"/no/such/dir", "", NULL);