summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-10-29 15:26:43 +0100
committerThomas Haller <thaller@redhat.com>2014-10-29 15:27:57 +0100
commit069fcf4ba37a5a6688d9b344a273a71177846358 (patch)
tree80c95fee2ee2b658e9f391f0abbe7893aaed6e97
parentcaa1779f33a0176d906a7e9cbe4d8e281875e3ea (diff)
parentb7d6e44f3cc6a3aba82a067a9d6121c415a812fe (diff)
downloadNetworkManager-069fcf4ba37a5a6688d9b344a273a71177846358.tar.gz
settings: merge branch 'th/bgo738611_load_setting_plugins' (bgo #738611)
buil://bugzilla.gnome.org/show_bug.cgi?id=738611 Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--configure.ac19
-rw-r--r--contrib/fedora/rpm/NetworkManager.conf2
-rw-r--r--contrib/fedora/rpm/NetworkManager.spec3
-rw-r--r--man/NetworkManager.conf.xml.in12
-rw-r--r--src/nm-config.c2
-rw-r--r--src/settings/nm-settings.c62
-rw-r--r--src/settings/plugins/Makefile.am6
7 files changed, 85 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index 7ef899a122..f14fb8e0b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,7 @@ AC_SUBST(nmstatedir, "$localstatedir/lib/$PACKAGE", [NetworkManager persistent s
AC_SUBST(nmrundir, "$localstatedir/run/$PACKAGE", [NetworkManager runtime state directory])
# 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(ifcfg-suse, AS_HELP_STRING([--enable-ifcfg-suse], [enable ifcfg-suse configuration plugin (SUSE)]))
AC_ARG_ENABLE(ifupdown, AS_HELP_STRING([--enable-ifupdown], [enable ifupdown configuration plugin (Debian/Ubuntu)]))
@@ -107,12 +108,27 @@ AS_IF([test -z "$enable_ifcfg_rh"], enable_ifcfg_rh=no)
AS_IF([test -z "$enable_ifcfg_suse"], enable_ifcfg_suse=no)
AS_IF([test -z "$enable_ifupdown"], enable_ifupdown=no)
AS_IF([test -z "$enable_ifnet"], enable_ifnet=no)
+# Enable ibft by default
+AS_IF([test -z "$enable_config_plugin_ibft"], enable_config_plugin_ibft="yes")
# 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_IFCFG_SUSE, test "$enable_ifcfg_suse" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFUPDOWN, test "$enable_ifupdown" = "yes")
AM_CONDITIONAL(CONFIG_PLUGIN_IFNET, test "$enable_ifnet" = "yes")
+AC_ARG_WITH(config-plugins-default, AS_HELP_STRING([--with-config-plugins-default=PLUGINS], [Default configuration option for main.plugins setting, used as fallback if the configuration option is unset]), [config_plugins_default="$withval"], [config_plugins_default=""])
+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_ifcfg_suse" = "yes" && config_plugins_default="$config_plugins_default,ifcfg-suse"
+ test "$enable_ifupdown" = "yes" && config_plugins_default="$config_plugins_default,ifupdown"
+ test "$enable_ifnet" = "yes" && config_plugins_default="$config_plugins_default,ifnet"
+ test "$enable_config_plugin_ibft" = "yes" && config_plugins_default="$config_plugins_default,ibft"
+ config_plugins_default="${config_plugins_default#,}"
+fi
+AC_DEFINE_UNQUOTED(CONFIG_PLUGINS_DEFAULT, "$config_plugins_default", [Default configuration option for main.plugins setting])
+
if test "$enable_ifcfg_rh" = "yes"; then
DISTRO_NETWORK_SERVICE=network.service
fi
@@ -1010,7 +1026,8 @@ echo " libteamdctl: $enable_teamdctl"
echo " nmtui: $build_nmtui"
echo
-echo "Configuration plugins"
+echo "Configuration plugins (main.plugins=${config_plugins_default})"
+echo " ibft: ${enable_config_plugin_ibft}"
echo " ifcfg-rh: ${enable_ifcfg_rh}"
echo " ifcfg-suse: ${enable_ifcfg_suse}"
echo " ifupdown: ${enable_ifupdown}"
diff --git a/contrib/fedora/rpm/NetworkManager.conf b/contrib/fedora/rpm/NetworkManager.conf
index 65e34a4df3..88b7cec290 100644
--- a/contrib/fedora/rpm/NetworkManager.conf
+++ b/contrib/fedora/rpm/NetworkManager.conf
@@ -1,2 +1,2 @@
[main]
-plugins=ifcfg-rh
+plugins=ifcfg-rh,ibft
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec
index 6376998d95..e78a94a3d7 100644
--- a/contrib/fedora/rpm/NetworkManager.spec
+++ b/contrib/fedora/rpm/NetworkManager.spec
@@ -423,7 +423,8 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
--enable-ifcfg-rh=yes \
--with-system-libndp=yes \
--with-pppd-plugin-dir=%{_libdir}/pppd/%{ppp_version} \
- --with-dist-version=%{version}-%{release}
+ --with-dist-version=%{version}-%{release} \
+ --with-setting-plugins-default='ifcfg-rh,ibft'
make %{?_smp_mflags}
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index fcb4dfc4e8..67919cfb4f 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -502,6 +502,18 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><varname>ibft</varname></term>
+ <listitem>
+ <para>
+ This plugin allows to read iBFT configuration (iSCSI Boot Firmware Table).
+ The configuration is read using /sbin/iscsiadm. Users are expected to
+ configure iBFT connections via the firmware interfaces.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/src/nm-config.c b/src/nm-config.c
index 2580541a62..1f41553355 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -580,6 +580,8 @@ nm_config_new (GError **error)
if (cli_plugins && cli_plugins[0])
g_key_file_set_value (priv->keyfile, "main", "plugins", cli_plugins);
priv->plugins = g_key_file_get_string_list (priv->keyfile, "main", "plugins", NULL, NULL);
+ if (!priv->plugins && STRLEN (CONFIG_PLUGINS_DEFAULT) > 0)
+ priv->plugins = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1);
value = g_key_file_get_value (priv->keyfile, "main", "monitor-connection-files", NULL);
priv->monitor_connection_files = FALSE;
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index e9d3eaf24d..bd90668203 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -26,6 +26,8 @@
#include "config.h"
#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
#include <string.h>
#include <gmodule.h>
#include <pwd.h>
@@ -70,6 +72,13 @@
#include "nm-config.h"
#include "NetworkManagerUtils.h"
+#define LOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), LOGD_CORE, \
+ "settings: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
/* LINKER CRACKROCK */
#define EXPORT(sym) void * __export_##sym = &sym;
@@ -619,18 +628,24 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
for (iter = plugins; iter && *iter; iter++) {
GModule *plugin;
- char *full_name, *path;
- const char *pname = *iter;
+ gs_free char *full_name = NULL;
+ gs_free char *path = NULL;
+ gs_free char *pname = NULL;
GObject *obj;
GObject * (*factory_func) (void);
+ struct stat st;
+ int errsv;
+
+ pname = g_strdup (*iter);
+ g_strstrip (pname);
- /* strip leading spaces */
- while (g_ascii_isspace (*pname))
- pname++;
+ if (!*pname)
+ continue;
- /* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */
- if (!strcmp (pname, "ifcfg-fedora"))
- pname = "ifcfg-rh";
+ if (!*pname || strchr (pname, '/')) {
+ LOG (LOGL_WARN, "ignore invalid plugin \"%s\"", pname);
+ continue;
+ }
obj = find_plugin (list, pname);
if (obj)
@@ -648,19 +663,32 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
full_name = g_strdup_printf ("nm-settings-plugin-%s", pname);
path = g_module_build_path (NMPLUGINDIR, full_name);
+ if (stat (path, &st) != 0) {
+ errsv = errno;
+ LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv));
+ continue;
+ }
+ if (!S_ISREG (st.st_mode)) {
+ LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': not a file", pname, path);
+ continue;
+ }
+ if (st.st_uid != 0) {
+ LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': file must be owned by root", pname, path);
+ continue;
+ }
+ if (st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) {
+ LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': invalid file permissions", pname, path);
+ continue;
+ }
+
plugin = g_module_open (path, G_MODULE_BIND_LOCAL);
if (!plugin) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
- "Could not load plugin '%s': %s",
- pname, g_module_error ());
- g_free (full_name);
- g_free (path);
- success = FALSE;
- break;
+ LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s",
+ pname, full_name, g_module_error ());
+ continue;
}
- g_free (full_name);
- g_free (path);
+ /* errors after this point are fatal, because we loaded the shared library already. */
if (!g_module_symbol (plugin, "nm_system_config_factory", (gpointer) (&factory_func))) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
diff --git a/src/settings/plugins/Makefile.am b/src/settings/plugins/Makefile.am
index 22f4171073..568da7f6ac 100644
--- a/src/settings/plugins/Makefile.am
+++ b/src/settings/plugins/Makefile.am
@@ -1,7 +1,11 @@
-SUBDIRS=keyfile example ibft
+SUBDIRS=keyfile example
@GNOME_CODE_COVERAGE_RULES@
+if CONFIG_PLUGIN_IBFT
+SUBDIRS+=ibft
+endif
+
if CONFIG_PLUGIN_IFCFG_RH
SUBDIRS+=ifcfg-rh
endif