connection-specific configuration.</para>
<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>
: 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));
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
* 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++) {
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);
#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"
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);
EXTRA_DIST = \
NetworkManager.conf \
bad.conf \
- global-dns-disabled.conf \
global-dns-invalid.conf \
conf.d/00-overrides.conf \
conf.d/10-more.conf \
+++ /dev/null
-[global-dns]
-enable=no
-searches=foo.com
-options=timeout:5
-
-[global-dns-domain-*]
-servers=1.2.3.4
-options=myoption
# Invalid configuration, since there isn't a default domain section
[global-dns]
-enable=yes
searches=foo.com
options=timeout:5
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);