settings: move warning about ifcfg-rh

Move the warning about the presence of ifcfg-rh profiles from the
plugin to NMSettings. In this way, it will be easier to implement the
migration option in the next commit.
This commit is contained in:
Beniamino Galvani
2023-07-24 16:18:08 +02:00
committed by Fernando Fernandez Mancera
parent 52cca91dd2
commit 5e75f0c197
2 changed files with 28 additions and 15 deletions

View File

@@ -1469,10 +1469,15 @@ static void
_plugin_connections_reload(NMSettings *self) _plugin_connections_reload(NMSettings *self)
{ {
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self);
GSList *iter; GSList *iter_plugin;
GHashTableIter iter_entry;
SettConnEntry *entry;
gboolean warned = FALSE;
for (iter = priv->plugins; iter; iter = iter->next) { for (iter_plugin = priv->plugins; iter_plugin; iter_plugin = iter_plugin->next) {
nm_settings_plugin_reload_connections(iter->data, _plugin_connections_reload_cb, self); nm_settings_plugin_reload_connections(iter_plugin->data,
_plugin_connections_reload_cb,
self);
} }
_connection_changed_process_all_dirty( _connection_changed_process_all_dirty(
@@ -1485,8 +1490,26 @@ _plugin_connections_reload(NMSettings *self)
| NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS
| NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET); | NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET);
for (iter = priv->plugins; iter; iter = iter->next) for (iter_plugin = priv->plugins; iter_plugin; iter_plugin = iter_plugin->next)
nm_settings_plugin_load_connections_done(iter->data); nm_settings_plugin_load_connections_done(iter_plugin->data);
g_hash_table_iter_init(&iter_entry, priv->sce_idx);
while (g_hash_table_iter_next(&iter_entry, (gpointer *) &entry, NULL)) {
const char *plugin;
plugin = nm_settings_plugin_get_plugin_name(nm_settings_storage_get_plugin(entry->storage));
if (nm_streq0(plugin, "ifcfg-rh")) {
if (!warned) {
nm_log_info(
LOGD_SETTINGS,
"Warning: the ifcfg-rh plugin is deprecated, please migrate connections "
"to the keyfile format using \"nmcli connection migrate\"");
warned = TRUE;
break;
}
}
}
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -52,8 +52,6 @@ typedef struct {
GHashTable *unmanaged_specs; GHashTable *unmanaged_specs;
GHashTable *unrecognized_specs; GHashTable *unrecognized_specs;
gboolean warned;
} NMSIfcfgRHPluginPrivate; } NMSIfcfgRHPluginPrivate;
struct _NMSIfcfgRHPlugin { struct _NMSIfcfgRHPlugin {
@@ -178,7 +176,6 @@ nm_assert_self(NMSIfcfgRHPlugin *self, gboolean unhandled_specs_consistent)
static NMSIfcfgRHStorage * static NMSIfcfgRHStorage *
_load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error) _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
{ {
NMSIfcfgRHPluginPrivate *priv = NMS_IFCFG_RH_PLUGIN_GET_PRIVATE(self);
NMSIfcfgRHStorage *ret = NULL; NMSIfcfgRHStorage *ret = NULL;
gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *connection = NULL;
gs_free_error GError *load_error = NULL; gs_free_error GError *load_error = NULL;
@@ -236,13 +233,6 @@ _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
&st.st_mtim); &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; return ret;
} }