mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 00:38:07 +02:00
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>
This commit is contained in:
commit
069fcf4ba3
7 changed files with 87 additions and 23 deletions
19
configure.ac
19
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}"
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
[main]
|
||||
plugins=ifcfg-rh
|
||||
plugins=ifcfg-rh,ibft
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/* strip leading spaces */
|
||||
while (g_ascii_isspace (*pname))
|
||||
pname++;
|
||||
pname = g_strdup (*iter);
|
||||
g_strstrip (pname);
|
||||
|
||||
/* ifcfg-fedora was renamed ifcfg-rh; handle old configs here */
|
||||
if (!strcmp (pname, "ifcfg-fedora"))
|
||||
pname = "ifcfg-rh";
|
||||
if (!*pname)
|
||||
continue;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
g_free (full_name);
|
||||
g_free (path);
|
||||
plugin = g_module_open (path, G_MODULE_BIND_LOCAL);
|
||||
if (!plugin) {
|
||||
LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s",
|
||||
pname, full_name, g_module_error ());
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue