mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 20:30:08 +01:00
keyfile: merge branch 'th/keyfile-path-bgo755995'
https://bugzilla.gnome.org/show_bug.cgi?id=755995
This commit is contained in:
commit
c3ccc9975e
11 changed files with 46 additions and 45 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
||||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -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_ */
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue