ifcfg-rh: move reader/writer to separate utility library

This commit is contained in:
Dan Williams
2009-02-28 07:08:19 -05:00
parent 984b07d5ea
commit 2285838cbb
6 changed files with 76 additions and 33 deletions

View File

@@ -1,25 +1,40 @@
pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la
libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ noinst_LTLIBRARIES = libifcfg-rh-io.la
libifcfg_rh_io_la_SOURCES = \
shvar.c \ shvar.c \
shvar.h \ shvar.h \
reader.c \
reader.h \
sha1.c \
sha1.h \
errors.c \
common.h
libifcfg_rh_io_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-util \
-DSYSCONFDIR=\"$(sysconfdir)\"
libifcfg_rh_io_la_LIBADD = $(GLIB_LIBS)
libnm_settings_plugin_ifcfg_rh_la_SOURCES = \
plugin.c \ plugin.c \
plugin.h \ plugin.h \
nm-ifcfg-connection.c \ nm-ifcfg-connection.c \
nm-ifcfg-connection.h \ nm-ifcfg-connection.h
reader.c \
reader.h \
common.h \
sha1.c \
sha1.h
libnm_settings_plugin_ifcfg_rh_la_CPPFLAGS = \ libnm_settings_plugin_ifcfg_rh_la_CPPFLAGS = \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \ $(GMODULE_CFLAGS) \
$(DBUS_CFLAGS) \ $(DBUS_CFLAGS) \
-DG_DISABLE_DEPRECATED \ -DG_DISABLE_DEPRECATED \
-I${top_srcdir}/system-settings/src \ -I$(top_srcdir)/system-settings/src \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-glib \ -I$(top_srcdir)/libnm-glib \
-I$(top_srcdir)/libnm-util \ -I$(top_srcdir)/libnm-util \
@@ -32,7 +47,8 @@ libnm_settings_plugin_ifcfg_rh_la_LIBADD = \
$(GMODULE_LIBS) \ $(GMODULE_LIBS) \
$(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)/marshallers/libmarshallers.la $(top_builddir)/marshallers/libmarshallers.la \
libifcfg-rh-io.la
if NO_GIO if NO_GIO
libnm_settings_plugin_ifcfg_rh_la_LIBADD += \ libnm_settings_plugin_ifcfg_rh_la_LIBADD += \

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* (C) Copyright 2008 Red Hat, Inc. * (C) Copyright 2008 - 2009 Red Hat, Inc.
*/ */
#ifndef __COMMON_H__ #ifndef __COMMON_H__

View 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 - 2009 Red Hat, Inc.
*/
#include <glib.h>
#include "common.h"
GQuark
ifcfg_plugin_error_quark (void)
{
static GQuark error_quark = 0;
if (G_UNLIKELY (error_quark == 0))
error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark");
return error_quark;
}

View File

@@ -87,17 +87,6 @@ typedef struct {
} SCPluginIfcfgPrivate; } SCPluginIfcfgPrivate;
GQuark
ifcfg_plugin_error_quark (void)
{
static GQuark error_quark = 0;
if (G_UNLIKELY (error_quark == 0))
error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark");
return error_quark;
}
static void static void
check_unmanaged (gpointer key, gpointer data, gpointer user_data) check_unmanaged (gpointer key, gpointer data, gpointer user_data)
{ {

View File

@@ -46,7 +46,5 @@ struct _SCPluginIfcfgClass {
GType sc_plugin_ifcfg_get_type (void); GType sc_plugin_ifcfg_get_type (void);
GQuark ifcfg_plugin_error_quark (void);
#endif /* _PLUGIN_H_ */ #endif /* _PLUGIN_H_ */

View File

@@ -53,7 +53,12 @@
#include "sha1.h" #include "sha1.h"
#include "reader.h" #include "reader.h"
#include "nm-system-config-interface.h"
#define PLUGIN_PRINT(pname, fmt, args...) \
{ g_message (" " pname ": " fmt, ##args); }
#define PLUGIN_WARN(pname, fmt, args...) \
{ g_warning (" " pname ": " fmt, ##args); }
#define TYPE_ETHERNET "Ethernet" #define TYPE_ETHERNET "Ethernet"
#define TYPE_WIRELESS "Wireless" #define TYPE_WIRELESS "Wireless"
@@ -143,7 +148,7 @@ make_connection_setting (const char *file,
if (errno == 0) if (errno == 0)
g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, tmp, NULL); g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, tmp, NULL);
else else
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: invalid LAST_CONNECT time"); PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid LAST_CONNECT time");
g_free (value); g_free (value);
} }
@@ -188,7 +193,7 @@ get_one_ip4_addr (shvarFile *ifcfg,
goto error; \ goto error; \
if (dns) { \ if (dns) { \
if (!nm_setting_ip4_config_add_dns (s_ip4, dns)) \ if (!nm_setting_ip4_config_add_dns (s_ip4, dns)) \
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: duplicate DNS server %s", tag); \ PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate DNS server %s", tag); \
} \ } \
} }
@@ -339,7 +344,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
if (addr) { if (addr) {
if (!nm_setting_ip4_config_add_address (s_ip4, addr)) if (!nm_setting_ip4_config_add_address (s_ip4, addr))
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: duplicate IP4 address"); PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate IP4 address");
} }
GET_ONE_DNS("DNS1"); GET_ONE_DNS("DNS1");
@@ -357,7 +362,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
for (item = searches; *item; item++) { for (item = searches; *item; item++) {
if (strlen (*item)) { if (strlen (*item)) {
if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item)) if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item))
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: duplicate DNS domain '%s'", *item); PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate DNS domain '%s'", *item);
} }
} }
g_strfreev (searches); g_strfreev (searches);
@@ -377,7 +382,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
for (item = searches; *item; item++) { for (item = searches; *item; item++) {
if (strlen (*item)) { if (strlen (*item)) {
if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item)) if (!nm_setting_ip4_config_add_dns_search (s_ip4, *item))
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: duplicate DNS search '%s'", *item); PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate DNS search '%s'", *item);
} }
} }
g_strfreev (searches); g_strfreev (searches);
@@ -730,7 +735,7 @@ fill_wpa_ciphers (shvarFile *ifcfg,
else if (group && !strcmp (*iter, "WEP40")) else if (group && !strcmp (*iter, "WEP40"))
nm_setting_wireless_security_add_group (wsec, "wep40"); nm_setting_wireless_security_add_group (wsec, "wep40");
else { else {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: ignoring invalid %s cipher '%s'", PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring invalid %s cipher '%s'",
group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE", group ? "CIPHER_GROUP" : "CIPHER_PAIRWISE",
*iter); *iter);
} }
@@ -1099,7 +1104,7 @@ make_wired_setting (shvarFile *ifcfg, gboolean unmanaged, GError **error)
g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu, NULL); g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu, NULL);
} else { } else {
/* Shouldn't be fatal... */ /* Shouldn't be fatal... */
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " warning: invalid MTU '%s'", value); PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid MTU '%s'", value);
} }
g_free (value); g_free (value);
} }