merge: branch 'bg/link-setting-ifcfg'

Deprecate the ifcfg-rh setting plugin

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1570
This commit is contained in:
Beniamino Galvani 2023-06-29 10:24:45 +02:00
commit 7e2f2174ab
9 changed files with 61 additions and 30 deletions

View file

@ -172,10 +172,9 @@ AC_SUBST(nmrundir, '${runstatedir}'/$PACKAGE, [NetworkManager runtime state dire
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
# Alternative configuration plugins
AC_ARG_ENABLE(ifcfg-rh, AS_HELP_STRING([--enable-ifcfg-rh], [enable ifcfg-rh configuration plugin (Fedora/RHEL)]))
AC_ARG_ENABLE(ifcfg-rh, AS_HELP_STRING([--enable-ifcfg-rh], [enable ifcfg-rh configuration plugin (Fedora/RHEL) (deprecated)]))
AC_ARG_ENABLE(ifupdown, AS_HELP_STRING([--enable-ifupdown], [enable ifupdown configuration plugin (Debian/Ubuntu)]))
# Default alternative plugins by distribution
AS_IF([test -z "$enable_ifcfg_rh" -a -d /etc/sysconfig/network-scripts], enable_ifcfg_rh=yes)
AS_IF([test -z "$enable_ifupdown" -a -f /etc/debian_version], enable_ifupdown=yes)
# Otherwise, plugins default to "no"
AS_IF([test -z "$enable_ifcfg_rh"], enable_ifcfg_rh=no)

View file

@ -1646,9 +1646,9 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
<term><varname>ifcfg-rh</varname></term>
<listitem>
<para>
This plugin is used on the Fedora and Red Hat Enterprise
Linux distributions to read and write configuration from
the standard
This plugin is now deprecated; it can be used on the
Fedora and Red Hat Enterprise Linux distributions to read
and write configuration from the standard
<filename>/etc/sysconfig/network-scripts/ifcfg-*</filename>
files. It currently supports reading Ethernet, Wi-Fi,
InfiniBand, VLAN, Bond, Bridge, and Team connections.

View file

@ -334,7 +334,7 @@ DEVICETYPE=TeamPort
<xsl:template match="setting">
<xsl:variable name="setting_name" select="../@name"/>
<xsl:variable name="unsupported" select="'802-11-olpc-mesh, adsl, bluetooth, cdma, dummy, generic, gsm, ip-tunnel, macsec, macvlan, ppp, pppoe, serial, tun, vpn, vxlan, wimax'"/>
<xsl:variable name="unsupported" select="'6lowpan, 802-11-olpc-mesh, adsl, bluetooth, cdma, dummy, generic, gsm, ip-tunnel, link, loopback, macsec, macvlan, ovs-bridge, ovs-dpdk, ovs-interface, ovs-patch, ovs-port, ppp, pppoe, serial, tun, veth, vpn, vrf, vxlan, wifi-p2p, wimax, wireguard, wpan'"/>
<xsl:if test="not (contains(concat(' ', $unsupported, ','), concat(' ', @name, ',')))">
<table>
<title><xsl:value-of select="@name"/> setting</title>

View file

@ -289,11 +289,6 @@ glib_dep = declare_dependency(
)
enable_ifcfg_rh = get_option('ifcfg_rh')
if enable_ifcfg_rh == 'auto'
enable_ifcfg_rh = (run_command('test', '-e', '/etc/sysconfig/network-scripts').returncode() == 0)
else
enable_ifcfg_rh = (enable_ifcfg_rh != 'false')
endif
enable_ifupdown = get_option('ifupdown')
if enable_ifupdown == 'auto'

View file

@ -45,7 +45,7 @@ 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('ifcfg_rh', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL)')
option('ifcfg_rh', type: 'boolean', value: false, description: 'enable ifcfg-rh configuration plugin (Fedora/RHEL) (deprecated)')
option('ifupdown', type: 'combo', choices:['auto', 'true', 'false'], value: 'auto', description: 'enable ifupdown configuration plugin (Debian/Ubuntu)')
# handlers for resolv.conf

View file

@ -53,6 +53,7 @@ typedef struct {
GHashTable *unmanaged_specs;
GHashTable *unrecognized_specs;
gboolean warned;
} NMSIfcfgRHPluginPrivate;
struct _NMSIfcfgRHPlugin {
@ -177,6 +178,8 @@ nm_assert_self(NMSIfcfgRHPlugin *self, gboolean unhandled_specs_consistent)
static NMSIfcfgRHStorage *
_load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
{
NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self);
NMSIfcfgRHStorage *ret = NULL;
gs_unref_object NMConnection *connection = NULL;
gs_free_error GError *load_error = NULL;
gs_free char *unhandled_spec = NULL;
@ -224,16 +227,23 @@ _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
nm_assert_not_reached();
return NULL;
}
return nms_ifcfg_rh_storage_new_unhandled(self,
ret = nms_ifcfg_rh_storage_new_unhandled(self, filename, unmanaged_spec, unrecognized_spec);
} else {
ret = nms_ifcfg_rh_storage_new_connection(self,
filename,
unmanaged_spec,
unrecognized_spec);
g_steal_pointer(&connection),
&st.st_mtim);
}
return nms_ifcfg_rh_storage_new_connection(self,
filename,
g_steal_pointer(&connection),
&st.st_mtim);
if (!priv->warned) {
nm_log_info(_NMLOG_DOMAIN,
"Warning: the ifcfg-rh plugin is deprecated, please migrate connections "
"to the keyfile format using \"nmcli connection migrate\".");
priv->warned = TRUE;
}
return ret;
}
static void

