keyfile: clean up directory structure
The IO library was in io/ because I was too lazy to find autotools' SUBDIRS rules at the time and that you could use '.' for the current directory. Fix that and use its own error defines instead of the system settings service. Clean up a for more things for good measure too (like KEYFILE_DIR, etc).
This commit is contained in:
@@ -521,7 +521,6 @@ system-settings/plugins/ifcfg-rh/tests/Makefile
|
|||||||
system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile
|
system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile
|
||||||
system-settings/plugins/ifcfg-suse/Makefile
|
system-settings/plugins/ifcfg-suse/Makefile
|
||||||
system-settings/plugins/keyfile/Makefile
|
system-settings/plugins/keyfile/Makefile
|
||||||
system-settings/plugins/keyfile/io/Makefile
|
|
||||||
system-settings/plugins/keyfile/tests/Makefile
|
system-settings/plugins/keyfile/tests/Makefile
|
||||||
system-settings/plugins/keyfile/tests/keyfiles/Makefile
|
system-settings/plugins/keyfile/tests/keyfiles/Makefile
|
||||||
cli/Makefile
|
cli/Makefile
|
||||||
|
@@ -1,36 +1,49 @@
|
|||||||
SUBDIRS=io tests
|
SUBDIRS=. tests
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir)/src/system-settings \
|
-I$(top_srcdir)/src/system-settings \
|
||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_srcdir)/libnm-util \
|
-I$(top_srcdir)/libnm-util \
|
||||||
-I$(top_srcdir)/libnm-glib \
|
-I$(top_srcdir)/libnm-glib
|
||||||
-I$(top_srcdir)/system-settings/plugins/keyfile/io
|
|
||||||
|
|
||||||
pkglib_LTLIBRARIES = libnm-settings-plugin-keyfile.la
|
pkglib_LTLIBRARIES = libnm-settings-plugin-keyfile.la
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libkeyfile-io.la
|
||||||
|
|
||||||
|
libkeyfile_io_la_SOURCES = \
|
||||||
|
reader.c \
|
||||||
|
reader.h \
|
||||||
|
writer.c \
|
||||||
|
writer.h \
|
||||||
|
errors.c \
|
||||||
|
common.h
|
||||||
|
|
||||||
|
libkeyfile_io_la_CPPFLAGS = \
|
||||||
|
$(GLIB_CFLAGS) \
|
||||||
|
$(DBUS_CFLAGS) \
|
||||||
|
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||||
|
-DG_DISABLE_DEPRECATED
|
||||||
|
|
||||||
|
libkeyfile_io_la_LIBADD = $(GLIB_LIBS)
|
||||||
|
|
||||||
libnm_settings_plugin_keyfile_la_SOURCES = \
|
libnm_settings_plugin_keyfile_la_SOURCES = \
|
||||||
nm-keyfile-connection.c \
|
nm-keyfile-connection.c \
|
||||||
nm-keyfile-connection.h \
|
nm-keyfile-connection.h \
|
||||||
plugin.c \
|
plugin.c \
|
||||||
plugin.h
|
plugin.h
|
||||||
|
|
||||||
keyfiledir=$(sysconfdir)/NetworkManager/system-connections
|
|
||||||
|
|
||||||
libnm_settings_plugin_keyfile_la_CPPFLAGS = \
|
libnm_settings_plugin_keyfile_la_CPPFLAGS = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
$(GMODULE_CFLAGS) \
|
$(GMODULE_CFLAGS) \
|
||||||
$(DBUS_CFLAGS) \
|
$(DBUS_CFLAGS) \
|
||||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||||
-DG_DISABLE_DEPRECATED \
|
-DG_DISABLE_DEPRECATED
|
||||||
-DKEYFILE_DIR=\""$(keyfiledir)"\" \
|
|
||||||
-DKEYFILE_PLUGIN_NAME=\""keyfile"\"
|
|
||||||
|
|
||||||
libnm_settings_plugin_keyfile_la_LDFLAGS = -module -avoid-version
|
libnm_settings_plugin_keyfile_la_LDFLAGS = -module -avoid-version
|
||||||
libnm_settings_plugin_keyfile_la_LIBADD = \
|
libnm_settings_plugin_keyfile_la_LIBADD = \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||||
$(top_builddir)/system-settings/plugins/keyfile/io/libkeyfile-io.la \
|
libkeyfile-io.la \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(GMODULE_LIBS) \
|
$(GMODULE_LIBS) \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
|
37
system-settings/plugins/keyfile/common.h
Normal file
37
system-settings/plugins/keyfile/common.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* -*- 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 - 2010 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COMMON_H__
|
||||||
|
#define __COMMON_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#define KEYFILE_PLUGIN_NAME "keyfile"
|
||||||
|
#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2010 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
|
||||||
|
|
||||||
|
#define KEYFILE_DIR SYSCONFDIR "/NetworkManager/system-connections"
|
||||||
|
|
||||||
|
#define VPN_SECRETS_GROUP "vpn-secrets"
|
||||||
|
|
||||||
|
#define KEYFILE_PLUGIN_ERROR (keyfile_plugin_error_quark ())
|
||||||
|
GQuark keyfile_plugin_error_quark (void);
|
||||||
|
|
||||||
|
#endif /* __COMMON_H__ */
|
||||||
|
|
35
system-settings/plugins/keyfile/errors.c
Normal file
35
system-settings/plugins/keyfile/errors.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* -*- 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 - 2010 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
GQuark
|
||||||
|
keyfile_plugin_error_quark (void)
|
||||||
|
{
|
||||||
|
static GQuark error_quark = 0;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (error_quark == 0))
|
||||||
|
error_quark = g_quark_from_static_string ("keyfile-plugin-error-quark");
|
||||||
|
|
||||||
|
return error_quark;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@@ -1,20 +0,0 @@
|
|||||||
INCLUDES = \
|
|
||||||
-I$(top_srcdir)/system-settings/src \
|
|
||||||
-I$(top_srcdir)/include \
|
|
||||||
-I$(top_srcdir)/libnm-util \
|
|
||||||
-I$(top_srcdir)/libnm-glib
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libkeyfile-io.la
|
|
||||||
|
|
||||||
libkeyfile_io_la_SOURCES = \
|
|
||||||
reader.h \
|
|
||||||
reader.c \
|
|
||||||
writer.h \
|
|
||||||
writer.c
|
|
||||||
|
|
||||||
libkeyfile_io_la_CPPFLAGS = \
|
|
||||||
$(GLIB_CFLAGS) \
|
|
||||||
$(DBUS_CFLAGS)
|
|
||||||
|
|
||||||
libkeyfile_io_la_LIBADD = $(GLIB_LIBS)
|
|
||||||
|
|
@@ -31,6 +31,7 @@
|
|||||||
#include "nm-keyfile-connection.h"
|
#include "nm-keyfile-connection.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
static NMSettingsConnectionInterface *parent_settings_connection_iface;
|
static NMSettingsConnectionInterface *parent_settings_connection_iface;
|
||||||
|
|
||||||
|
@@ -38,9 +38,7 @@
|
|||||||
#include "nm-system-config-interface.h"
|
#include "nm-system-config-interface.h"
|
||||||
#include "nm-keyfile-connection.h"
|
#include "nm-keyfile-connection.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
#include "common.h"
|
||||||
#define KEYFILE_PLUGIN_NAME "keyfile"
|
|
||||||
#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2010 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
|
|
||||||
|
|
||||||
#define CONF_FILE SYSCONFDIR "/NetworkManager/NetworkManager.conf"
|
#define CONF_FILE SYSCONFDIR "/NetworkManager/NetworkManager.conf"
|
||||||
#define OLD_CONF_FILE SYSCONFDIR "/NetworkManager/nm-system-settings.conf"
|
#define OLD_CONF_FILE SYSCONFDIR "/NetworkManager/nm-system-settings.conf"
|
||||||
|
@@ -40,10 +40,10 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/ether.h>
|
#include <netinet/ether.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <nm-settings-interface.h>
|
|
||||||
|
|
||||||
#include "nm-dbus-glib-types.h"
|
#include "nm-dbus-glib-types.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
read_array_of_uint (GKeyFile *file,
|
read_array_of_uint (GKeyFile *file,
|
||||||
@@ -1004,9 +1004,7 @@ connection_from_file (const char *filename, GError **error)
|
|||||||
GError *verify_error = NULL;
|
GError *verify_error = NULL;
|
||||||
|
|
||||||
if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) {
|
if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"File did not exist or was not a regular file");
|
"File did not exist or was not a regular file");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1015,9 +1013,7 @@ connection_from_file (const char *filename, GError **error)
|
|||||||
bad_permissions = statbuf.st_mode & 0077;
|
bad_permissions = statbuf.st_mode & 0077;
|
||||||
|
|
||||||
if (bad_owner || bad_permissions) {
|
if (bad_owner || bad_permissions) {
|
||||||
g_set_error (error,
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"File permissions (%o) or owner (%d) were insecure",
|
"File permissions (%o) or owner (%d) were insecure",
|
||||||
statbuf.st_mode, statbuf.st_uid);
|
statbuf.st_mode, statbuf.st_uid);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1096,9 +1092,7 @@ connection_from_file (const char *filename, GError **error)
|
|||||||
|
|
||||||
/* Verify the connection */
|
/* Verify the connection */
|
||||||
if (!nm_connection_verify (connection, &verify_error)) {
|
if (!nm_connection_verify (connection, &verify_error)) {
|
||||||
g_set_error (error,
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"invalid or missing connection property '%s'",
|
"invalid or missing connection property '%s'",
|
||||||
(verify_error && verify_error->message) ? verify_error->message : "(unknown)");
|
(verify_error && verify_error->message) ? verify_error->message : "(unknown)");
|
||||||
g_clear_error (&verify_error);
|
g_clear_error (&verify_error);
|
@@ -22,8 +22,6 @@
|
|||||||
#ifndef _KEYFILE_PLUGIN_READER_H
|
#ifndef _KEYFILE_PLUGIN_READER_H
|
||||||
#define _KEYFILE_PLUGIN_READER_H
|
#define _KEYFILE_PLUGIN_READER_H
|
||||||
|
|
||||||
#define VPN_SECRETS_GROUP "vpn-secrets"
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <nm-connection.h>
|
#include <nm-connection.h>
|
||||||
|
|
@@ -4,7 +4,7 @@ INCLUDES = \
|
|||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_srcdir)/libnm-util \
|
-I$(top_srcdir)/libnm-util \
|
||||||
-I$(top_srcdir)/libnm-glib \
|
-I$(top_srcdir)/libnm-glib \
|
||||||
-I$(top_srcdir)/system-settings/plugins/keyfile/io
|
-I$(top_srcdir)/system-settings/plugins/keyfile
|
||||||
|
|
||||||
noinst_PROGRAMS = test-keyfile
|
noinst_PROGRAMS = test-keyfile
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ test_keyfile_CPPFLAGS = \
|
|||||||
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\"
|
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\"
|
||||||
|
|
||||||
test_keyfile_LDADD = \
|
test_keyfile_LDADD = \
|
||||||
$(top_builddir)/system-settings/plugins/keyfile/io/libkeyfile-io.la \
|
$(top_builddir)/system-settings/plugins/keyfile/libkeyfile-io.la \
|
||||||
$(top_builddir)/libnm-glib/libnm-glib.la \
|
$(top_builddir)/libnm-glib/libnm-glib.la \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
$(DBUS_LIBS)
|
$(DBUS_LIBS)
|
||||||
|
@@ -36,11 +36,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/ether.h>
|
#include <netinet/ether.h>
|
||||||
#include <nm-settings-interface.h>
|
|
||||||
|
|
||||||
#include "nm-dbus-glib-types.h"
|
#include "nm-dbus-glib-types.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
#include "reader.h"
|
#include "common.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_array_of_uint (GKeyFile *file,
|
write_array_of_uint (GKeyFile *file,
|
||||||
@@ -667,18 +666,14 @@ write_connection (NMConnection *connection,
|
|||||||
|
|
||||||
g_file_set_contents (path, data, len, error);
|
g_file_set_contents (path, data, len, error);
|
||||||
if (chown (path, owner_uid, owner_grp) < 0) {
|
if (chown (path, owner_uid, owner_grp) < 0) {
|
||||||
g_set_error (error,
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"%s.%d: error chowning '%s': %d", __FILE__, __LINE__,
|
"%s.%d: error chowning '%s': %d", __FILE__, __LINE__,
|
||||||
path, errno);
|
path, errno);
|
||||||
unlink (path);
|
unlink (path);
|
||||||
} else {
|
} else {
|
||||||
err = chmod (path, S_IRUSR | S_IWUSR);
|
err = chmod (path, S_IRUSR | S_IWUSR);
|
||||||
if (err) {
|
if (err) {
|
||||||
g_set_error (error,
|
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"%s.%d: error setting permissions on '%s': %d", __FILE__,
|
"%s.%d: error setting permissions on '%s': %d", __FILE__,
|
||||||
__LINE__, path, errno);
|
__LINE__, path, errno);
|
||||||
unlink (path);
|
unlink (path);
|
Reference in New Issue
Block a user