summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <ffmancera@riseup.net>2023-07-25 15:40:02 +0200
committerFernando Fernandez Mancera <ffmancera@riseup.net>2023-07-25 15:40:02 +0200
commit9f01cff04f4a0aac5e4438e6bdb0e5c68594a706 (patch)
tree224a49e7900cc3e50328672be80b1aabc10e9e28
parentaaaf727b97d8ce1a89a76d9e13808dffa7e3ecf3 (diff)
parentb2ada6d4fa16f29346b9127f49890ddd0300df2f (diff)
settings: merge branch 'bg/ifcfg-migrate-option'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1700
-rw-r--r--Makefile.am1
-rw-r--r--config.h.meson3
-rw-r--r--configure.ac21
-rw-r--r--man/NetworkManager.conf.xml11
-rw-r--r--man/common.ent.in1
-rw-r--r--meson.build8
-rw-r--r--meson_options.txt1
-rw-r--r--src/core/nm-config-data.c1
-rw-r--r--src/core/nm-config.c1
-rw-r--r--src/core/nm-config.h2
-rw-r--r--src/core/settings/nm-settings.c63
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c10
-rw-r--r--src/libnm-base/nm-config-base.h1
13 files changed, 108 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 7b14ef91b5..d49b92c719 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -219,6 +219,7 @@ data_edit = sed \
-e 's|@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT)|g' \
-e 's|@NM_CONFIG_DEFAULT_MAIN_RC_MANAGER[@]|$(NM_CONFIG_DEFAULT_MAIN_RC_MANAGER)|g' \
-e 's|@NM_CONFIG_DEFAULT_MAIN_DHCP[@]|$(NM_CONFIG_DEFAULT_MAIN_DHCP)|g' \
+ -e 's|@NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT[@]|$(NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT)|g' \
-e 's|@NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT)|g'
###############################################################################
diff --git a/config.h.meson b/config.h.meson
index f6485e6915..d364f76281 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -106,6 +106,9 @@
/* Default configuration option for main.plugins setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_PLUGINS
+/* Default configuration value for main.migrate-ifcfg-rh setting */
+#mesondefine NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH
+
/* Default value for main.rc-manager setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_RC_MANAGER
diff --git a/configure.ac b/configure.ac
index 40e578706c..6cca7bd47d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -409,6 +409,26 @@ AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_LOGGING_BACKEND, "$nm_config_logging_backen
NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT="$nm_config_logging_backend_default"
AC_SUBST(NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT)
+AC_ARG_WITH(config-migrate-ifcfg-rh-default,
+ AS_HELP_STRING([--with-config-migrate-ifcfg-rh-default=yes|no],
+ [Default value for main.migrate-ifcfg-rh]),
+ nm_config_migrate_ifcfg_rh_default="$withval",
+ nm_config_migrate_ifcfg_rh_default="no")
+
+if test "$nm_config_migrate_ifcfg_rh_default" = yes; then
+ if test "$enable_ifcfg_rh" = no; then
+ AC_MSG_ERROR([ifcfg-rh migration can be enabled by default only when the ifcfg-rh plugin is enabled])
+ fi
+ AC_DEFINE(NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH, "true", [The default value of the main.migrate-ifcfg-rh configuration option])
+ NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT='true'
+elif test "$nm_config_migrate_ifcfg_rh_default" = no; then
+ AC_DEFINE(NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH, "false", [The default value of the main.migrate-ifcfg-rh configuration option])
+ NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT='false'
+else
+ AC_MSG_ERROR([The value of --with-config-migrate-ifcfg-rh-default must be either "yes" or "no".])
+fi
+AC_SUBST(NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT)
+
AC_ARG_WITH(config-wifi-backend-default,
AS_HELP_STRING([--with-config-wifi-backend-default=backend],
[Default value for wifi.backend]),
@@ -1440,6 +1460,7 @@ echo
echo "Configuration plugins (main.plugins=${config_plugins_default})"
echo " ifcfg-rh: ${enable_ifcfg_rh}"
+echo " default value of main.migrate-ifcfg-rh: ${nm_config_migrate_ifcfg_rh_default}"
echo " ifupdown: ${enable_ifupdown}"
echo
diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml
index 40aa51d137..3e31ecb759 100644
--- a/man/NetworkManager.conf.xml
+++ b/man/NetworkManager.conf.xml
@@ -528,6 +528,17 @@ no-auto-default=*
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><varname>migrate-ifcfg-rh</varname></term>
+ <listitem><para>Whether NetworkManager tries to automatically convert
+ any connection profile stored in ifcfg-rh format to the keyfile format.
+ Support for ifcfg-rh is deprecated and will be eventually removed. If
+ enabled, the migration is performed at every startup of the daemon.
+ The default value is <literal>&NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT;</literal>.
+ </para></listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/man/common.ent.in b/man/common.ent.in
index ae792f2529..71a47f42d7 100644
--- a/man/common.ent.in
+++ b/man/common.ent.in
@@ -8,4 +8,5 @@
<!ENTITY NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT "@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@">
<!ENTITY NM_CONFIG_DEFAULT_MAIN_RC_MANAGER "@NM_CONFIG_DEFAULT_MAIN_RC_MANAGER@">
<!ENTITY NM_CONFIG_DEFAULT_MAIN_DHCP "@NM_CONFIG_DEFAULT_MAIN_DHCP@">
+<!ENTITY NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT "@NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT@">
<!ENTITY NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT "@NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT@">
diff --git a/meson.build b/meson.build
index 055501dd41..6da1363649 100644
--- a/meson.build
+++ b/meson.build
@@ -290,6 +290,12 @@ glib_dep = declare_dependency(
enable_ifcfg_rh = get_option('ifcfg_rh')
+config_migrate_ifcfg_rh_default = get_option('config_migrate_ifcfg_rh_default').to_string()
+if config_migrate_ifcfg_rh_default == 'true'
+ assert(enable_ifcfg_rh, 'ifcfg-rh migration can be enabled by default only when the ifcfg-rh plugin is enabled')
+endif
+config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH', config_migrate_ifcfg_rh_default)
+
enable_ifupdown = get_option('ifupdown')
if enable_ifupdown == 'auto'
enable_ifupdown = (run_command('test', '-e', '/etc/debian_version').returncode() == 0)
@@ -889,6 +895,7 @@ data_conf.set('NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT', config_logging_backend_
data_conf.set('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT', config_auth_polkit_default)
data_conf.set('NM_CONFIG_DEFAULT_MAIN_DHCP', config_dhcp_default)
data_conf.set('NM_CONFIG_DEFAULT_MAIN_RC_MANAGER', config_dns_rc_manager_default)
+data_conf.set('NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_TEXT', config_migrate_ifcfg_rh_default)
data_conf.set('NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT', config_wifi_backend_default)
data_conf.set('NM_MAJOR_VERSION', nm_major_version)
data_conf.set('NM_MICRO_VERSION', nm_micro_version)
@@ -1086,6 +1093,7 @@ output += ' nmtui: ' + enable_nmtui.to_string() + '\n'
output += ' nm-cloud-setup: ' + enable_nm_cloud_setup.to_string() + '\n'
output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')\n'
output += ' ifcfg-rh: ' + enable_ifcfg_rh.to_string() + '\n'
+output += ' default value of main.migrate-ifcfg-rh: ' + config_migrate_ifcfg_rh_default + '\n'
output += ' ifupdown: ' + enable_ifupdown.to_string() + '\n'
output += '\nHandlers for /etc/resolv.conf:\n' + resolv_conf_summary
output += '\n'
diff --git a/meson_options.txt b/meson_options.txt
index c8827c6abd..f2aca21b63 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -48,6 +48,7 @@ option('ebpf', type: 'combo', choices: ['auto', 'true', 'false'], description: '
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: '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)')
+option('config_migrate_ifcfg_rh_default', type: 'boolean', value: false, description: 'The default value of the main.migrate-ifcfg-rh configuration option')
# handlers for resolv.conf
option('resolvconf', type: 'string', value: '', description: 'Enable resolvconf support')
diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c
index fe21308005..ed6d8381f2 100644
--- a/src/core/nm-config-data.c
+++ b/src/core/nm-config-data.c
@@ -760,6 +760,7 @@ static const struct {
} default_values[] = {
{NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_DEFAULT_MAIN_PLUGINS},
{NM_CONFIG_KEYFILE_GROUP_MAIN, "rc-manager", NM_CONFIG_DEFAULT_MAIN_RC_MANAGER},
+ {NM_CONFIG_KEYFILE_GROUP_MAIN, "migrate-ifcfg-rh", NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH},
{NM_CONFIG_KEYFILE_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT,
NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT},
diff --git a/src/core/nm-config.c b/src/core/nm-config.c
index a53c6a07bc..b8df41b723 100644
--- a/src/core/nm-config.c
+++ b/src/core/nm-config.c
@@ -853,6 +853,7 @@ static const ConfigGroup config_groups[] = {
NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE,
NM_CONFIG_KEYFILE_KEY_MAIN_IGNORE_CARRIER,
NM_CONFIG_KEYFILE_KEY_MAIN_IWD_CONFIG_PATH,
+ NM_CONFIG_KEYFILE_KEY_MAIN_MIGRATE_IFCFG_RH,
NM_CONFIG_KEYFILE_KEY_MAIN_MONITOR_CONNECTION_FILES,
NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT,
NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS,
diff --git a/src/core/nm-config.h b/src/core/nm-config.h
index d56770d079..acec8d05cd 100644
--- a/src/core/nm-config.h
+++ b/src/core/nm-config.h
@@ -150,6 +150,8 @@ extern char *_nm_config_match_env;
#define NM_CONFIG_DEVICE_STATE_DIR "" NMRUNDIR "/devices"
#define NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL (nm_streq("" NM_CONFIG_DEFAULT_LOGGING_AUDIT, "true"))
+#define NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_BOOL \
+ (nm_streq("" NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH, "true"))
typedef enum {
NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN = -1,
diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c
index 5fc2db8cc3..8796de3612 100644
--- a/src/core/settings/nm-settings.c
+++ b/src/core/settings/nm-settings.c
@@ -1469,10 +1469,16 @@ static void
_plugin_connections_reload(NMSettings *self)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self);
- GSList *iter;
-
- for (iter = priv->plugins; iter; iter = iter->next) {
- nm_settings_plugin_reload_connections(iter->data, _plugin_connections_reload_cb, self);
+ GSList *iter_plugin;
+ GHashTableIter iter_entry;
+ SettConnEntry *entry;
+ gboolean warned = FALSE;
+ gboolean migrate;
+
+ for (iter_plugin = priv->plugins; iter_plugin; iter_plugin = iter_plugin->next) {
+ nm_settings_plugin_reload_connections(iter_plugin->data,
+ _plugin_connections_reload_cb,
+ self);
}
_connection_changed_process_all_dirty(
@@ -1485,8 +1491,53 @@ _plugin_connections_reload(NMSettings *self)
| NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS
| NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET);
- for (iter = priv->plugins; iter; iter = iter->next)
- nm_settings_plugin_load_connections_done(iter->data);
+ for (iter_plugin = priv->plugins; iter_plugin; iter_plugin = iter_plugin->next)
+ nm_settings_plugin_load_connections_done(iter_plugin->data);
+
+ migrate = nm_config_data_get_value_boolean(nm_config_get_data(priv->config),
+ NM_CONFIG_KEYFILE_GROUP_MAIN,
+ NM_CONFIG_KEYFILE_KEY_MAIN_MIGRATE_IFCFG_RH,
+ NM_CONFIG_DEFAULT_MAIN_MIGRATE_IFCFG_RH_BOOL);
+
+ 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) {
+ if (migrate) {
+ nm_log_warn(
+ LOGD_SETTINGS,
+ "Warning: connections were found in ifcfg-rh format and the "
+ "\"main.migrate-ifcfg-rh\" option is enabled. Those connections will be "
+ "migrated to keyfile. To convert them back, disable the option and then "
+ "run \"nmcli connection migrate --plugin ifcfg-rh $UUID\"");
+ } else {
+ 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;
+ }
+ if (migrate) {
+ _LOGW("migrating connection %s ('%s') from ifcfg-rh to keyfile",
+ entry->uuid,
+ nm_settings_connection_get_id(entry->sett_conn));
+ nm_settings_connection_update(entry->sett_conn,
+ "keyfile",
+ NULL,
+ NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NONE,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NONE,
+ NM_SETTINGS_CONNECTION_UPDATE_REASON_NONE,
+ "migrate-ifcfg-rh",
+ NULL);
+ }
+ }
+ }
}
/*****************************************************************************/
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 f68a4e0e03..0a3852474d 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
@@ -52,8 +52,6 @@ typedef struct {
GHashTable *unmanaged_specs;
GHashTable *unrecognized_specs;
-
- gboolean warned;
} NMSIfcfgRHPluginPrivate;
struct _NMSIfcfgRHPlugin {
@@ -178,7 +176,6 @@ 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;
@@ -236,13 +233,6 @@ _load_file(NMSIfcfgRHPlugin *self, const char *filename, GError **error)
&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;
}
diff --git a/src/libnm-base/nm-config-base.h b/src/libnm-base/nm-config-base.h
index 8d6e60a807..c90efc1b7c 100644
--- a/src/libnm-base/nm-config-base.h
+++ b/src/libnm-base/nm-config-base.h
@@ -30,6 +30,7 @@
#define NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE "hostname-mode"
#define NM_CONFIG_KEYFILE_KEY_MAIN_IGNORE_CARRIER "ignore-carrier"
#define NM_CONFIG_KEYFILE_KEY_MAIN_IWD_CONFIG_PATH "iwd-config-path"
+#define NM_CONFIG_KEYFILE_KEY_MAIN_MIGRATE_IFCFG_RH "migrate-ifcfg-rh"
#define NM_CONFIG_KEYFILE_KEY_MAIN_MONITOR_CONNECTION_FILES "monitor-connection-files"
#define NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT "no-auto-default"
#define NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS "plugins"