From 3231bbd73264a2b8f3749f6ab03271532ca6c04c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 4 Mar 2022 12:02:50 +0100 Subject: [PATCH 1/4] build: remove unused variable from configure.ac (cherry picked from commit f018afcd538d4eb2267bf5bcb5334db316642107) --- configure.ac | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure.ac b/configure.ac index 3a3eee41a3..b59d2922b8 100644 --- a/configure.ac +++ b/configure.ac @@ -192,10 +192,6 @@ if test -z "$config_plugins_default" -o "$config_plugins_default" = no; then config_plugins_default="${config_plugins_default#,}" fi -test "$enable_ifcfg_rh" = "yes" && distro_plugins="$distro_plugins,ifcfg-rh" -test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifupdown" -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_ifcfg_rh" = "yes"; then From 9830e958ed77301d4f23c92ad39235e533c61492 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 22 Feb 2022 16:58:46 +0100 Subject: [PATCH 2/4] core: fall back to loading all known settings plugins Currently it is possible to specify a list of default settings plugins to be used when configuration doesn't contain the main.plugins key. We want to add a mechanism that allows to automatically load any plugin found in the plugins directory without needing configuration. This mechanism is useful when plugins are shipped in a different, optional subpackage, to automatically use them. With such mechanism, the actual list of plugins will be determined (in order of evaluation): 1. via explicit user configuration in /etc, if any 2. via distro configuration in /usr, if any 3. using the build-time default, if any 4. looking for known plugins in /usr/lib (cherry picked from commit 392daa5dabdbabcd5025a125b3d358aeb2587161) --- NEWS | 11 +++++++++++ config.h.meson | 6 ++++++ configure.ac | 18 ++++++++++++------ meson.build | 16 +++------------- src/core/settings/nm-settings.c | 28 ++++++++++++++++++++-------- 5 files changed, 52 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index e6a608013b..ec137573c5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,14 @@ +============================================= +NetworkManager-1.36.2 +Overview of changes since NetworkManager-1.36 +============================================= + +* When the list of plugins is not specified via "main.plugins" in + NetworkManager.conf and no build-time default is set with + "--with-config-plugins-default" configure argument, now all known + plugins found in the plugin directory are loaded (and the built-in + "keyfile" plugin is preferred over others). + ============================================= NetworkManager-1.36 Overview of changes since NetworkManager-1.34 diff --git a/config.h.meson b/config.h.meson index 192246e558..7d1feb53ad 100644 --- a/config.h.meson +++ b/config.h.meson @@ -82,6 +82,12 @@ /* Path to netconfig */ #mesondefine NETCONFIG_PATH +/* Build with ifcfg-rh settings plugin */ +#mesondefine WITH_CONFIG_PLUGIN_IFCFG_RH + +/* Build with ifupdown settings plugin */ +#mesondefine WITH_CONFIG_PLUGIN_IFUPDOWN + /* The default value of the logging.audit configuration option */ #mesondefine NM_CONFIG_DEFAULT_LOGGING_AUDIT diff --git a/configure.ac b/configure.ac index b59d2922b8..07c1685e41 100644 --- a/configure.ac +++ b/configure.ac @@ -185,12 +185,6 @@ 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_ifupdown" = "yes" && config_plugins_default="$config_plugins_default,ifupdown" - config_plugins_default="${config_plugins_default#,}" -fi AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_MAIN_PLUGINS, "$config_plugins_default", [Default configuration option for main.plugins setting]) @@ -199,6 +193,18 @@ if test "$enable_ifcfg_rh" = "yes"; then fi AC_SUBST(DISTRO_NETWORK_SERVICE) +if test "$enable_ifcfg_rh" = yes; then + AC_DEFINE(WITH_CONFIG_PLUGIN_IFCFG_RH, 1, [Build with ifcfg-rh settings plugin]) +else + AC_DEFINE(WITH_CONFIG_PLUGIN_IFCFG_RH, 0, [Build with ifcfg-rh settings plugin]) +fi + +if test "$enable_ifupdown" = yes; then + AC_DEFINE(WITH_CONFIG_PLUGIN_IFUPDOWN, 1, [Build with ifupdown settings plugin]) +else + AC_DEFINE(WITH_CONFIG_PLUGIN_IFUPDOWN, 0, [Build with ifupdown settings plugin]) +fi + # Code coverage GNOME_CODE_COVERAGE diff --git a/meson.build b/meson.build index d553aaf6d5..3cbfea3e86 100644 --- a/meson.build +++ b/meson.build @@ -308,21 +308,11 @@ enable_ifcfg_rh = get_option('ifcfg_rh') or (distro == 'redhat') enable_ifupdown = get_option('ifupdown') or (distro == 'debian') config_plugins_default = get_option('config_plugins_default') -if config_plugins_default == '' - config_plugins = [] - - if enable_ifcfg_rh - config_plugins += ['ifcfg-rh'] - endif - - if enable_ifupdown - config_plugins += ['ifupdown'] - endif - - config_plugins_default = ','.join(config_plugins) -endif config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_PLUGINS', config_plugins_default) +config_h.set10('WITH_CONFIG_PLUGIN_IFCFG_RH', enable_ifcfg_rh) +config_h.set10('WITH_CONFIG_PLUGIN_IFUPDOWN', enable_ifupdown) + config_h.set_quoted('NM_DIST_VERSION', dist_version) enable_wifi = get_option('wifi') diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c index da09571b0d..6619d3e0a2 100644 --- a/src/core/settings/nm-settings.c +++ b/src/core/settings/nm-settings.c @@ -3266,7 +3266,7 @@ add_plugin(NMSettings *self, NMSettingsPlugin *plugin, const char *pname, const } static gboolean -add_plugin_load_file(NMSettings *self, const char *pname, GError **error) +add_plugin_load_file(NMSettings *self, const char *pname, gboolean ignore_not_found, GError **error) { gs_free char *full_name = NULL; gs_free char *path = NULL; @@ -3281,10 +3281,12 @@ add_plugin_load_file(NMSettings *self, const char *pname, GError **error) if (stat(path, &st) != 0) { errsv = errno; - _LOGW("could not load plugin '%s' from file '%s': %s", - pname, - path, - nm_strerror_native(errsv)); + if (!ignore_not_found) { + _LOGW("could not load plugin '%s' from file '%s': %s", + pname, + path, + nm_strerror_native(errsv)); + } return TRUE; } if (!S_ISREG(st.st_mode)) { @@ -3378,7 +3380,7 @@ load_plugins(NMSettings *self, const char *const *plugins, GError **error) continue; } - success = add_plugin_load_file(self, pname, error); + success = add_plugin_load_file(self, pname, FALSE, error); if (!success) break; } @@ -3872,8 +3874,18 @@ nm_settings_start(NMSettings *self, GError **error) /* Load the plugins; fail if a plugin is not found. */ plugins = nm_config_data_get_plugins(nm_config_get_data_orig(priv->config), TRUE); - if (!load_plugins(self, (const char *const *) plugins, error)) - return FALSE; + if (plugins && plugins[0]) { + if (!load_plugins(self, (const char *const *) plugins, error)) + return FALSE; + } else { + add_plugin_keyfile(self); +#if WITH_CONFIG_PLUGIN_IFCFG_RH + add_plugin_load_file(self, "ifcfg-rh", TRUE, NULL); +#endif +#if WITH_CONFIG_PLUGIN_IFUPDOWN + add_plugin_load_file(self, "ifupdown", TRUE, NULL); +#endif + } for (iter = priv->plugins; iter; iter = iter->next) { NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN(iter->data); From cbf9417c26c3fc2032fe1d8d15256e87a24ab9e0 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 22 Feb 2022 16:59:16 +0100 Subject: [PATCH 3/4] rpm: remove build-time default for plugins on newer distros On newer distros, remove the build-time default for settings plugins. All plugins found in the plugin directory will be used. (cherry picked from commit bb832641ebb62a0e24b5c67fc88d153a9a46c2ad) --- contrib/fedora/rpm/NetworkManager.spec | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 7c84bede35..d07b1c42f6 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -155,9 +155,9 @@ %endif %if 0%{?rhel} > 8 || 0%{?fedora} > 32 -%global config_plugins_default keyfile,ifcfg-rh +%global config_plugins_default_ifcfg_rh 0 %else -%global config_plugins_default ifcfg-rh +%global config_plugins_default_ifcfg_rh 1 %endif %if 0%{?fedora} @@ -702,7 +702,9 @@ Preferably use nmcli instead. -Dfirewalld_zone=false \ %endif -Ddist_version=%{version}-%{release} \ - -Dconfig_plugins_default=%{config_plugins_default} \ +%if %{?config_plugins_default_ifcfg_rh} + -Dconfig_plugins_default=ifcfg-rh \ +%endif -Dresolvconf=no \ -Dnetconfig=no \ -Dconfig_dns_rc_manager_default=%{dns_rc_manager_default} \ From 072171f1a3c71d9d5c4c994a4e37be969dfe4df2 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 22 Feb 2022 10:41:43 +0100 Subject: [PATCH 4/4] rpm: split ifcfg-rh settings plugin into a separate package Split the ifcfg-rh settings plugin into a separate package, so that it will not be in new installations. https://bugzilla.redhat.com/show_bug.cgi?id=2045875 (cherry picked from commit 50a6627fd7287847323e4e91462938d8cfb20af6) --- contrib/fedora/rpm/NetworkManager.spec | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index d07b1c42f6..be7a8cefab 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -22,6 +22,7 @@ %global obsoletes_device_plugins 1:0.9.9.95-1 %global obsoletes_ppp_plugin 1:1.5.3 %global obsoletes_initscripts_updown 1:1.35.4 +%global obsoletes_ifcfg_rh 1:1.36.2 %global systemd_dir %{_prefix}/lib/systemd/system %global sysctl_dir %{_prefix}/lib/sysctl.d @@ -160,6 +161,12 @@ %global config_plugins_default_ifcfg_rh 1 %endif +%if 0%{?rhel} > 9 || 0%{?fedora} > 35 +%global split_ifcfg_rh 1 +%else +%global split_ifcfg_rh 0 +%endif + %if 0%{?fedora} # Although eBPF would be available on Fedora's kernel, it seems # we often get SELinux denials (rh#1651654). But even aside them, @@ -219,6 +226,9 @@ Obsoletes: NetworkManager-wimax < 1.2 Suggests: NetworkManager-initscripts-updown %endif Obsoletes: NetworkManager < %{obsoletes_initscripts_updown} +%if 0%{?split_ifcfg_rh} +Obsoletes: NetworkManager < %{obsoletes_ifcfg_rh} +%endif %if 0%{?rhel} && 0%{?rhel} <= 7 # Kept for RHEL to ensure that wired 802.1x works out of the box @@ -528,6 +538,9 @@ deployments. %package dispatcher-routing-rules Summary: NetworkManager dispatcher file for advanced routing rules Group: System Environment/Base +%if 0%{?split_ifcfg_rh} +Requires: %{name}-initscripts-ifcfg-rh +%endif BuildArch: noarch Provides: %{name}-config-routing-rules = %{epoch}:%{version}-%{release} Obsoletes: %{name}-config-routing-rules < 1:1.31.0 @@ -552,6 +565,19 @@ by nm-connection-editor and nm-applet in a non-graphical environment. %endif +%if 0%{?split_ifcfg_rh} +%package initscripts-ifcfg-rh +Summary: NetworkManager plugin for reading and writing connections in ifcfg-rh format +Group: System Environment/Base +Requires: %{name} = %{epoch}:%{version}-%{release} +Obsoletes: NetworkManager < %{obsoletes_ifcfg_rh} + +%description initscripts-ifcfg-rh +Installs a plugin for reading and writing connection profiles using +the Red Hat ifcfg format in /etc/sysconfig/network-scripts/. +%endif + + %if %{with nm_cloud_setup} %package cloud-setup Summary: Automatically configure NetworkManager in cloud @@ -1004,7 +1030,9 @@ fi %{dbus_sys_dir}/org.freedesktop.NetworkManager.conf %{dbus_sys_dir}/nm-dispatcher.conf %{dbus_sys_dir}/nm-priv-helper.conf +%if 0%{?split_ifcfg_rh} == 0 %{dbus_sys_dir}/nm-ifcfg-rh.conf +%endif %{_sbindir}/%{name} %{_bindir}/nmcli %{_datadir}/bash-completion/completions/nmcli @@ -1027,7 +1055,9 @@ fi %{_libexecdir}/nm-priv-helper %dir %{_libdir}/%{name} %dir %{nmplugindir} -%{nmplugindir}/libnm-settings-plugin*.so +%if 0%{?split_ifcfg_rh} == 0 +%{nmplugindir}/libnm-settings-plugin-ifcfg-rh.so +%endif %if %{with nmtui} %exclude %{_mandir}/man1/nmtui* %endif @@ -1046,7 +1076,9 @@ fi %{_mandir}/man8/NetworkManager.8.gz %{_mandir}/man8/NetworkManager-dispatcher.8.gz %dir %{_localstatedir}/lib/NetworkManager +%if 0%{?split_ifcfg_rh} == 0 %dir %{_sysconfdir}/sysconfig/network-scripts +%endif %{_datadir}/dbus-1/system-services/org.freedesktop.nm_dispatcher.service %{_datadir}/dbus-1/system-services/org.freedesktop.nm_priv_helper.service %{_datadir}/polkit-1/actions/*.policy @@ -1174,6 +1206,14 @@ fi %endif +%if 0%{?split_ifcfg_rh} +%files initscripts-ifcfg-rh +%dir %{_sysconfdir}/sysconfig/network-scripts +%{nmplugindir}/libnm-settings-plugin-ifcfg-rh.so +%{dbus_sys_dir}/nm-ifcfg-rh.conf +%endif + + %if %{with nm_cloud_setup} %files cloud-setup %{_libexecdir}/nm-cloud-setup