summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2015-02-12 17:35:14 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-02-25 18:25:04 +0100
commitaa672b2dc2b2e39df21b0c7c384fa9f7dab0382b (patch)
tree71941ee74fdee420c1df1cb6e8013c34d316b57c
parent8b35b9e06118fd87bb32e79ad10952cf2b236a24 (diff)
downloadNetworkManager-aa672b2dc2b2e39df21b0c7c384fa9f7dab0382b.tar.gz
config: move dns mode configuration to NMConfigData
This will make is possible for the NMDnsManager to watch for configuration changes.
-rw-r--r--src/dns-manager/nm-dns-manager.c2
-rw-r--r--src/nm-config-data.c17
-rw-r--r--src/nm-config-data.h4
-rw-r--r--src/nm-config.c13
-rw-r--r--src/nm-config.h1
5 files changed, 24 insertions, 13 deletions
diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c
index 3c15c76e67..b217f6f7b8 100644
--- a/src/dns-manager/nm-dns-manager.c
+++ b/src/dns-manager/nm-dns-manager.c
@@ -1088,7 +1088,7 @@ init_resolv_conf_mode (NMDnsManager *self)
}
}
- mode = nm_config_get_dns_mode (nm_config_get ());
+ mode = nm_config_data_get_dns_mode (nm_config_get_data (nm_config_get ()));
if (!g_strcmp0 (mode, "none")) {
priv->resolv_conf_mode = NM_DNS_MANAGER_RESOLV_CONF_UNMANAGED;
nm_log_info (LOGD_DNS, "DNS: not managing " _PATH_RESCONF);
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index 270c302f12..45d90b51d2 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -42,6 +42,8 @@ typedef struct {
char **arr;
GSList *specs;
} no_auto_default;
+
+ char *dns_mode;
} NMConfigDataPrivate;
@@ -128,6 +130,14 @@ nm_config_data_get_no_auto_default_list (const NMConfigData *self)
return NM_CONFIG_DATA_GET_PRIVATE (self)->no_auto_default.specs;
}
+const char *
+nm_config_data_get_dns_mode (const NMConfigData *self)
+{
+ g_return_val_if_fail (self, NULL);
+
+ return NM_CONFIG_DATA_GET_PRIVATE (self)->dns_mode;
+}
+
/************************************************************************/
static gboolean
@@ -192,6 +202,9 @@ nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data)
if (spec_old || spec_new)
changes |= NM_CONFIG_CHANGE_NO_AUTO_DEFAULT;
+ if (g_strcmp0 (nm_config_data_get_dns_mode (old_data), nm_config_data_get_dns_mode (new_data)))
+ changes |= NM_CONFIG_CHANGE_DNS_MODE;
+
return changes;
}
@@ -286,6 +299,8 @@ finalize (GObject *gobject)
g_slist_free (priv->no_auto_default.specs);
g_strfreev (priv->no_auto_default.arr);
+ g_free (priv->dns_mode);
+
g_key_file_unref (priv->keyfile);
G_OBJECT_CLASS (nm_config_data_parent_class)->finalize (gobject);
@@ -309,6 +324,8 @@ constructed (GObject *object)
interval = g_key_file_get_integer (priv->keyfile, "connectivity", "interval", NULL);
priv->connectivity.interval = MAX (0, interval);
+ priv->dns_mode = g_key_file_get_value (priv->keyfile, "main", "dns", NULL);
+
G_OBJECT_CLASS (nm_config_data_parent_class)->constructed (object);
}
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index bb88bf7ea2..f260a73a90 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -43,6 +43,7 @@ G_BEGIN_DECLS
#define NM_CONFIG_DATA_CONNECTIVITY_INTERVAL "connectivity-interval"
#define NM_CONFIG_DATA_CONNECTIVITY_RESPONSE "connectivity-response"
#define NM_CONFIG_DATA_NO_AUTO_DEFAULT "no-auto-default"
+#define NM_CONFIG_DATA_DNS_MODE "dns"
typedef enum { /*< flags >*/
NM_CONFIG_CHANGE_NONE = 0,
@@ -50,6 +51,7 @@ typedef enum { /*< flags >*/
NM_CONFIG_CHANGE_VALUES = (1L << 1),
NM_CONFIG_CHANGE_CONNECTIVITY = (1L << 2),
NM_CONFIG_CHANGE_NO_AUTO_DEFAULT = (1L << 3),
+ NM_CONFIG_CHANGE_DNS_MODE = (1L << 4),
_NM_CONFIG_CHANGE_LAST,
NM_CONFIG_CHANGE_ALL = ((_NM_CONFIG_CHANGE_LAST - 1) << 1) - 1,
@@ -85,6 +87,8 @@ const char *nm_config_data_get_connectivity_response (const NMConfigData *config
const char *const*nm_config_data_get_no_auto_default (const NMConfigData *config_data);
const GSList * nm_config_data_get_no_auto_default_list (const NMConfigData *config_data);
+const char *nm_config_data_get_dns_mode (const NMConfigData *self);
+
G_END_DECLS
#endif /* NM_CONFIG_DATA_H */
diff --git a/src/nm-config.c b/src/nm-config.c
index 594d05f2e3..eabb378664 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -70,7 +70,6 @@ typedef struct {
gboolean monitor_connection_files;
gboolean auth_polkit;
char *dhcp_client;
- char *dns_mode;
char *log_level;
char *log_domains;
@@ -198,14 +197,6 @@ nm_config_get_dhcp_client (NMConfig *config)
}
const char *
-nm_config_get_dns_mode (NMConfig *config)
-{
- g_return_val_if_fail (config != NULL, NULL);
-
- return NM_CONFIG_GET_PRIVATE (config)->dns_mode;
-}
-
-const char *
nm_config_get_log_level (NMConfig *config)
{
g_return_val_if_fail (config != NULL, NULL);
@@ -738,6 +729,8 @@ _change_flags_one_to_string (NMConfigChangeFlags flag)
return "connectivity";
case NM_CONFIG_CHANGE_NO_AUTO_DEFAULT:
return "no-auto-default";
+ case NM_CONFIG_CHANGE_DNS_MODE:
+ return "dns-mode";
default:
g_return_val_if_reached ("unknown");
}
@@ -852,7 +845,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
priv->auth_polkit = _get_bool_value (keyfile, "main", "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT);
priv->dhcp_client = g_key_file_get_value (keyfile, "main", "dhcp", NULL);
- priv->dns_mode = g_key_file_get_value (keyfile, "main", "dns", NULL);
priv->log_level = g_key_file_get_value (keyfile, "logging", "level", NULL);
priv->log_domains = g_key_file_get_value (keyfile, "logging", "domains", NULL);
@@ -911,7 +903,6 @@ finalize (GObject *gobject)
g_free (priv->no_auto_default_file);
g_strfreev (priv->plugins);
g_free (priv->dhcp_client);
- g_free (priv->dns_mode);
g_free (priv->log_level);
g_free (priv->log_domains);
g_free (priv->debug);
diff --git a/src/nm-config.h b/src/nm-config.h
index 46388b08eb..b82dfb3e9f 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -68,7 +68,6 @@ const char **nm_config_get_plugins (NMConfig *config);
gboolean nm_config_get_monitor_connection_files (NMConfig *config);
gboolean nm_config_get_auth_polkit (NMConfig *config);
const char *nm_config_get_dhcp_client (NMConfig *config);
-const char *nm_config_get_dns_mode (NMConfig *config);
const char *nm_config_get_log_level (NMConfig *config);
const char *nm_config_get_log_domains (NMConfig *config);
const char *nm_config_get_debug (NMConfig *config);