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.
This commit is contained in:
Beniamino Galvani
2023-05-31 08:53:38 +02:00
parent 9c90503ffe
commit 3fd70ff685

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,18 +227,25 @@ _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
nm_assert_not_reached();
return NULL;
}
return nms_ifcfg_rh_storage_new_unhandled(self,
filename,
unmanaged_spec,
unrecognized_spec);
}
return nms_ifcfg_rh_storage_new_connection(self,
ret = nms_ifcfg_rh_storage_new_unhandled(self, filename, unmanaged_spec, unrecognized_spec);
} else {
ret = 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
_load_dir(NMSIfcfgRHPlugin *self, NMSettUtilStorages *storages)
{