summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-14 20:23:54 +0200
committerThomas Haller <thaller@redhat.com>2015-10-14 20:23:54 +0200
commitc3ccc9975e7b1e4b920b5be101410763074d7f98 (patch)
treeb39232be02175b601c31e70d10a95227d2f1f1bf
parent7209356c4f47367d6e42e0cc8f2c10a816781cf3 (diff)
parent2144457fab9138c9f5ddac9759f48e2a8735dcfb (diff)
downloadNetworkManager-c3ccc9975e7b1e4b920b5be101410763074d7f98.tar.gz
keyfile: merge branch 'th/keyfile-path-bgo755995'
https://bugzilla.gnome.org/show_bug.cgi?id=755995
-rw-r--r--configure.ac3
-rw-r--r--man/NetworkManager.conf.xml.in8
-rw-r--r--src/Makefile.am1
-rw-r--r--src/nm-config.h1
-rw-r--r--src/settings/plugins/keyfile/Makefile.am3
-rw-r--r--src/settings/plugins/keyfile/common.h32
-rw-r--r--src/settings/plugins/keyfile/nm-keyfile-connection.c1
-rw-r--r--src/settings/plugins/keyfile/plugin.c13
-rw-r--r--src/settings/plugins/keyfile/utils.c21
-rw-r--r--src/settings/plugins/keyfile/utils.h5
-rw-r--r--src/settings/plugins/keyfile/writer.c3
11 files changed, 46 insertions, 45 deletions
diff --git a/configure.ac b/configure.ac
index 386c1e84b1..e7d3ed9279 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,9 @@ if test "$enable_ifcfg_rh" = "yes"; then
fi
AC_SUBST(DISTRO_NETWORK_SERVICE)
+AC_SUBST(NM_CONFIG_KEYFILE_PATH_DEFAULT, "${sysconfdir}/$PACKAGE/system-connections", [The keyfile directory])
+AC_DEFINE_UNQUOTED(NM_CONFIG_KEYFILE_PATH_DEFAULT, "$NM_CONFIG_KEYFILE_PATH_DEFAULT", [The keyfile directory])
+
# Code coverage
GNOME_CODE_COVERAGE
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index 53f46d10b5..3fd1b12b19 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -336,6 +336,14 @@ no-auto-default=*
system configuration files according to build options.
</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>path</varname></term>
+ <listitem>
+ <para>The location where keyfiles are read and stored.
+ This defaults to "<literal>@NM_CONFIG_KEYFILE_PATH_DEFAULT@</literal>".
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><varname>unmanaged-devices</varname></term>
<listitem><para>Set devices that should be ignored by
diff --git a/src/Makefile.am b/src/Makefile.am
index 2cae35de1c..096cd5761e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -298,7 +298,6 @@ libNetworkManager_la_SOURCES = \
settings/nm-settings.c \
settings/nm-settings.h \
\
- settings/plugins/keyfile/common.h \
settings/plugins/keyfile/nm-keyfile-connection.c \
settings/plugins/keyfile/nm-keyfile-connection.h \
settings/plugins/keyfile/plugin.c \
diff --git a/src/nm-config.h b/src/nm-config.h
index eb195138bd..7ea65d397e 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -65,6 +65,7 @@ G_BEGIN_DECLS
#define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend"
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
+#define NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH "path"
#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"
diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am
index e3566a3cad..1278b2fa3c 100644
--- a/src/settings/plugins/keyfile/Makefile.am
+++ b/src/settings/plugins/keyfile/Makefile.am
@@ -27,8 +27,7 @@ libkeyfile_io_la_SOURCES = \
writer.c \
writer.h \
utils.c \
- utils.h \
- common.h
+ utils.h
libkeyfile_io_la_LIBADD = $(GLIB_LIBS)
diff --git a/src/settings/plugins/keyfile/common.h b/src/settings/plugins/keyfile/common.h
deleted file mode 100644
index 19fa18c997..0000000000
--- a/src/settings/plugins/keyfile/common.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2008 - 2013 Red Hat, Inc.
- */
-
-#ifndef __COMMON_H__
-#define __COMMON_H__
-
-#include "nm-default.h"
-
-#define KEYFILE_PLUGIN_NAME "keyfile"
-#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
-
-#define KEYFILE_DIR NMCONFDIR "/system-connections"
-
-#endif /* __COMMON_H__ */
-
diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c
index 5f0a5517b9..c217de68ed 100644
--- a/src/settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c
@@ -32,7 +32,6 @@
#include "nm-keyfile-connection.h"
#include "reader.h"
#include "writer.h"
-#include "common.h"
#include "utils.h"
#include "nm-logging.h"
diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c
index b6c0080a4b..1ecce71a35 100644
--- a/src/settings/plugins/keyfile/plugin.c
+++ b/src/settings/plugins/keyfile/plugin.c
@@ -41,7 +41,6 @@
#include "nm-settings-plugin.h"
#include "nm-keyfile-connection.h"
#include "writer.h"
-#include "common.h"
#include "utils.h"
static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
@@ -335,7 +334,7 @@ setup_monitoring (NMSettingsPlugin *config)
GFileMonitor *monitor;
if (nm_config_get_monitor_connection_files (nm_config_get ())) {
- file = g_file_new_for_path (KEYFILE_DIR);
+ file = g_file_new_for_path (nm_keyfile_plugin_get_path ());
monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
g_object_unref (file);
@@ -404,10 +403,10 @@ read_connections (NMSettingsPlugin *config)
GPtrArray *filenames;
GHashTable *paths;
- dir = g_dir_open (KEYFILE_DIR, 0, &error);
+ dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error);
if (!dir) {
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s",
- KEYFILE_DIR,
+ nm_keyfile_plugin_get_path (),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
@@ -420,7 +419,7 @@ read_connections (NMSettingsPlugin *config)
while ((item = g_dir_read_name (dir))) {
if (nm_keyfile_plugin_utils_should_ignore_file (item))
continue;
- g_ptr_array_add (filenames, g_build_filename (KEYFILE_DIR, item, NULL));
+ g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL));
}
g_dir_close (dir);
@@ -480,9 +479,9 @@ load_connection (NMSettingsPlugin *config,
{
SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config);
NMKeyfileConnection *connection;
- int dir_len = strlen (KEYFILE_DIR);
+ int dir_len = strlen (nm_keyfile_plugin_get_path ());
- if ( strncmp (filename, KEYFILE_DIR, dir_len) != 0
+ if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0
|| filename[dir_len] != '/'
|| strchr (filename + dir_len + 1, '/') != NULL)
return FALSE;
diff --git a/src/settings/plugins/keyfile/utils.c b/src/settings/plugins/keyfile/utils.c
index 4300b0dcb4..de538bca47 100644
--- a/src/settings/plugins/keyfile/utils.c
+++ b/src/settings/plugins/keyfile/utils.c
@@ -27,6 +27,7 @@
#include <nm-setting-wired.h>
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
+#include "nm-config.h"
static const char temp_letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -144,3 +145,23 @@ nm_keyfile_plugin_utils_escape_filename (const char *filename)
return g_string_free (str, FALSE);;
}
+/*****************************************************************************/
+
+const char *
+nm_keyfile_plugin_get_path (void)
+{
+ static char *path = NULL;
+
+ if (G_UNLIKELY (!path)) {
+ path = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
+ NM_CONFIG_KEYFILE_GROUP_KEYFILE,
+ NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH,
+ NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
+ if (!path)
+ path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT"");
+ }
+ return path;
+}
+
+/*****************************************************************************/
+
diff --git a/src/settings/plugins/keyfile/utils.h b/src/settings/plugins/keyfile/utils.h
index 427cd5f64d..0b2b6f4e5e 100644
--- a/src/settings/plugins/keyfile/utils.h
+++ b/src/settings/plugins/keyfile/utils.h
@@ -24,6 +24,9 @@
#include "nm-default.h"
#include "NetworkManagerUtils.h"
+#define KEYFILE_PLUGIN_NAME "keyfile"
+#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
+
#define NM_KEYFILE_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory")
#define NM_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
#define NM_KEYFILE_CONNECTION_LOG_ARG(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
@@ -34,5 +37,7 @@ gboolean nm_keyfile_plugin_utils_should_ignore_file (const char *filename);
char *nm_keyfile_plugin_utils_escape_filename (const char *filename);
+const char *nm_keyfile_plugin_get_path (void);
+
#endif /* _UTILS_H_ */
diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c
index d3c292bdcf..db00b06104 100644
--- a/src/settings/plugins/keyfile/writer.c
+++ b/src/settings/plugins/keyfile/writer.c
@@ -29,7 +29,6 @@
#include "nm-default.h"
#include "writer.h"
-#include "common.h"
#include "utils.h"
#include "nm-keyfile-internal.h"
@@ -367,7 +366,7 @@ nm_keyfile_plugin_write_connection (NMConnection *connection,
GError **error)
{
return _internal_write_connection (connection,
- KEYFILE_DIR,
+ nm_keyfile_plugin_get_path (),
0, 0,
existing_path,
force_rename,