keyfile: merge branch 'th/keyfile-rename-bgo772463'
https://bugzilla.gnome.org/show_bug.cgi?id=772463
This commit is contained in:
@@ -384,16 +384,16 @@ libNetworkManager_la_SOURCES = \
|
||||
settings/nm-settings.c \
|
||||
settings/nm-settings.h \
|
||||
\
|
||||
settings/plugins/keyfile/nm-keyfile-connection.c \
|
||||
settings/plugins/keyfile/nm-keyfile-connection.h \
|
||||
settings/plugins/keyfile/plugin.c \
|
||||
settings/plugins/keyfile/plugin.h \
|
||||
settings/plugins/keyfile/reader.c \
|
||||
settings/plugins/keyfile/reader.h \
|
||||
settings/plugins/keyfile/utils.c \
|
||||
settings/plugins/keyfile/utils.h \
|
||||
settings/plugins/keyfile/writer.c \
|
||||
settings/plugins/keyfile/writer.h \
|
||||
settings/plugins/keyfile/nms-keyfile-connection.c \
|
||||
settings/plugins/keyfile/nms-keyfile-connection.h \
|
||||
settings/plugins/keyfile/nms-keyfile-plugin.c \
|
||||
settings/plugins/keyfile/nms-keyfile-plugin.h \
|
||||
settings/plugins/keyfile/nms-keyfile-reader.c \
|
||||
settings/plugins/keyfile/nms-keyfile-reader.h \
|
||||
settings/plugins/keyfile/nms-keyfile-utils.c \
|
||||
settings/plugins/keyfile/nms-keyfile-utils.h \
|
||||
settings/plugins/keyfile/nms-keyfile-writer.c \
|
||||
settings/plugins/keyfile/nms-keyfile-writer.h \
|
||||
\
|
||||
supplicant-manager/nm-supplicant-config.c \
|
||||
supplicant-manager/nm-supplicant-config.h \
|
||||
|
@@ -14,7 +14,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-adsl"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GUDEV_CFLAGS)
|
||||
|
||||
|
@@ -16,7 +16,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-bluetooth"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
|
@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-team"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
|
@@ -18,7 +18,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
|
@@ -8,7 +8,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/devices/wifi \
|
||||
-I$(top_builddir)/src \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
|
@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-wwan"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(LIBSYSTEMD_CFLAGS) \
|
||||
|
@@ -69,7 +69,7 @@
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-auth-subject.h"
|
||||
#include "nm-session-monitor.h"
|
||||
#include "plugins/keyfile/plugin.h"
|
||||
#include "plugins/keyfile/nms-keyfile-plugin.h"
|
||||
#include "nm-agent-manager.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-audit-manager.h"
|
||||
@@ -798,10 +798,9 @@ find_plugin (GSList *list, const char *pname)
|
||||
static void
|
||||
add_keyfile_plugin (NMSettings *self)
|
||||
{
|
||||
gs_unref_object GObject *keyfile_plugin = NULL;
|
||||
gs_unref_object NMSKeyfilePlugin *keyfile_plugin = NULL;
|
||||
|
||||
keyfile_plugin = nm_settings_keyfile_plugin_new ();
|
||||
g_assert (keyfile_plugin);
|
||||
keyfile_plugin = nms_keyfile_plugin_new ();
|
||||
if (!add_plugin (self, NM_SETTINGS_PLUGIN (keyfile_plugin)))
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DSBINDIR=\"$(sbindir)\"
|
||||
|
||||
|
@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/platform \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(srcdir)/../ \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DTEST_IBFT_DIR=\"$(abs_srcdir)\" \
|
||||
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/\"
|
||||
|
@@ -50,7 +50,7 @@ AM_CPPFLAGS = \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(NSS_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DSBINDIR=\"$(sbindir)\"
|
||||
|
||||
|
@@ -17,7 +17,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/platform \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(srcdir)/../ \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \
|
||||
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \
|
||||
|
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
@@ -13,7 +13,7 @@ AM_CPPFLAGS= \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(top_srcdir)/src/platform \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(CHECK_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
|
@@ -9,7 +9,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/shared \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(GUDEV_CFLAGS) \
|
||||
|
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(srcdir)/../ \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DTEST_ENI_DIR=\"$(abs_srcdir)\"
|
||||
|
@@ -1,48 +1 @@
|
||||
SUBDIRS = . tests
|
||||
|
||||
@GNOME_CODE_COVERAGE_RULES@
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(top_srcdir)/shared \
|
||||
-I$(top_builddir)/shared \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DNMCONFDIR=\"$(nmconfdir)\"
|
||||
|
||||
noinst_LTLIBRARIES = \
|
||||
libkeyfile-io.la \
|
||||
libnm-settings-plugin-keyfile.la
|
||||
|
||||
##### I/O library for testcases #####
|
||||
|
||||
libkeyfile_io_la_SOURCES = \
|
||||
reader.c \
|
||||
reader.h \
|
||||
writer.c \
|
||||
writer.h \
|
||||
utils.c \
|
||||
utils.h
|
||||
|
||||
libkeyfile_io_la_LIBADD = $(GLIB_LIBS)
|
||||
|
||||
#####################################
|
||||
|
||||
libnm_settings_plugin_keyfile_la_SOURCES = \
|
||||
nm-keyfile-connection.c \
|
||||
nm-keyfile-connection.h \
|
||||
plugin.c \
|
||||
plugin.h
|
||||
|
||||
libnm_settings_plugin_keyfile_la_LIBADD = \
|
||||
libkeyfile-io.la
|
||||
|
||||
keyfiledir=$(sysconfdir)/NetworkManager/system-connections
|
||||
|
||||
install-data-hook:
|
||||
$(mkinstalldirs) -m 0755 $(DESTDIR)$(keyfiledir)
|
||||
|
||||
SUBDIRS = tests
|
||||
|
@@ -1,48 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager system settings service - keyfile plugin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_KEYFILE_CONNECTION_H__
|
||||
#define __NETWORKMANAGER_KEYFILE_CONNECTION_H__
|
||||
|
||||
#include <nm-settings-connection.h>
|
||||
|
||||
#define NM_TYPE_KEYFILE_CONNECTION (nm_keyfile_connection_get_type ())
|
||||
#define NM_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnection))
|
||||
#define NM_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass))
|
||||
#define NM_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_KEYFILE_CONNECTION))
|
||||
#define NM_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_KEYFILE_CONNECTION))
|
||||
#define NM_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass))
|
||||
|
||||
typedef struct {
|
||||
NMSettingsConnection parent;
|
||||
} NMKeyfileConnection;
|
||||
|
||||
typedef struct {
|
||||
NMSettingsConnectionClass parent;
|
||||
} NMKeyfileConnectionClass;
|
||||
|
||||
GType nm_keyfile_connection_get_type (void);
|
||||
|
||||
NMKeyfileConnection *nm_keyfile_connection_new (NMConnection *source,
|
||||
const char *filename,
|
||||
GError **error);
|
||||
|
||||
#endif /* __NETWORKMANAGER_KEYFILE_CONNECTION_H__ */
|
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nms-keyfile-connection.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -29,17 +31,99 @@
|
||||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-settings-plugin.h"
|
||||
#include "nm-keyfile-connection.h"
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
#include "utils.h"
|
||||
|
||||
G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION)
|
||||
#include "nms-keyfile-reader.h"
|
||||
#include "nms-keyfile-writer.h"
|
||||
#include "nms-keyfile-utils.h"
|
||||
|
||||
NMKeyfileConnection *
|
||||
nm_keyfile_connection_new (NMConnection *source,
|
||||
const char *full_path,
|
||||
GError **error)
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMSKeyfileConnection {
|
||||
NMSettingsConnection parent;
|
||||
};
|
||||
|
||||
struct _NMSKeyfileConnectionClass {
|
||||
NMSettingsConnectionClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NMSKeyfileConnection, nms_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
commit_changes (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
NMSettingsConnectionCommitFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *path = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nms_keyfile_writer_connection (NM_CONNECTION (connection),
|
||||
nm_settings_connection_get_filename (connection),
|
||||
NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION
|
||||
| NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED),
|
||||
&path,
|
||||
&error)) {
|
||||
callback (connection, error, user_data);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the filename if it changed */
|
||||
if ( path
|
||||
&& g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) {
|
||||
gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection));
|
||||
|
||||
nm_settings_connection_set_filename (connection, path);
|
||||
if (old_path) {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"",
|
||||
NMS_KEYFILE_CONNECTION_LOG_ARG (connection),
|
||||
old_path);
|
||||
} else {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and persist connection",
|
||||
NMS_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
}
|
||||
} else {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT,
|
||||
NMS_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->commit_changes (connection,
|
||||
commit_reason,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
do_delete (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionDeleteFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
const char *path;
|
||||
|
||||
path = nm_settings_connection_get_filename (connection);
|
||||
if (path)
|
||||
g_unlink (path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->delete (connection,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nms_keyfile_connection_init (NMSKeyfileConnection *connection)
|
||||
{
|
||||
}
|
||||
|
||||
NMSKeyfileConnection *
|
||||
nms_keyfile_connection_new (NMConnection *source,
|
||||
const char *full_path,
|
||||
GError **error)
|
||||
{
|
||||
GObject *object;
|
||||
NMConnection *tmp;
|
||||
@@ -52,7 +136,7 @@ nm_keyfile_connection_new (NMConnection *source,
|
||||
if (source)
|
||||
tmp = g_object_ref (source);
|
||||
else {
|
||||
tmp = nm_keyfile_plugin_connection_from_file (full_path, error);
|
||||
tmp = nms_keyfile_reader_from_file (full_path, error);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
|
||||
@@ -68,7 +152,7 @@ nm_keyfile_connection_new (NMConnection *source,
|
||||
update_unsaved = FALSE;
|
||||
}
|
||||
|
||||
object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION,
|
||||
object = (GObject *) g_object_new (NMS_TYPE_KEYFILE_CONNECTION,
|
||||
NM_SETTINGS_CONNECTION_FILENAME, full_path,
|
||||
NULL);
|
||||
|
||||
@@ -83,85 +167,14 @@ nm_keyfile_connection_new (NMConnection *source,
|
||||
}
|
||||
|
||||
g_object_unref (tmp);
|
||||
return (NMKeyfileConnection *) object;
|
||||
return (NMSKeyfileConnection *) object;
|
||||
}
|
||||
|
||||
static void
|
||||
commit_changes (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
NMSettingsConnectionCommitFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *path = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection),
|
||||
nm_settings_connection_get_filename (connection),
|
||||
NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION
|
||||
| NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED),
|
||||
&path,
|
||||
&error)) {
|
||||
callback (connection, error, user_data);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the filename if it changed */
|
||||
if ( path
|
||||
&& g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) {
|
||||
gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection));
|
||||
|
||||
nm_settings_connection_set_filename (connection, path);
|
||||
if (old_path) {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"",
|
||||
NM_KEYFILE_CONNECTION_LOG_ARG (connection),
|
||||
old_path);
|
||||
} else {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and persist connection",
|
||||
NM_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
}
|
||||
} else {
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT,
|
||||
NM_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection,
|
||||
commit_reason,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
do_delete (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionDeleteFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
const char *path;
|
||||
|
||||
path = nm_settings_connection_get_filename (connection);
|
||||
if (path)
|
||||
g_unlink (path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/* GObject */
|
||||
|
||||
static void
|
||||
nm_keyfile_connection_init (NMKeyfileConnection *connection)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class)
|
||||
nms_keyfile_connection_class_init (NMSKeyfileConnectionClass *keyfile_connection_class)
|
||||
{
|
||||
NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class);
|
||||
|
||||
/* Virtual methods */
|
||||
settings_class->commit_changes = commit_changes;
|
||||
settings_class->delete = do_delete;
|
||||
}
|
43
src/settings/plugins/keyfile/nms-keyfile-connection.h
Normal file
43
src/settings/plugins/keyfile/nms-keyfile-connection.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager system settings service - keyfile plugin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NMS_KEYFILE_CONNECTION_H__
|
||||
#define __NMS_KEYFILE_CONNECTION_H__
|
||||
|
||||
#include <nm-settings-connection.h>
|
||||
|
||||
#define NMS_TYPE_KEYFILE_CONNECTION (nms_keyfile_connection_get_type ())
|
||||
#define NMS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnection))
|
||||
#define NMS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass))
|
||||
#define NMS_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_CONNECTION))
|
||||
#define NMS_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_CONNECTION))
|
||||
#define NMS_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass))
|
||||
|
||||
typedef struct _NMSKeyfileConnection NMSKeyfileConnection;
|
||||
typedef struct _NMSKeyfileConnectionClass NMSKeyfileConnectionClass;
|
||||
|
||||
GType nms_keyfile_connection_get_type (void);
|
||||
|
||||
NMSKeyfileConnection *nms_keyfile_connection_new (NMConnection *source,
|
||||
const char *filename,
|
||||
GError **error);
|
||||
|
||||
#endif /* __NMS_KEYFILE_CONNECTION_H__ */
|
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "nms-keyfile-plugin.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@@ -38,9 +38,10 @@
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-settings-plugin.h"
|
||||
#include "nm-keyfile-connection.h"
|
||||
#include "writer.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "nms-keyfile-connection.h"
|
||||
#include "nms-keyfile-writer.h"
|
||||
#include "nms-keyfile-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -52,49 +53,59 @@ typedef struct {
|
||||
gulong monitor_id;
|
||||
|
||||
NMConfig *config;
|
||||
} SettingsPluginKeyfilePrivate;
|
||||
} NMSKeyfilePluginPrivate;
|
||||
|
||||
struct _SettingsPluginKeyfile {
|
||||
struct _NMSKeyfilePlugin {
|
||||
GObject parent;
|
||||
SettingsPluginKeyfilePrivate _priv;
|
||||
NMSKeyfilePluginPrivate _priv;
|
||||
};
|
||||
|
||||
struct _SettingsPluginKeyfileClass {
|
||||
struct _NMSKeyfilePluginClass {
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0,
|
||||
G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
|
||||
settings_plugin_interface_init))
|
||||
|
||||
#define SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginKeyfile, SETTINGS_IS_PLUGIN_KEYFILE)
|
||||
#define NMS_KEYFILE_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSKeyfilePlugin, NMS_IS_KEYFILE_PLUGIN)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "keyfile"
|
||||
#define _NMLOG_DOMAIN LOGD_SETTINGS
|
||||
#define _NMLOG(level, ...) \
|
||||
nm_log ((level), _NMLOG_DOMAIN, \
|
||||
"%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME": " \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
connection_removed_cb (NMSettingsConnection *obj, gpointer user_data)
|
||||
{
|
||||
g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) user_data)->connections,
|
||||
g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) user_data)->connections,
|
||||
nm_connection_get_uuid (NM_CONNECTION (obj)));
|
||||
}
|
||||
|
||||
/* Monitoring */
|
||||
|
||||
static void
|
||||
remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection)
|
||||
remove_connection (NMSKeyfilePlugin *self, NMSKeyfileConnection *connection)
|
||||
{
|
||||
gboolean removed;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: removed " NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
_LOGI ("removed " NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection));
|
||||
|
||||
/* Removing from the hash table should drop the last reference */
|
||||
g_object_ref (connection);
|
||||
g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self);
|
||||
removed = g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections,
|
||||
removed = g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections,
|
||||
nm_connection_get_uuid (NM_CONNECTION (connection)));
|
||||
nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
|
||||
g_object_unref (connection);
|
||||
@@ -102,10 +113,10 @@ remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection)
|
||||
g_return_if_fail (removed);
|
||||
}
|
||||
|
||||
static NMKeyfileConnection *
|
||||
find_by_path (SettingsPluginKeyfile *self, const char *path)
|
||||
static NMSKeyfileConnection *
|
||||
find_by_path (NMSKeyfilePlugin *self, const char *path)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
NMSettingsConnection *candidate = NULL;
|
||||
|
||||
@@ -114,7 +125,7 @@ find_by_path (SettingsPluginKeyfile *self, const char *path)
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
|
||||
if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0)
|
||||
return NM_KEYFILE_CONNECTION (candidate);
|
||||
return NMS_KEYFILE_CONNECTION (candidate);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -150,18 +161,18 @@ find_by_path (SettingsPluginKeyfile *self, const char *path)
|
||||
*
|
||||
* Returns: the updated connection.
|
||||
* */
|
||||
static NMKeyfileConnection *
|
||||
update_connection (SettingsPluginKeyfile *self,
|
||||
static NMSKeyfileConnection *
|
||||
update_connection (NMSKeyfilePlugin *self,
|
||||
NMConnection *source,
|
||||
const char *full_path,
|
||||
NMKeyfileConnection *connection,
|
||||
NMSKeyfileConnection *connection,
|
||||
gboolean protect_existing_connection,
|
||||
GHashTable *protected_connections,
|
||||
GError **error)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self);
|
||||
NMKeyfileConnection *connection_new;
|
||||
NMKeyfileConnection *connection_by_uuid;
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self);
|
||||
NMSKeyfileConnection *connection_new;
|
||||
NMSKeyfileConnection *connection_by_uuid;
|
||||
GError *local = NULL;
|
||||
const char *uuid;
|
||||
|
||||
@@ -169,15 +180,15 @@ update_connection (SettingsPluginKeyfile *self,
|
||||
g_return_val_if_fail (full_path || source, NULL);
|
||||
|
||||
if (full_path)
|
||||
nm_log_dbg (LOGD_SETTINGS, "keyfile: loading from file \"%s\"...", full_path);
|
||||
_LOGD ("loading from file \"%s\"...", full_path);
|
||||
|
||||
connection_new = nm_keyfile_connection_new (source, full_path, &local);
|
||||
connection_new = nms_keyfile_connection_new (source, full_path, &local);
|
||||
if (!connection_new) {
|
||||
/* Error; remove the connection */
|
||||
if (source)
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: error creating connection %s: %s", nm_connection_get_uuid (source), local->message);
|
||||
_LOGW ("error creating connection %s: %s", nm_connection_get_uuid (source), local->message);
|
||||
else
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: error loading connection from file %s: %s", full_path, local->message);
|
||||
_LOGW ("error loading connection from file %s: %s", full_path, local->message);
|
||||
if ( connection
|
||||
&& !protect_existing_connection
|
||||
&& (!protected_connections || !g_hash_table_contains (protected_connections, connection)))
|
||||
@@ -194,12 +205,12 @@ update_connection (SettingsPluginKeyfile *self,
|
||||
|
||||
if ( (protect_existing_connection && connection_by_uuid != NULL)
|
||||
|| (protected_connections && g_hash_table_contains (protected_connections, connection))) {
|
||||
NMKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection;
|
||||
NMSKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection;
|
||||
|
||||
if (source)
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update protected "NM_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NM_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid);
|
||||
_LOGW ("cannot update protected "NMS_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid);
|
||||
else
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (conflicting));
|
||||
_LOGW ("cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting));
|
||||
g_object_unref (connection_new);
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
|
||||
"Cannot update protected connection due to conflicting UUID");
|
||||
@@ -215,9 +226,9 @@ update_connection (SettingsPluginKeyfile *self,
|
||||
&& ( (!connection && protect_existing_connection)
|
||||
|| (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) {
|
||||
if (source)
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update connection due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid));
|
||||
_LOGW ("cannot update connection due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid));
|
||||
else
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid));
|
||||
_LOGW ("cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid));
|
||||
g_object_unref (connection_new);
|
||||
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
|
||||
"Skip updating protected connection during reload");
|
||||
@@ -235,17 +246,17 @@ update_connection (SettingsPluginKeyfile *self,
|
||||
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
|
||||
/* Nothing to do... except updating the path. */
|
||||
if (old_path && g_strcmp0 (old_path, full_path) != 0)
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
} else {
|
||||
/* An existing connection changed. */
|
||||
if (source)
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" from %s", NM_KEYFILE_CONNECTION_LOG_ARG (connection_new), NM_KEYFILE_CONNECTION_LOG_PATH (old_path));
|
||||
_LOGI ("update "NMS_KEYFILE_CONNECTION_LOG_FMT" from %s", NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new), NMS_KEYFILE_CONNECTION_LOG_PATH (old_path));
|
||||
else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new))))
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("update "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
else if (old_path)
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT, old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT, old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
else
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: update and persist "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("update and persist "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid),
|
||||
NM_CONNECTION (connection_new),
|
||||
@@ -263,9 +274,9 @@ update_connection (SettingsPluginKeyfile *self,
|
||||
return connection_by_uuid;
|
||||
} else {
|
||||
if (source)
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: add connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("add connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
else
|
||||
nm_log_info (LOGD_SETTINGS, "keyfile: new connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
_LOGI ("new connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new);
|
||||
|
||||
g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED,
|
||||
@@ -289,31 +300,31 @@ dir_changed (GFileMonitor *monitor,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data);
|
||||
SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config);
|
||||
NMKeyfileConnection *connection;
|
||||
NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config);
|
||||
NMSKeyfileConnection *connection;
|
||||
char *full_path;
|
||||
gboolean exists;
|
||||
|
||||
full_path = g_file_get_path (file);
|
||||
if (nm_keyfile_plugin_utils_should_ignore_file (full_path)) {
|
||||
if (nms_keyfile_utils_should_ignore_file (full_path)) {
|
||||
g_free (full_path);
|
||||
return;
|
||||
}
|
||||
exists = g_file_test (full_path, G_FILE_TEST_EXISTS);
|
||||
|
||||
nm_log_dbg (LOGD_SETTINGS, "dir_changed(%s) = %d; file %s", full_path, event_type, exists ? "exists" : "does not exist");
|
||||
_LOGD ("dir_changed(%s) = %d; file %s", full_path, event_type, exists ? "exists" : "does not exist");
|
||||
|
||||
connection = find_by_path (self, full_path);
|
||||
|
||||
switch (event_type) {
|
||||
case G_FILE_MONITOR_EVENT_DELETED:
|
||||
if (!exists && connection)
|
||||
remove_connection (SETTINGS_PLUGIN_KEYFILE (config), connection);
|
||||
remove_connection (NMS_KEYFILE_PLUGIN (config), connection);
|
||||
break;
|
||||
case G_FILE_MONITOR_EVENT_CREATED:
|
||||
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
|
||||
if (exists)
|
||||
update_connection (SETTINGS_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL);
|
||||
update_connection (NMS_KEYFILE_PLUGIN (config), NULL, full_path, connection, TRUE, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -327,7 +338,7 @@ config_changed_cb (NMConfig *config,
|
||||
NMConfigData *config_data,
|
||||
NMConfigChangeFlags changes,
|
||||
NMConfigData *old_data,
|
||||
SettingsPluginKeyfile *self)
|
||||
NMSKeyfilePlugin *self)
|
||||
{
|
||||
gs_free char *old_value = NULL, *new_value = NULL;
|
||||
|
||||
@@ -341,12 +352,12 @@ config_changed_cb (NMConfig *config,
|
||||
static void
|
||||
setup_monitoring (NMSettingsPlugin *config)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config);
|
||||
GFile *file;
|
||||
GFileMonitor *monitor;
|
||||
|
||||
if (nm_config_get_monitor_connection_files (nm_config_get ())) {
|
||||
file = g_file_new_for_path (nm_keyfile_plugin_get_path ());
|
||||
if (nm_config_get_monitor_connection_files (priv->config)) {
|
||||
file = g_file_new_for_path (nms_keyfile_utils_get_path ());
|
||||
monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
||||
g_object_unref (file);
|
||||
|
||||
@@ -366,7 +377,7 @@ static GHashTable *
|
||||
_paths_from_connections (GHashTable *connections)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
NMKeyfileConnection *connection;
|
||||
NMSKeyfileConnection *connection;
|
||||
GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_iter_init (&iter, connections);
|
||||
@@ -402,23 +413,23 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths)
|
||||
static void
|
||||
read_connections (NMSettingsPlugin *config)
|
||||
{
|
||||
SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config);
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self);
|
||||
NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self);
|
||||
GDir *dir;
|
||||
GError *error = NULL;
|
||||
const char *item;
|
||||
GHashTable *alive_connections;
|
||||
GHashTableIter iter;
|
||||
NMKeyfileConnection *connection;
|
||||
NMSKeyfileConnection *connection;
|
||||
GPtrArray *dead_connections = NULL;
|
||||
guint i;
|
||||
GPtrArray *filenames;
|
||||
GHashTable *paths;
|
||||
|
||||
dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error);
|
||||
dir = g_dir_open (nms_keyfile_utils_get_path (), 0, &error);
|
||||
if (!dir) {
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': %s",
|
||||
nm_keyfile_plugin_get_path (),
|
||||
_LOGW ("cannot read directory '%s': %s",
|
||||
nms_keyfile_utils_get_path (),
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
@@ -428,9 +439,9 @@ read_connections (NMSettingsPlugin *config)
|
||||
|
||||
filenames = g_ptr_array_new_with_free_func (g_free);
|
||||
while ((item = g_dir_read_name (dir))) {
|
||||
if (nm_keyfile_plugin_utils_should_ignore_file (item))
|
||||
if (nms_keyfile_utils_should_ignore_file (item))
|
||||
continue;
|
||||
g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL));
|
||||
g_ptr_array_add (filenames, g_build_filename (nms_keyfile_utils_get_path (), item, NULL));
|
||||
}
|
||||
g_dir_close (dir);
|
||||
|
||||
@@ -474,7 +485,7 @@ read_connections (NMSettingsPlugin *config)
|
||||
static GSList *
|
||||
get_connections (NMSettingsPlugin *config)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config);
|
||||
|
||||
if (!priv->initialized) {
|
||||
setup_monitoring (config);
|
||||
@@ -488,16 +499,16 @@ static gboolean
|
||||
load_connection (NMSettingsPlugin *config,
|
||||
const char *filename)
|
||||
{
|
||||
SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE ((SettingsPluginKeyfile *) config);
|
||||
NMKeyfileConnection *connection;
|
||||
int dir_len = strlen (nm_keyfile_plugin_get_path ());
|
||||
NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN ((NMSKeyfilePlugin *) config);
|
||||
NMSKeyfileConnection *connection;
|
||||
int dir_len = strlen (nms_keyfile_utils_get_path ());
|
||||
|
||||
if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0
|
||||
if ( strncmp (filename, nms_keyfile_utils_get_path (), dir_len) != 0
|
||||
|| filename[dir_len] != '/'
|
||||
|| strchr (filename + dir_len + 1, '/') != NULL)
|
||||
return FALSE;
|
||||
|
||||
if (nm_keyfile_plugin_utils_should_ignore_file (filename + dir_len + 1))
|
||||
if (nms_keyfile_utils_should_ignore_file (filename + dir_len + 1))
|
||||
return FALSE;
|
||||
|
||||
connection = update_connection (self, NULL, filename, find_by_path (self, filename), TRUE, NULL, NULL);
|
||||
@@ -517,11 +528,11 @@ add_connection (NMSettingsPlugin *config,
|
||||
gboolean save_to_disk,
|
||||
GError **error)
|
||||
{
|
||||
SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config);
|
||||
NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config);
|
||||
gs_free char *path = NULL;
|
||||
|
||||
if (save_to_disk) {
|
||||
if (!nm_keyfile_plugin_write_connection (connection, NULL, FALSE, &path, error))
|
||||
if (!nms_keyfile_writer_connection (connection, NULL, FALSE, &path, error))
|
||||
return NULL;
|
||||
}
|
||||
return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error));
|
||||
@@ -530,7 +541,7 @@ add_connection (NMSettingsPlugin *config,
|
||||
static GSList *
|
||||
get_unmanaged_specs (NMSettingsPlugin *config)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config);
|
||||
gs_free char *value = NULL;
|
||||
|
||||
value = nm_config_data_get_value (nm_config_get_data (priv->config),
|
||||
@@ -548,10 +559,10 @@ get_property (GObject *object, guint prop_id,
|
||||
{
|
||||
switch (prop_id) {
|
||||
case NM_SETTINGS_PLUGIN_PROP_NAME:
|
||||
g_value_set_string (value, KEYFILE_PLUGIN_NAME);
|
||||
g_value_set_string (value, NMS_KEYFILE_PLUGIN_NAME);
|
||||
break;
|
||||
case NM_SETTINGS_PLUGIN_PROP_INFO:
|
||||
g_value_set_string (value, KEYFILE_PLUGIN_INFO);
|
||||
g_value_set_string (value, NMS_KEYFILE_PLUGIN_INFO);
|
||||
break;
|
||||
case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES:
|
||||
g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS);
|
||||
@@ -565,36 +576,38 @@ get_property (GObject *object, guint prop_id,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin)
|
||||
nms_keyfile_plugin_init (NMSKeyfilePlugin *plugin)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (plugin);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (plugin);
|
||||
|
||||
priv->config = g_object_ref (nm_config_get ());
|
||||
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) object);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object);
|
||||
|
||||
G_OBJECT_CLASS (nms_keyfile_plugin_parent_class)->constructed (object);
|
||||
|
||||
priv->config = g_object_ref (nm_config_get ());
|
||||
if (nm_config_data_has_value (nm_config_get_data_orig (priv->config),
|
||||
NM_CONFIG_KEYFILE_GROUP_KEYFILE,
|
||||
NM_CONFIG_KEYFILE_KEY_KEYFILE_HOSTNAME,
|
||||
NM_CONFIG_GET_VALUE_RAW))
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect");
|
||||
_LOGW ("'hostname' option is deprecated and has no effect");
|
||||
}
|
||||
|
||||
GObject *
|
||||
nm_settings_keyfile_plugin_new (void)
|
||||
NMSKeyfilePlugin *
|
||||
nms_keyfile_plugin_new (void)
|
||||
{
|
||||
return g_object_new (SETTINGS_TYPE_PLUGIN_KEYFILE, NULL);
|
||||
return g_object_new (NMS_TYPE_KEYFILE_PLUGIN, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) object);
|
||||
NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object);
|
||||
|
||||
if (priv->monitor) {
|
||||
nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id);
|
||||
@@ -613,11 +626,11 @@ dispose (GObject *object)
|
||||
g_clear_object (&priv->config);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (settings_plugin_keyfile_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (nms_keyfile_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class)
|
||||
nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
|
39
src/settings/plugins/keyfile/nms-keyfile-plugin.h
Normal file
39
src/settings/plugins/keyfile/nms-keyfile-plugin.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager system settings service - keyfile plugin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NMS_KEYFILE_PLUGIN_H__
|
||||
#define __NMS_KEYFILE_PLUGIN_H__
|
||||
|
||||
#define NMS_TYPE_KEYFILE_PLUGIN (nms_keyfile_plugin_get_type ())
|
||||
#define NMS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePlugin))
|
||||
#define NMS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass))
|
||||
#define NMS_IS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_PLUGIN))
|
||||
#define NMS_IS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_PLUGIN))
|
||||
#define NMS_KEYFILE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass))
|
||||
|
||||
typedef struct _NMSKeyfilePlugin NMSKeyfilePlugin;
|
||||
typedef struct _NMSKeyfilePluginClass NMSKeyfilePluginClass;
|
||||
|
||||
GType nms_keyfile_plugin_get_type (void);
|
||||
|
||||
NMSKeyfilePlugin *nms_keyfile_plugin_new (void);
|
||||
|
||||
#endif /* __NMS_KEYFILE_PLUGIN_H__ */
|
@@ -20,14 +20,17 @@
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nms-keyfile-reader.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "reader.h"
|
||||
|
||||
#include "nm-keyfile-internal.h"
|
||||
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const char *
|
||||
_fmt_warn (const char *group, NMSetting *setting, const char *property_name, const char *message, char **out_message)
|
||||
{
|
||||
@@ -86,7 +89,7 @@ _handler_read (GKeyFile *keyfile,
|
||||
}
|
||||
|
||||
NMConnection *
|
||||
nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
|
||||
nms_keyfile_reader_from_file (const char *filename, GError **error)
|
||||
{
|
||||
GKeyFile *key_file;
|
||||
struct stat statbuf;
|
@@ -19,11 +19,11 @@
|
||||
* Copyright (C) 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _KEYFILE_PLUGIN_READER_H
|
||||
#define _KEYFILE_PLUGIN_READER_H
|
||||
#ifndef __NMS_KEYFILE_READER_H__
|
||||
#define __NMS_KEYFILE_READER_H__
|
||||
|
||||
#include <nm-connection.h>
|
||||
|
||||
NMConnection *nm_keyfile_plugin_connection_from_file (const char *filename, GError **error);
|
||||
NMConnection *nms_keyfile_reader_from_file (const char *filename, GError **error);
|
||||
|
||||
#endif /* _KEYFILE_PLUGIN_READER_H */
|
||||
#endif /* __NMS_KEYFILE_READER_H__ */
|
@@ -20,10 +20,11 @@
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nms-keyfile-utils.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
@@ -31,6 +32,8 @@
|
||||
|
||||
#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const char temp_letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
@@ -87,7 +90,7 @@ check_suffix (const char *base, const char *tag)
|
||||
#define DER_TAG ".der"
|
||||
|
||||
gboolean
|
||||
nm_keyfile_plugin_utils_should_ignore_file (const char *filename)
|
||||
nms_keyfile_utils_should_ignore_file (const char *filename)
|
||||
{
|
||||
gs_free char *base = NULL;
|
||||
|
||||
@@ -111,7 +114,7 @@ nm_keyfile_plugin_utils_should_ignore_file (const char *filename)
|
||||
}
|
||||
|
||||
char *
|
||||
nm_keyfile_plugin_utils_escape_filename (const char *filename)
|
||||
nms_keyfile_utils_escape_filename (const char *filename)
|
||||
{
|
||||
GString *str;
|
||||
const char *f = filename;
|
||||
@@ -150,7 +153,7 @@ nm_keyfile_plugin_utils_escape_filename (const char *filename)
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *
|
||||
nm_keyfile_plugin_get_path (void)
|
||||
nms_keyfile_utils_get_path (void)
|
||||
{
|
||||
static char *path = NULL;
|
||||
|
||||
@@ -165,5 +168,3 @@ nm_keyfile_plugin_get_path (void)
|
||||
return path;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
41
src/settings/plugins/keyfile/nms-keyfile-utils.h
Normal file
41
src/settings/plugins/keyfile/nms-keyfile-utils.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- 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 2010-2016 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NMS_KEYFILE_UTILS_H__
|
||||
#define __NMS_KEYFILE_UTILS_H__
|
||||
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#define NMS_KEYFILE_PLUGIN_NAME "keyfile"
|
||||
#define NMS_KEYFILE_PLUGIN_INFO "(c) 2007 - 2016 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
|
||||
|
||||
#define NMS_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory")
|
||||
#define NMS_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
|
||||
#define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
|
||||
#define NMS_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
|
||||
#define NMS_KEYFILE_CONNECTION_LOG_ARGD(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con)
|
||||
|
||||
gboolean nms_keyfile_utils_should_ignore_file (const char *filename);
|
||||
|
||||
char *nms_keyfile_utils_escape_filename (const char *filename);
|
||||
|
||||
const char *nms_keyfile_utils_get_path (void);
|
||||
|
||||
#endif /* __NMS_KEYFILE_UTILS_H__ */
|
@@ -21,20 +21,25 @@
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nms-keyfile-writer.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "writer.h"
|
||||
#include "utils.h"
|
||||
#include "nm-keyfile-internal.h"
|
||||
|
||||
#include "nms-keyfile-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
const char *keyfile_dir;
|
||||
} WriteInfo;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
write_cert_key_file (const char *path,
|
||||
@@ -262,7 +267,7 @@ _internal_write_connection (NMConnection *connection,
|
||||
if (existing_path != NULL && !force_rename) {
|
||||
path = g_strdup (existing_path);
|
||||
} else {
|
||||
char *filename_escaped = nm_keyfile_plugin_utils_escape_filename (id);
|
||||
char *filename_escaped = nms_keyfile_utils_escape_filename (id);
|
||||
|
||||
path = g_build_filename (keyfile_dir, filename_escaped, NULL);
|
||||
g_free (filename_escaped);
|
||||
@@ -288,7 +293,7 @@ _internal_write_connection (NMConnection *connection,
|
||||
else
|
||||
filename = g_strdup_printf ("%s-%s-%u", id, nm_connection_get_uuid (connection), i);
|
||||
|
||||
filename_escaped = nm_keyfile_plugin_utils_escape_filename (filename);
|
||||
filename_escaped = nms_keyfile_utils_escape_filename (filename);
|
||||
|
||||
g_free (path);
|
||||
path = g_strdup_printf ("%s/%s", keyfile_dir, filename_escaped);
|
||||
@@ -351,14 +356,14 @@ out:
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_keyfile_plugin_write_connection (NMConnection *connection,
|
||||
const char *existing_path,
|
||||
gboolean force_rename,
|
||||
char **out_path,
|
||||
GError **error)
|
||||
nms_keyfile_writer_connection (NMConnection *connection,
|
||||
const char *existing_path,
|
||||
gboolean force_rename,
|
||||
char **out_path,
|
||||
GError **error)
|
||||
{
|
||||
return _internal_write_connection (connection,
|
||||
nm_keyfile_plugin_get_path (),
|
||||
nms_keyfile_utils_get_path (),
|
||||
0, 0,
|
||||
existing_path,
|
||||
force_rename,
|
||||
@@ -367,12 +372,12 @@ nm_keyfile_plugin_write_connection (NMConnection *connection,
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_keyfile_plugin_write_test_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error)
|
||||
nms_keyfile_writer_test_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error)
|
||||
{
|
||||
return _internal_write_connection (connection,
|
||||
keyfile_dir,
|
@@ -19,22 +19,22 @@
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _KEYFILE_PLUGIN_WRITER_H
|
||||
#define _KEYFILE_PLUGIN_WRITER_H
|
||||
#ifndef __NMS_KEYFILE_WRITER_H__
|
||||
#define __NMS_KEYFILE_WRITER_H__
|
||||
|
||||
#include <nm-connection.h>
|
||||
|
||||
gboolean nm_keyfile_plugin_write_connection (NMConnection *connection,
|
||||
const char *existing_path,
|
||||
gboolean force_rename,
|
||||
gboolean nms_keyfile_writer_connection (NMConnection *connection,
|
||||
const char *existing_path,
|
||||
gboolean force_rename,
|
||||
char **out_path,
|
||||
GError **error);
|
||||
|
||||
gboolean nms_keyfile_writer_test_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_keyfile_plugin_write_test_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error);
|
||||
|
||||
#endif /* _KEYFILE_PLUGIN_WRITER_H */
|
||||
#endif /* __NMS_KEYFILE_WRITER_H__ */
|
@@ -1,39 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager system settings service - keyfile plugin
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NMKF_PLUGIN_H__
|
||||
#define __NMKF_PLUGIN_H__
|
||||
|
||||
#define SETTINGS_TYPE_PLUGIN_KEYFILE (settings_plugin_keyfile_get_type ())
|
||||
#define SETTINGS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfile))
|
||||
#define SETTINGS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass))
|
||||
#define SETTINGS_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE))
|
||||
#define SETTINGS_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE))
|
||||
#define SETTINGS_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass))
|
||||
|
||||
typedef struct _SettingsPluginKeyfile SettingsPluginKeyfile;
|
||||
typedef struct _SettingsPluginKeyfileClass SettingsPluginKeyfileClass;
|
||||
|
||||
GType settings_plugin_keyfile_get_type (void);
|
||||
|
||||
GObject *nm_settings_keyfile_plugin_new (void);
|
||||
|
||||
#endif /* __NMKF_PLUGIN_H__ */
|
@@ -14,7 +14,7 @@ AM_CPPFLAGS = \
|
||||
-I$(srcdir)/../ \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(CODE_COVERAGE_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \
|
||||
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \
|
||||
@@ -23,10 +23,7 @@ AM_CPPFLAGS = \
|
||||
noinst_PROGRAMS = test-keyfile
|
||||
|
||||
test_keyfile_SOURCES = \
|
||||
test-keyfile.c \
|
||||
../reader.c \
|
||||
../writer.c \
|
||||
../utils.c
|
||||
test-keyfile.c
|
||||
|
||||
test_keyfile_LDADD = \
|
||||
$(top_builddir)/src/libNetworkManager.la \
|
||||
|
@@ -30,9 +30,9 @@
|
||||
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
#include "utils.h"
|
||||
#include "nms-keyfile-reader.h"
|
||||
#include "nms-keyfile-writer.h"
|
||||
#include "nms-keyfile-utils.h"
|
||||
|
||||
#include "nm-test-utils-core.h"
|
||||
|
||||
@@ -69,7 +69,7 @@ keyfile_read_connection_from_file (const char *filename)
|
||||
|
||||
g_assert (filename);
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (filename, &error);
|
||||
connection = nms_keyfile_reader_from_file (filename, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
@@ -89,7 +89,7 @@ assert_reread (NMConnection *connection, gboolean normalize_connection, const ch
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
g_assert (testfile && testfile[0]);
|
||||
|
||||
reread = nm_keyfile_plugin_connection_from_file (testfile, p_error);
|
||||
reread = nms_keyfile_reader_from_file (testfile, p_error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (NM_IS_CONNECTION (reread));
|
||||
|
||||
@@ -127,7 +127,7 @@ write_test_connection (NMConnection *connection, char **testfile)
|
||||
owner_uid = geteuid ();
|
||||
owner_grp = getegid ();
|
||||
|
||||
success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, testfile, p_error);
|
||||
success = nms_keyfile_writer_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, testfile, p_error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (success);
|
||||
g_assert (*testfile && (*testfile)[0]);
|
||||
@@ -204,7 +204,7 @@ test_read_valid_wired_connection (void)
|
||||
"*ipv6.routes*semicolon at the end*routes1*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
|
||||
"*ipv6.route*semicolon at the end*route6*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert (connection);
|
||||
|
||||
@@ -465,7 +465,7 @@ test_read_ip6_wired_connection (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
g_assert_no_error (error);
|
||||
@@ -576,7 +576,7 @@ test_read_wired_mac_case (void)
|
||||
"*ipv4.addresses*semicolon at the end*addresses2*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
|
||||
"*ipv6.routes*semicolon at the end*routes1*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -608,7 +608,7 @@ test_read_mac_old_format (void)
|
||||
char expected_mac[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 };
|
||||
char expected_cloned_mac[ETH_ALEN] = { 0x00, 0x16, 0xaa, 0xbb, 0xcc, 0xfe };
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -642,7 +642,7 @@ test_read_mac_ib_old_format (void)
|
||||
0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89,
|
||||
0x90 };
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -671,7 +671,7 @@ test_read_valid_wireless_connection (void)
|
||||
const guint8 expected_bssid[ETH_ALEN] = { 0x00, 0x1a, 0x33, 0x44, 0x99, 0x82 };
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
g_assert_no_error (error);
|
||||
@@ -775,7 +775,7 @@ test_read_string_ssid (void)
|
||||
const char *expected_ssid = "blah blah ssid 1234";
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
g_assert_no_error (error);
|
||||
@@ -859,7 +859,7 @@ test_read_intlist_ssid (void)
|
||||
gsize ssid_len;
|
||||
const char *expected_ssid = "blah1234";
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -952,7 +952,7 @@ test_read_intlike_ssid (void)
|
||||
gsize ssid_len;
|
||||
const char *expected_ssid = "101";
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -983,7 +983,7 @@ test_read_intlike_ssid_2 (void)
|
||||
gsize ssid_len;
|
||||
const char *expected_ssid = "11;12;13;";
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -1132,7 +1132,7 @@ test_read_bt_dun_connection (void)
|
||||
const guint8 expected_bdaddr[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
g_assert_no_error (error);
|
||||
@@ -1235,7 +1235,7 @@ test_read_gsm_connection (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
|
||||
@@ -1340,7 +1340,7 @@ test_read_wired_8021x_tls_blob_connection (void)
|
||||
"*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -1399,7 +1399,7 @@ test_read_wired_8021x_tls_bad_path_connection (void)
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*does not exist*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
@@ -1457,7 +1457,7 @@ test_read_wired_8021x_tls_old_connection (void)
|
||||
"*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -1503,7 +1503,7 @@ test_read_wired_8021x_tls_new_connection (void)
|
||||
char *tmp2;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -1645,7 +1645,7 @@ test_write_wired_8021x_tls_connection_path (void)
|
||||
write_test_connection (connection, &testfile);
|
||||
|
||||
/* Read the connection back in and compare it to the one we just wrote out */
|
||||
reread = nm_keyfile_plugin_connection_from_file (testfile, &error);
|
||||
reread = nms_keyfile_reader_from_file (testfile, &error);
|
||||
if (!reread) {
|
||||
g_assert (error);
|
||||
g_warning ("Failed to re-read test connection: %s", error->message);
|
||||
@@ -1753,7 +1753,7 @@ test_write_wired_8021x_tls_connection_blob (void)
|
||||
g_assert (g_file_test (new_priv_key, G_FILE_TEST_EXISTS));
|
||||
|
||||
/* Read the connection back in and compare it to the one we just wrote out */
|
||||
reread = nm_keyfile_plugin_connection_from_file (testfile, &error);
|
||||
reread = nms_keyfile_reader_from_file (testfile, &error);
|
||||
if (!reread) {
|
||||
g_assert (error);
|
||||
g_warning ("Failed to re-read test connection: %s", error->message);
|
||||
@@ -1800,7 +1800,7 @@ test_read_infiniband_connection (void)
|
||||
const char *expected_uuid = "4e80a56d-c99f-4aad-a6dd-b449bc398c57";
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -1886,7 +1886,7 @@ test_read_bridge_main (void)
|
||||
const char *expected_uuid = "8f061643-fe41-4d4c-a8d9-097d26e2ad3a";
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -1983,7 +1983,7 @@ test_read_bridge_component (void)
|
||||
const char *expected_uuid = "d7b4f96c-c45e-4298-bef8-f48574f8c1c0";
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2073,7 +2073,7 @@ test_read_new_wired_group_name (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2155,7 +2155,7 @@ test_read_new_wireless_group_names (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2262,7 +2262,7 @@ test_read_missing_vlan_setting (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2284,7 +2284,7 @@ test_read_missing_vlan_flags (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2307,7 +2307,7 @@ test_read_missing_id_uuid (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2411,7 +2411,7 @@ test_read_enum_property (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2471,7 +2471,7 @@ test_read_flags_property (void)
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error);
|
||||
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
success = nm_connection_verify (connection, &error);
|
||||
@@ -2530,18 +2530,18 @@ _escape_filename (const char *filename, gboolean would_be_ignored)
|
||||
|
||||
g_assert (filename && filename[0]);
|
||||
|
||||
if (!!would_be_ignored != !!nm_keyfile_plugin_utils_should_ignore_file (filename)) {
|
||||
if (!!would_be_ignored != !!nms_keyfile_utils_should_ignore_file (filename)) {
|
||||
if (would_be_ignored)
|
||||
g_error ("We expect filename \"%s\" to be ignored, but it isn't", filename);
|
||||
else
|
||||
g_error ("We expect filename \"%s\" not to be ignored, but it is", filename);
|
||||
}
|
||||
|
||||
esc = nm_keyfile_plugin_utils_escape_filename (filename);
|
||||
esc = nms_keyfile_utils_escape_filename (filename);
|
||||
g_assert (esc && esc[0]);
|
||||
g_assert (!strchr (esc, '/'));
|
||||
|
||||
if (nm_keyfile_plugin_utils_should_ignore_file (esc))
|
||||
if (nms_keyfile_utils_should_ignore_file (esc))
|
||||
g_error ("Escaping filename \"%s\" yielded \"%s\", but this is ignored", filename, esc);
|
||||
}
|
||||
|
||||
|
@@ -1,42 +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 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _UTILS_H_
|
||||
#define _UTILS_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) ((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))
|
||||
#define NM_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
|
||||
#define NM_KEYFILE_CONNECTION_LOG_ARGD(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)), (con)
|
||||
|
||||
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_ */
|
||||
|
Reference in New Issue
Block a user