Commit 74641be8 authored by Thomas Haller's avatar Thomas Haller

settings: drop ibft settings plugin

The functionality of the ibft settings plugin is now handled by
nm-initrd-generator. There is no need for it anymore, drop it.

Note that ibft called iscsiadm, which requires CAP_SYS_ADMIN to work
([1]). We really want to drop this capability, so the current solution
of a settings plugin (as it is implemented) is wrong. The solution
instead is nm-initrd-generator.

Also, on Fedora the ibft was disabled and probably on most other
distributions as well. This was only used on RHEL.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1371201#c7
parent f182d4fa
Pipeline #43937 passed with stages
in 68 minutes and 49 seconds
......@@ -232,7 +232,6 @@ test-*.trs
/src/platform/tests/test-platform-general
/src/platform/tests/test-route-fake
/src/platform/tests/test-route-linux
/src/settings/plugins/ibft/tests/test-ibft
/src/settings/plugins/ifcfg-rh/nmdbus-ifcfg-rh.[ch]
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
/src/settings/plugins/ifupdown/tests/test-ifupdown
......@@ -334,6 +333,7 @@ test-*.trs
/src/platform/tests/platform
/src/platform/tests/test-general
/src/rdisc/
/src/settings/plugins/ibft/tests/test-ibft
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils
/src/settings/plugins/ifnet
/src/settings/plugins/keyfile/tests/test-keyfile
......
......@@ -141,7 +141,6 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-wext=no \
--enable-ifcfg-rh \
--enable-ifupdown \
--enable-config-plugin-ibft \
--disable-dependency-tracking \
$(NULL)
......@@ -2714,76 +2713,6 @@ EXTRA_DIST += \
\
src/settings/plugins/keyfile/tests/meson.build
###############################################################################
# src/settings/plugins/ibft
###############################################################################
if CONFIG_PLUGIN_IBFT
core_plugins += src/settings/plugins/ibft/libnm-settings-plugin-ibft.la
noinst_LTLIBRARIES += src/settings/plugins/ibft/libnms-ibft-core.la
src_settings_plugins_ibft_libnms_ibft_core_la_CPPFLAGS = $(src_cppflags_base)
src_settings_plugins_ibft_libnms_ibft_core_la_SOURCES = \
src/settings/plugins/ibft/nms-ibft-reader.c \
src/settings/plugins/ibft/nms-ibft-reader.h
$(src_settings_plugins_ibft_libnms_ibft_core_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
src_settings_plugins_ibft_libnm_settings_plugin_ibft_la_SOURCES = \
src/settings/plugins/ibft/nms-ibft-plugin.c \
src/settings/plugins/ibft/nms-ibft-plugin.h \
src/settings/plugins/ibft/nms-ibft-connection.c \
src/settings/plugins/ibft/nms-ibft-connection.h
src_settings_plugins_ibft_libnm_settings_plugin_ibft_la_CPPFLAGS = $(src_cppflags_base)
src_settings_plugins_ibft_libnm_settings_plugin_ibft_la_LDFLAGS = \
-module -avoid-version \
-Wl,--version-script="$(srcdir)/linker-script-settings.ver"
src_settings_plugins_ibft_libnm_settings_plugin_ibft_la_LIBADD = \
src/settings/plugins/ibft/libnms-ibft-core.la
$(src_settings_plugins_ibft_libnm_settings_plugin_ibft_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
check_programs += src/settings/plugins/ibft/tests/test-ibft
src_settings_plugins_ibft_tests_test_ibft_CPPFLAGS = $(src_cppflags_base_test)
src_settings_plugins_ibft_tests_test_ibft_LDFLAGS = \
$(GLIB_LIBS) \
$(CODE_COVERAGE_LDFLAGS) \
$(SANITIZER_EXEC_LDFLAGS)
src_settings_plugins_ibft_tests_test_ibft_LDADD = \
src/settings/plugins/ibft/libnms-ibft-core.la \
src/libNetworkManagerTest.la
$(src_settings_plugins_ibft_tests_test_ibft_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
check-local-symbols-settings-ibft: src/settings/plugins/ibft/libnm-settings-plugin-ibft.la
$(call check_so_symbols,$(builddir)/src/settings/plugins/ibft/.libs/libnm-settings-plugin-ibft.so)
check_local += check-local-symbols-settings-ibft
endif
EXTRA_DIST += \
src/settings/plugins/ibft/tests/iscsiadm-test-dhcp \
src/settings/plugins/ibft/tests/iscsiadm-test-static \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-ipaddr \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-gateway \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-dns1 \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-dns2 \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-entry \
src/settings/plugins/ibft/tests/iscsiadm-test-bad-record \
src/settings/plugins/ibft/tests/iscsiadm-test-vlan \
src/settings/plugins/ibft/meson.build \
src/settings/plugins/ibft/tests/meson.build
###############################################################################
# src/settings/plugins/ifcfg-rh
###############################################################################
......
......@@ -23,6 +23,8 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
* Rework parsing team JSON config in libnm and stricter validate settings.
With this NetworkManager rejects settings that it considers invalid while
still allowing setting arbitrary JSON config directly.
* Drop ibft settings plugin. This functionality is now covered by using
nm-initrd-generator from initrd to pre-generate in-memory profiles.
=============================================
NetworkManager-1.18
......
......@@ -212,9 +212,6 @@
/* Define if you have PPP support */
#mesondefine WITH_PPP
/* Whether compilation of ibft setting plugin is enabled */
#mesondefine WITH_SETTINGS_PLUGIN_IBFT
/* Define if you have iwd support */
#mesondefine WITH_IWD
......
......@@ -138,7 +138,6 @@ AC_GNU_SOURCE
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
# Alternative configuration plugins
AC_ARG_ENABLE(config-plugin-ibft, AS_HELP_STRING([--enable-config-plugin-ibft], [enable ibft configuration plugin]))
AC_ARG_ENABLE(ifcfg-rh, AS_HELP_STRING([--enable-ifcfg-rh], [enable ifcfg-rh configuration plugin (Fedora/RHEL)]))
AC_ARG_ENABLE(ifupdown, AS_HELP_STRING([--enable-ifupdown], [enable ifupdown configuration plugin (Debian/Ubuntu)]))
# Default alternative plugins by distribution
......@@ -147,10 +146,7 @@ AS_IF([test -z "$enable_ifupdown" -a -f /etc/debian_version], enable_
# Otherwise plugins default to "no"
AS_IF([test -z "$enable_ifcfg_rh"], enable_ifcfg_rh=no)
AS_IF([test -z "$enable_ifupdown"], enable_ifupdown=no)
# Disable obsolete ibft plugin by default
AS_IF([test -z "$enable_config_plugin_ibft"], enable_config_plugin_ibft="no")
# Create automake conditionals
AM_CONDITIONAL(CONFIG_PLUGIN_IBFT, test "$enable_config_plugin_ibft" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFCFG_RH, test "$enable_ifcfg_rh" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFUPDOWN, test "$enable_ifupdown" = "yes")
......@@ -162,7 +158,6 @@ if test -z "$config_plugins_default" -o "$config_plugins_default" = no; then
config_plugins_default=''
test "$enable_ifcfg_rh" = "yes" && config_plugins_default="$config_plugins_default,ifcfg-rh"
test "$enable_ifupdown" = "yes" && config_plugins_default="$config_plugins_default,ifupdown"
test "$enable_config_plugin_ibft" = "yes" && config_plugins_default="$config_plugins_default,ibft"
config_plugins_default="${config_plugins_default#,}"
fi
......@@ -171,11 +166,6 @@ test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifu
distro_plugins="${distro_plugins#,}"
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_MAIN_PLUGINS, "$config_plugins_default", [Default configuration option for main.plugins setting])
if test "${enable_config_plugin_ibft}" = yes; then
AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 1, [Whether compilation of ibft setting plugin is enabled])
else
AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 0, [Whether compilation of ibft setting plugin is enabled])
fi
if test "$enable_ifcfg_rh" = "yes"; then
DISTRO_NETWORK_SERVICE=network.service
......@@ -1303,7 +1293,6 @@ echo " iwd: $ac_with_iwd"
echo
echo "Configuration plugins (main.plugins=${config_plugins_default})"
echo " ibft: ${enable_config_plugin_ibft}"
echo " ifcfg-rh: ${enable_ifcfg_rh}"
echo " ifupdown: ${enable_ifupdown}"
echo
......
......@@ -106,13 +106,7 @@
%global dns_rc_manager_default file
%endif
%if 0%{?rhel}
%global config_plugins_default ifcfg-rh,ibft
%global ibft_enabled yes
%else
%global config_plugins_default ifcfg-rh
%global ibft_enabled no
%endif
%if 0%{?fedora}
# Altough eBPF would be available on Fedora's kernel, it seems
......@@ -573,11 +567,6 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
-Dtests=yes \
-Dvalgrind=no \
-Difcfg_rh=true \
%if %{ibft_enabled} != yes
-Dibft=false \
%else
-Dibft=true \
%endif
-Difupdown=false \
%if %{with ppp}
-Dpppd_plugin_dir=%{_libdir}/pppd/%{ppp_version} \
......@@ -695,7 +684,6 @@ intltoolize --automake --copy --force
%endif
--with-valgrind=no \
--enable-ifcfg-rh=yes \
--enable-config-plugin-ibft=%{ibft_enabled} \
--enable-ifupdown=no \
%if %{with ppp}
--with-pppd-plugin-dir=%{_libdir}/pppd/%{ppp_version} \
......
......@@ -150,7 +150,6 @@ if [[ $NO_DIST != 1 ]]; then
--enable-introspection \
--enable-ifcfg-rh \
--enable-ifupdown \
--enable-config-plugin-ibft \
--with-config-logging-backend-default=syslog \
--with-libaudit=yes-disabled-by-default \
--enable-polkit=yes \
......
......@@ -163,7 +163,6 @@ run_autotools() {
--with-resolvconf=/bin/nowhere/resolvconf \
\
--enable-ifcfg-rh=yes \
--enable-config-plugin-ibft=yes \
--enable-ifupdown=yes \
\
#end
......@@ -240,7 +239,6 @@ run_meson() {
-D resolvconf=/bin/nowhere/resolvconf \
\
-D ifcfg_rh=false \
-D ibft=true \
-D ifupdown=true \
\
#end
......
......@@ -16,9 +16,6 @@ Restart=on-failure
KillMode=process
CapabilityBoundingSet=CAP_NET_ADMIN CAP_DAC_OVERRIDE CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_MODULE CAP_AUDIT_WRITE CAP_KILL CAP_SYS_CHROOT
# ibft settings plugin calls iscsiadm which needs CAP_SYS_ADMIN
#CapabilityBoundingSet=CAP_SYS_ADMIN
ProtectSystem=true
ProtectHome=read-only
......
......@@ -1323,17 +1323,8 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
<term><varname>ibft</varname>, <varname>no-ibft</varname></term>
<listitem>
<para>
This plugin allows to read iBFT configuration (iSCSI Boot Firmware Table).
The configuration is read using <filename>/sbin/iscsiadm</filename>. Users are
expected to configure iBFT connections via the firmware interfaces.
If ibft support is available, it is automatically enabled after
<literal>ifcfg-rh</literal>. This can be disabled by <literal>no-ibft</literal>.
You can also explicitly specify <literal>ibft</literal> to load the
plugin without <literal>ifcfg-rh</literal> or to change the plugin order.
</para>
<para>
Note that ibft plugin uses <filename>/sbin/iscsiadm</filename> and thus requires
CAP_SYS_ADMIN capability.
These plugins are deprecated and their selection has no effect.
This is now handled by nm-initrd-generator.
</para>
</listitem>
</varlistentry>
......
......@@ -233,9 +233,6 @@ endif
enable_ifcfg_rh = get_option('ifcfg_rh') or (distro == 'redhat')
enable_ifupdown = get_option('ifupdown') or (distro == 'debian')
enable_ibft = get_option('ibft')
config_h.set10('WITH_SETTINGS_PLUGIN_IBFT', enable_ibft)
config_plugins_default = get_option('config_plugins_default')
if config_plugins_default == ''
......@@ -249,10 +246,6 @@ if config_plugins_default == ''
config_plugins += ['ifupdown']
endif
if enable_ibft
config_plugins += ['ibft']
endif
config_plugins_default = ','.join(config_plugins)
endif
config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_PLUGINS', config_plugins_default)
......@@ -937,7 +930,6 @@ output += ' ovs: ' + enable_ovs.to_string() + '\n'
output += ' nmcli: ' + enable_nmcli.to_string() + '\n'
output += ' nmtui: ' + enable_nmtui.to_string() + '\n'
output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')\n'
output += ' ibft: ' + enable_ibft.to_string() + '\n'
output += ' ifcfg-rh: ' + enable_ifcfg_rh.to_string() + '\n'
output += ' ifupdown: ' + enable_ifupdown.to_string() + '\n'
output += '\nHandlers for /etc/resolv.conf:\n' + resolv_conf_summary
......
......@@ -41,7 +41,6 @@ option('ebpf', type: 'combo', choices : ['auto', 'true', 'false'], description:
# configuration plugins
option('config_plugins_default', type: 'string', value: '', description: 'Default configuration option for main.plugins setting, used as fallback if the configuration option is unset')
option('ibft', type: 'boolean', value: false, description: 'enable ibft configuration plugin')
option('ifcfg_rh', type: 'boolean', value: false, description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL)')
option('ifupdown', type: 'boolean', value: false, description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
......
......@@ -172,6 +172,5 @@ src/nm-config.c
src/nm-iface-helper.c
src/nm-logging.c
src/nm-manager.c
src/settings/plugins/ibft/nms-ibft-plugin.c
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
......@@ -1341,16 +1341,6 @@ load_plugins (NMSettings *self, const char *const*plugins, GError **error)
{
const char *const*iter;
gboolean success = TRUE;
gboolean add_ibft = FALSE;
gboolean has_no_ibft;
gssize idx_no_ibft, idx_ibft;
idx_ibft = nm_utils_strv_find_first ((char **) plugins, -1, "ibft");
idx_no_ibft = nm_utils_strv_find_first ((char **) plugins, -1, "no-ibft");
has_no_ibft = idx_no_ibft >= 0 && idx_no_ibft > idx_ibft;
#if WITH_SETTINGS_PLUGIN_IBFT
add_ibft = idx_no_ibft < 0 && idx_ibft < 0;
#endif
for (iter = plugins; iter && *iter; iter++) {
const char *pname = *iter;
......@@ -1360,16 +1350,11 @@ load_plugins (NMSettings *self, const char *const*plugins, GError **error)
continue;
}
if (NM_IN_STRSET (pname, "ifcfg-suse", "ifnet")) {
if (NM_IN_STRSET (pname, "ifcfg-suse", "ifnet", "ibft", "no-ibft")) {
_LOGW ("skipping deprecated plugin %s", pname);
continue;
}
if (nm_streq (pname, "no-ibft"))
continue;
if (has_no_ibft && nm_streq (pname, "ibft"))
continue;
/* keyfile plugin is built-in now */
if (nm_streq (pname, "keyfile")) {
add_plugin_keyfile (self);
......@@ -1387,16 +1372,6 @@ load_plugins (NMSettings *self, const char *const*plugins, GError **error)
success = add_plugin_load_file (self, pname, error);
if (!success)
break;
if ( add_ibft
&& nm_streq (pname, "ifcfg-rh")) {
/* The plugin ibft is not explicitly mentioned but we just enabled "ifcfg-rh".
* Enable "ibft" by default after "ifcfg-rh". */
add_ibft = FALSE;
success = add_plugin_load_file (self, "ibft", error);
if (!success)
break;
}
}
/* If keyfile plugin was not among configured plugins, add it as the last one */
......
name = 'nm-settings-plugin-ibft'
libnms_ibft_core = static_library(
'nms-ibft-core',
'nms-ibft-reader.c',
dependencies: nm_dep,
)
sources = files(
'nms-ibft-connection.c',
'nms-ibft-plugin.c',
)
libnm_settings_plugin_ibft = shared_module(
name,
sources: sources,
dependencies: nm_dep,
link_with: libnms_ibft_core,
link_args: ldflags_linker_script_settings,
link_depends: linker_script_settings,
install: true,
install_dir: nm_plugindir,
)
core_plugins += libnm_settings_plugin_ibft
# FIXME: check_so_symbols replacement
'''
run_target(
'check-local-symbols-settings-ibft',
command: [check_so_symbols, libnm_settings_plugin_ibft.full_path()],
depends: libnm_settings_plugin_ibft,
)
check-local-symbols-settings-ibft: src/settings/plugins/ibft/libnm-settings-plugin-ibft.la
$(call check_so_symbols,$(builddir)/src/settings/plugins/ibft/.libs/libnm-settings-plugin-ibft.so)
'''
if enable_tests
subdir('tests')
endif
/* 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.
*
* Copyright 2014 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nms-ibft-connection.h"
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <glib/gstdio.h>
#include "nms-ibft-reader.h"
/*****************************************************************************/
struct _NMSIbftConnection {
NMSettingsConnection parent;
};
struct _NMSIbftConnectionClass {
NMSettingsConnectionClass parent;
};
G_DEFINE_TYPE (NMSIbftConnection, nms_ibft_connection, NM_TYPE_SETTINGS_CONNECTION)
/*****************************************************************************/
static void
nms_ibft_connection_init (NMSIbftConnection *connection)
{
}
NMSIbftConnection *
nms_ibft_connection_new (const GPtrArray *block, GError **error)
{
NMConnection *source;
GObject *object;
source = nms_ibft_reader_get_connection_from_block (block, error);
if (!source)
return NULL;
object = g_object_new (NMS_TYPE_IBFT_CONNECTION, NULL);
/* Update settings with what was read from iscsiadm */
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
source,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
error))
g_clear_object (&object);
return (NMSIbftConnection *) object;
}
static void
nms_ibft_connection_class_init (NMSIbftConnectionClass *ibft_connection_class)
{
}
/* 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.
*
* Copyright 2014 Red Hat, Inc.
*/
#ifndef __NMS_IBFT_CONNECTION_H__
#define __NMS_IBFT_CONNECTION_H__
#include "settings/nm-settings-connection.h"
#define NMS_TYPE_IBFT_CONNECTION (nms_ibft_connection_get_type ())
#define NMS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnection))
#define NMS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass))
#define NMS_IS_IBFT_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_CONNECTION))
#define NMS_IS_IBFT_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_CONNECTION))
#define NMS_IBFT_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_CONNECTION, NMSIbftConnectionClass))
typedef struct _NMSIbftConnection NMSIbftConnection;
typedef struct _NMSIbftConnectionClass NMSIbftConnectionClass;
GType nms_ibft_connection_get_type (void);
NMSIbftConnection *nms_ibft_connection_new (const GPtrArray *block,
GError **error);
#endif /* __NMS_IBFT_CONNECTION_H__ */
/* 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.
*
* Copyright 2014 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nms-ibft-plugin.h"
#include <unistd.h>
#include <gmodule.h>
#include "nm-setting-connection.h"
#include "settings/nm-settings-plugin.h"
#include "NetworkManagerUtils.h"
#include "nms-ibft-reader.h"
#include "nms-ibft-connection.h"
/*****************************************************************************/
typedef struct {
GHashTable *connections; /* uuid::connection */
gboolean initialized;
} NMSIbftPluginPrivate;
struct _NMSIbftPlugin {
NMSettingsPlugin parent;
NMSIbftPluginPrivate _priv;
};
struct _NMSIbftPluginClass {
NMSettingsPluginClass parent;
};
G_DEFINE_TYPE (NMSIbftPlugin, nms_ibft_plugin, NM_TYPE_SETTINGS_PLUGIN);
#define NMS_IBFT_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSIbftPlugin, NMS_IS_IBFT_PLUGIN)
/*****************************************************************************/
static NMSIbftPlugin *nms_ibft_plugin_get (void);
NM_DEFINE_SINGLETON_GETTER (NMSIbftPlugin, nms_ibft_plugin_get, NMS_TYPE_IBFT_PLUGIN);
/*****************************************************************************/
static void
read_connections (NMSIbftPlugin *self)
{
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
nm_auto_free_ibft_blocks GSList *blocks = NULL;
GSList *iter;
gs_free_error GError *error = NULL;
NMSIbftConnection *connection;
if (!nms_ibft_reader_load_blocks ("/sbin/iscsiadm", &blocks, &error)) {
nm_log_dbg (LOGD_SETTINGS, "ibft: failed to read iscsiadm records: %s", error->message);
return;
}
for (iter = blocks; iter; iter = iter->next) {
connection = nms_ibft_connection_new (iter->data, &error);
if (!connection) {
nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message);
g_clear_error (&error);
continue;
}
nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'",
nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (connection)));
g_hash_table_insert (priv->connections,
g_strdup (nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection))),
connection);
}
}
static GSList *
get_connections (NMSettingsPlugin *config)
{
NMSIbftPlugin *self = NMS_IBFT_PLUGIN (config);
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
GSList *list = NULL;
GHashTableIter iter;
NMSIbftConnection *connection;
if (!priv->initialized) {
read_connections (self);
priv->initialized = TRUE;
}
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection))
list = g_slist_prepend (list, connection);
return list;
}
/*****************************************************************************/
static void
nms_ibft_plugin_init (NMSIbftPlugin *self)
{
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
priv->connections = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_object_unref);
}
static void
dispose (GObject *object)
{
NMSIbftPlugin *self = NMS_IBFT_PLUGIN (object);
NMSIbftPluginPrivate *priv = NMS_IBFT_PLUGIN_GET_PRIVATE (self);
if (priv->connections) {
g_hash_table_destroy (priv->connections);
priv->connections = NULL;
}
G_OBJECT_CLASS (nms_ibft_plugin_parent_class)->dispose (object);
}
static void
nms_ibft_plugin_class_init (NMSIbftPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS (klass);
object_class->dispose = dispose;
plugin_class->get_connections = get_connections;
}
/*****************************************************************************/
G_MODULE_EXPORT NMSettingsPlugin *
nm_settings_plugin_factory (void)
{
return NM_SETTINGS_PLUGIN (g_object_ref (nms_ibft_plugin_get ()));
}
/* 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.
*
* Copyright 2014 Red Hat, Inc.
*/
#ifndef __NMS_IBFT_PLUGIN_H__
#define __NMS_IBFT_PLUGIN_H__
#define NMS_TYPE_IBFT_PLUGIN (nms_ibft_plugin_get_type ())
#define NMS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPlugin))
#define NMS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass))
#define NMS_IS_IBFT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_IBFT_PLUGIN))
#define NMS_IS_IBFT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_IBFT_PLUGIN))
#define NMS_IBFT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_IBFT_PLUGIN, NMSIbftPluginClass))
typedef struct _NMSIbftPlugin NMSIbftPlugin;
typedef struct _NMSIbftPluginClass NMSIbftPluginClass;
GType nms_ibft_plugin_get_type (void);
#endif /* __NMS_IBFT_PLUGIN_H__ */
This diff is collapsed.
/* 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.
*