From 3fd70ff685d6e38245a33d0be3e4b931fa6cd6d9 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 31 May 2023 08:53:38 +0200 Subject: [PATCH] ifcfg-rh: emit deprecation warning when a ifcfg-rh profile is found Emit a warning (once) when a connection profile is found in ifcfg-rh format. --- .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index eb0d733df..f68a4e0e0 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -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