summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-09 09:24:28 +0200
committerThomas Haller <thaller@redhat.com>2015-06-13 12:26:39 +0200
commit36750d05edaf1a519ac1b7f00434052f81dc6ceb (patch)
treeb0e050fa9f5f72f8d8f45dcdc426a56a048876b4
parenta711ac073f7c1bd52f77296da50cab3ffe634721 (diff)
downloadNetworkManager-36750d05edaf1a519ac1b7f00434052f81dc6ceb.tar.gz
config: add defines for keyfile groups to "nm-config.h"
Some plugins had their local defines for the name of the sections and keys in NMConfig. Move those defines to "nm-config.h". Usually plugins make use of code in core, but not the other way round. Defining the names inside "nm-config.h" is no violation of that because the config section names are anyway not local to the plugin, but global in the shared name-space with other settings. For example, another plugins shouldn't reuse the section "ifnet". For that reason, it is correct and consistent to move these defines to "nm-config.h". We don't use those names in core, we merely signal their existance.
-rw-r--r--src/nm-config-data.c20
-rw-r--r--src/nm-config.c28
-rw-r--r--src/nm-config.h13
-rw-r--r--src/settings/plugins/ifnet/net_parser.h1
-rw-r--r--src/settings/plugins/ifnet/plugin.c5
-rw-r--r--src/settings/plugins/ifupdown/plugin.c5
-rw-r--r--src/settings/plugins/keyfile/plugin.c8
7 files changed, 45 insertions, 35 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index d30000af19..55f119c0be 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -355,8 +355,8 @@ _get_connection_infos (GKeyFile *keyfile)
* in the right order. */
groups = g_key_file_get_groups (keyfile, NULL);
for (i = 0; groups && groups[i]; i++) {
- if (g_str_has_prefix (groups[i], "connection")) {
- if (strlen (groups[i]) == STRLEN ("connection"))
+ if (g_str_has_prefix (groups[i], NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION)) {
+ if (strlen (groups[i]) == STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION))
connection_tag = groups[i];
else
connection_groups = g_slist_prepend (connection_groups, groups[i]);
@@ -600,24 +600,24 @@ constructed (GObject *object)
priv->connection_infos = _get_connection_infos (priv->keyfile);
- priv->connectivity.uri = g_key_file_get_value (priv->keyfile, "connectivity", "uri", NULL);
- priv->connectivity.response = g_key_file_get_value (priv->keyfile, "connectivity", "response", NULL);
+ priv->connectivity.uri = g_key_file_get_value (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "uri", NULL);
+ priv->connectivity.response = g_key_file_get_value (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "response", NULL);
/* On missing config value, fallback to 300. On invalid value, disable connectivity checking by setting
* the interval to zero. */
- interval = g_key_file_get_value (priv->keyfile, "connectivity", "interval", NULL);
+ interval = g_key_file_get_value (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "interval", NULL);
priv->connectivity.interval = interval
? _nm_utils_ascii_str_to_int64 (interval, 10, 0, G_MAXUINT, 0)
: NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL;
g_free (interval);
- priv->dns_mode = g_key_file_get_value (priv->keyfile, "main", "dns", NULL);
- priv->rc_manager = g_key_file_get_value (priv->keyfile, "main", "rc-manager", NULL);
+ priv->dns_mode = g_key_file_get_value (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "dns", NULL);
+ priv->rc_manager = g_key_file_get_value (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "rc-manager", NULL);
- priv->ignore_carrier = nm_config_get_device_match_spec (priv->keyfile, "main", "ignore-carrier");
- priv->assume_ipv6ll_only = nm_config_get_device_match_spec (priv->keyfile, "main", "assume-ipv6ll-only");
+ priv->ignore_carrier = nm_config_get_device_match_spec (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "ignore-carrier");
+ priv->assume_ipv6ll_only = nm_config_get_device_match_spec (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "assume-ipv6ll-only");
- priv->no_auto_default.specs_config = nm_config_get_device_match_spec (priv->keyfile, "main", "no-auto-default");
+ priv->no_auto_default.specs_config = nm_config_get_device_match_spec (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "no-auto-default");
G_OBJECT_CLASS (nm_config_data_parent_class)->constructed (object);
}
diff --git a/src/nm-config.c b/src/nm-config.c
index 2a666d5c45..8d1bcf2b3f 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -710,7 +710,7 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
plugins_default = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1);
if (plugins_default && plugins_default[0])
- g_key_file_set_string_list (keyfile, "main", "plugins", (const char *const*) plugins_default, g_strv_length (plugins_default));
+ g_key_file_set_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", (const char *const*) plugins_default, g_strv_length (plugins_default));
g_strfreev (plugins_default);
system_confs = _get_config_dir_files (system_config_dir);
@@ -750,15 +750,15 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
/* Merge settings from command line. They overwrite everything read from
* config files. */
if (cli && cli->plugins)
- g_key_file_set_value (keyfile, "main", "plugins", cli->plugins);
+ g_key_file_set_value (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", cli->plugins);
if (cli && cli->configure_and_quit)
- g_key_file_set_value (keyfile, "main", "configure-and-quit", "true");
+ g_key_file_set_value (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "configure-and-quit", "true");
if (cli && cli->connectivity_uri && cli->connectivity_uri[0])
- g_key_file_set_value (keyfile, "connectivity", "uri", cli->connectivity_uri);
+ g_key_file_set_value (keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "uri", cli->connectivity_uri);
if (cli && cli->connectivity_interval >= 0)
- g_key_file_set_integer (keyfile, "connectivity", "interval", cli->connectivity_interval);
+ g_key_file_set_integer (keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "interval", cli->connectivity_interval);
if (cli && cli->connectivity_response && cli->connectivity_response[0])
- g_key_file_set_value (keyfile, "connectivity", "response", cli->connectivity_response);
+ g_key_file_set_value (keyfile, NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, "response", cli->connectivity_response);
str = g_string_new (o_config_main_file);
if (system_confs->len > 0) {
@@ -1399,22 +1399,22 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
else
priv->no_auto_default_file = g_strdup (DEFAULT_NO_AUTO_DEFAULT_FILE);
- priv->plugins = g_key_file_get_string_list (keyfile, "main", "plugins", NULL, NULL);
+ priv->plugins = g_key_file_get_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL);
if (!priv->plugins)
priv->plugins = g_new0 (char *, 1);
- priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, "main", "monitor-connection-files", FALSE);
+ priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
- priv->auth_polkit = nm_config_keyfile_get_boolean (keyfile, "main", "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT);
+ priv->auth_polkit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT);
- priv->dhcp_client = g_key_file_get_value (keyfile, "main", "dhcp", NULL);
+ priv->dhcp_client = g_key_file_get_value (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "dhcp", 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);
+ priv->log_level = g_key_file_get_value (keyfile, NM_CONFIG_KEYFILE_GROUP_LOGGING, "level", NULL);
+ priv->log_domains = g_key_file_get_value (keyfile, NM_CONFIG_KEYFILE_GROUP_LOGGING, "domains", NULL);
- priv->debug = g_key_file_get_value (keyfile, "main", "debug", NULL);
+ priv->debug = g_key_file_get_value (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "debug", NULL);
- priv->configure_and_quit = nm_config_keyfile_get_boolean (keyfile, "main", "configure-and-quit", FALSE);
+ priv->configure_and_quit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "configure-and-quit", FALSE);
no_auto_default = no_auto_default_from_file (priv->no_auto_default_file);
diff --git a/src/nm-config.h b/src/nm-config.h
index ec7b8ce2b6..f6ad951eb0 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -49,6 +49,19 @@ G_BEGIN_DECLS
#define NM_CONFIG_KEYFILE_LIST_SEPARATOR ','
#define NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN ".intern."
+#define NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION "connection"
+
+#define NM_CONFIG_KEYFILE_GROUP_MAIN "main"
+#define NM_CONFIG_KEYFILE_GROUP_LOGGING "logging"
+#define NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY "connectivity"
+
+#define NM_CONFIG_KEYFILE_GROUP_KEYFILE "keyfile"
+#define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN "ifupdown"
+#define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet"
+
+#define NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH "auto_refresh"
+#define NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED "managed"
+#define NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED "managed"
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was."
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET ".set."
diff --git a/src/settings/plugins/ifnet/net_parser.h b/src/settings/plugins/ifnet/net_parser.h
index 005207adfe..d10979cca6 100644
--- a/src/settings/plugins/ifnet/net_parser.h
+++ b/src/settings/plugins/ifnet/net_parser.h
@@ -25,7 +25,6 @@
#include <glib.h>
#define CONF_NET_FILE SYSCONFDIR "/conf.d/net"
-#define IFNET_KEY_FILE_GROUP "ifnet"
gboolean ifnet_init (gchar * config_file);
void ifnet_destroy (void);
diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c
index 552a480994..550f31a5fc 100644
--- a/src/settings/plugins/ifnet/plugin.c
+++ b/src/settings/plugins/ifnet/plugin.c
@@ -46,7 +46,6 @@
#define IFNET_PLUGIN_NAME_PRINT "ifnet"
#define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix."
#define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE
-#define IFNET_KEY_FILE_KEY_MANAGED "managed"
typedef struct {
GHashTable *connections; /* uuid::connection */
@@ -83,7 +82,7 @@ static gboolean
is_managed_plugin (void)
{
return nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
- IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED,
+ NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED,
IFNET_MANAGE_WELL_KNOWN_DEFAULT);
}
@@ -210,7 +209,7 @@ reload_connections (NMSystemConfigInterface *config)
nm_log_info (LOGD_SETTINGS, "Loading connections");
auto_refresh = nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
- IFNET_KEY_FILE_GROUP, "auto_refresh",
+ NM_CONFIG_KEYFILE_GROUP_IFNET, NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH,
FALSE);
new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
index dc92b19a63..ce2a0b603c 100644
--- a/src/settings/plugins/ifupdown/plugin.c
+++ b/src/settings/plugins/ifupdown/plugin.c
@@ -59,8 +59,6 @@
#define IFUPDOWN_PLUGIN_NAME "ifupdown"
#define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list."
-#define IFUPDOWN_KEY_FILE_GROUP "ifupdown"
-#define IFUPDOWN_KEY_FILE_KEY_MANAGED "managed"
#define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE
/* #define ALWAYS_UNMANAGE TRUE */
@@ -419,7 +417,8 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
/* Check the config file to find out whether to manage interfaces */
if (nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
- IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED,
+ NM_CONFIG_KEYFILE_GROUP_IFUPDOWN,
+ NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED,
FALSE))
priv->unmanage_well_known = TRUE;
nm_log_info (LOGD_SETTINGS, "management mode: %s", priv->unmanage_well_known ? "unmanaged" : "managed");
diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c
index 5ca0374b3d..f12ffd90e1 100644
--- a/src/settings/plugins/keyfile/plugin.c
+++ b/src/settings/plugins/keyfile/plugin.c
@@ -323,8 +323,8 @@ config_changed_cb (NMConfig *config,
{
gs_free char *old_value = NULL, *new_value = NULL;
- old_value = nm_config_data_get_value (old_data, "keyfile", "unmanaged-devices");
- new_value = nm_config_data_get_value (config_data, "keyfile", "unmanaged-devices");
+ old_value = nm_config_data_get_value (old_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "unmanaged-devices");
+ new_value = nm_config_data_get_value (config_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "unmanaged-devices");
if (g_strcmp0 (old_value, new_value) != 0)
g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
@@ -526,7 +526,7 @@ get_unmanaged_specs (NMSystemConfigInterface *config)
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config);
gs_free char *value = NULL;
- value = nm_config_data_get_value (nm_config_get_data (priv->config), "keyfile", "unmanaged-devices");
+ value = nm_config_data_get_value (nm_config_get_data (priv->config), NM_CONFIG_KEYFILE_GROUP_KEYFILE, "unmanaged-devices");
return nm_match_spec_split (value);
}
@@ -647,7 +647,7 @@ nm_settings_keyfile_plugin_new (void)
priv->config = g_object_ref (nm_config_get ());
value = nm_config_data_get_value (nm_config_get_data (priv->config),
- "keyfile", "hostname");
+ NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname");
if (value) {
nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect");
g_free (value);