diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-03-06 09:47:44 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-03-06 09:47:44 +0100 |
commit | 8384afa8754fcd5e8432e3a1ac1da4493c3776f8 (patch) | |
tree | ac35d60a93f90168be86a5873ba00088ef217cea | |
parent | f1b3dd4eb599d17ed894afcecf74c5e7a11cf947 (diff) | |
parent | 50a6627fd7287847323e4e91462938d8cfb20af6 (diff) | |
download | NetworkManager-8384afa8754fcd5e8432e3a1ac1da4493c3776f8.tar.gz |
merge: branch 'bg/ifcfg-rh-split'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1116
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | config.h.meson | 6 | ||||
-rw-r--r-- | configure.ac | 22 | ||||
-rw-r--r-- | contrib/fedora/rpm/NetworkManager.spec | 50 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | src/core/settings/nm-settings.c | 28 |
6 files changed, 92 insertions, 35 deletions
@@ -13,6 +13,11 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! * libnm: add new dummy crypto backend "null" that does nothing. * Veth devices with name "eth*" are now managed by default via the udev rule. This is to support managing the network in LXD containers. +* 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 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 6f3e312365..46013af1d8 100644 --- a/configure.ac +++ b/configure.ac @@ -185,16 +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 - -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]) @@ -203,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/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index a36968d7e9..9229bd77fa 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.37.1 %global nmlibdir %{_prefix}/lib/%{name} %global nmplugindir %{_libdir}/%{name}/%{version}-%{release} @@ -153,9 +154,15 @@ %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%{?rhel} > 9 || 0%{?fedora} > 35 +%global split_ifcfg_rh 1 +%else +%global split_ifcfg_rh 0 %endif %if 0%{?fedora} @@ -217,6 +224,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 @@ -526,6 +536,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 @@ -550,6 +563,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 @@ -699,7 +725,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} \ @@ -998,7 +1026,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 @@ -1021,7 +1051,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 @@ -1041,7 +1073,9 @@ fi %{_mandir}/man8/NetworkManager-dispatcher.8.gz %{_mandir}/man8/NetworkManager-wait-online.service.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 @@ -1169,6 +1203,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 diff --git a/meson.build b/meson.build index c1016e0068..b5c6944659 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); |