View file

@ -61,6 +61,24 @@
/*****************************************************************************/
static void
set_error_unsupported(GError **error,
NMConnection *connection,
const char *name,
gboolean is_setting)
{
g_set_error(error,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN,
"The ifcfg-rh plugin doesn't support %s '%s'. If you are modifying an existing "
"connection profile saved in ifcfg-rh format, please migrate the connection to "
"keyfile using 'nmcli connection migrate %s' or via the Update2() D-Bus API "
"and try again.",
is_setting ? "setting" : "property",
name,
nm_connection_get_uuid(connection));
};
static void
save_secret_flags(shvarFile *ifcfg, const char *key, NMSettingSecretFlags flags)
{
@ -3488,6 +3506,11 @@ do_write_construct(NMConnection *connection,
write_sriov_setting(connection, ifcfg);
write_tc_setting(connection, ifcfg);
if (_nm_connection_get_setting(connection, NM_TYPE_SETTING_LINK)) {
set_error_unsupported(error, connection, "link", TRUE);
return FALSE;
}
route_path_is_svformat = utils_has_route_file_new_syntax(route_path);
has_complex_routes_v4 = utils_has_complex_routes(ifcfg_name, AF_INET);

View file

@ -51,11 +51,10 @@
#include "nm-setting-match.h"
#include "nm-setting-olpc-mesh.h"
#include "nm-setting-ovs-bridge.h"
#include "nm-setting-ovs-interface.h"
#include "nm-setting-ovs-dpdk.h"
#include "nm-setting-ovs-interface.h"
#include "nm-setting-ovs-patch.h"
#include "nm-setting-ovs-port.h"
#include "nm-setting-wifi-p2p.h"
#include "nm-setting-ppp.h"
#include "nm-setting-pppoe.h"
#include "nm-setting-proxy.h"
@ -71,6 +70,7 @@
#include "nm-setting-vpn.h"
#include "nm-setting-vrf.h"
#include "nm-setting-vxlan.h"
#include "nm-setting-wifi-p2p.h"
#include "nm-setting-wimax.h"
#include "nm-setting-wired.h"
#include "nm-setting-wireguard.h"

View file

@ -253,6 +253,9 @@ GQuark nm_secret_agent_error_quark(void);
* @NM_SETTINGS_ERROR_VERSION_ID_MISMATCH: The profile's VersionId mismatched
* and the update is rejected. See the "version-id" argument to Update2()
* method. Since 1.44.
* @NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN: the requested operation is not
* supported by the settings plugin currently in use for the specified object.
* Since: 1.44.
*
* Errors related to the settings/persistent configuration interface of
* NetworkManager.
@ -262,15 +265,16 @@ GQuark nm_secret_agent_error_quark(void);
* D-Bus errors in that namespace.
*/
typedef enum {
NM_SETTINGS_ERROR_FAILED = 0, /*< nick=Failed >*/
NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
NM_SETTINGS_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/
NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/
NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/
NM_SETTINGS_ERROR_INVALID_HOSTNAME, /*< nick=InvalidHostname >*/
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, /*< nick=InvalidArguments >*/
NM_SETTINGS_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/
NM_SETTINGS_ERROR_FAILED = 0, /*< nick=Failed >*/
NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
NM_SETTINGS_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/
NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/
NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/
NM_SETTINGS_ERROR_INVALID_HOSTNAME, /*< nick=InvalidHostname >*/
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, /*< nick=InvalidArguments >*/
NM_SETTINGS_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/
NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN, /*< nick=NotSupportedByPlugin >*/
} NMSettingsError;
GQuark nm_settings_error_quark(void);