diff options
Diffstat (limited to 'src/core/nm-config-data.c')
| -rw-r--r-- | src/core/nm-config-data.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index 5a84a2c8..461fd8ed 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -50,9 +50,9 @@ struct _NMGlobalDnsConfig { char **options; GHashTable *domains; const char **domain_list; - gboolean internal; char *cert_authority; NMDnsResolveMode resolve_mode; + gboolean internal; }; /*****************************************************************************/ @@ -941,6 +941,14 @@ next: /*****************************************************************************/ +gboolean +nm_global_dns_has_global_dns_section(const NMGlobalDnsConfig *dns_config) +{ + g_return_val_if_fail(dns_config, FALSE); + + return dns_config->searches != NULL || dns_config->options != NULL; +} + const char *const * nm_global_dns_config_get_searches(const NMGlobalDnsConfig *dns_config) { @@ -1236,6 +1244,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) gs_free char *cert_authority = NULL; gs_free char *resolve_mode = NULL; NMDnsResolveMode parsed_resolve_mode; + gboolean has_global_dns_section; if (internal) { group = NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS; @@ -1386,6 +1395,22 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) return NULL; } + /* Defining [global-dns-domain-*] implies defining [global-dns] too (maybe empty) */ + if (default_found) + has_global_dns_section = TRUE; + else + has_global_dns_section = g_key_file_has_group(keyfile, group); + + /* If there exist a [global-dns] section, always initialize "searches" and "options" so + * they appear in D-Bus. Clients can use this to know if it's defined, so they can know + * if DNS configs from connections are relevant or not. */ + if (has_global_dns_section) { + if (!dns_config->searches) + dns_config->searches = nm_strv_empty_new(); + if (!dns_config->options) + dns_config->options = nm_strv_empty_new(); + } + dns_config->internal = internal; global_dns_config_seal_domains(dns_config); return dns_config; @@ -1606,17 +1631,6 @@ nm_global_dns_config_from_dbus(const GValue *value, GError **error) g_variant_unref(val); } - /* An empty value is valid and clears the internal configuration */ - if (!nm_global_dns_config_is_empty(dns_config) - && !nm_global_dns_config_lookup_domain(dns_config, "*")) { - g_set_error_literal(error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_FAILED, - "Global DNS configuration is missing the default domain"); - nm_global_dns_config_free(dns_config); - return NULL; - } - global_dns_config_seal_domains(dns_config); return dns_config; } |