summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2023-07-24 14:20:04 +0200
committerFernando Fernandez Mancera <ffmancera@riseup.net>2023-07-25 15:39:06 +0200
commit52cca91dd29eeaab110bf979f70fb827d8c4a1b8 (patch)
tree06c7048efb7da3bf30bfa8ec243b905f5992698c
parentaaaf727b97d8ce1a89a76d9e13808dffa7e3ecf3 (diff)
build,core: add a "main.migrate-ifcfg-rh" configuration option
The option enables automatic migration of ifcfg-rh connection profiles to keyfile. The default value can be configured at build time.
-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/libnm-base/nm-config-base.h1
11 files changed, 51 insertions, 0 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/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"