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.
This commit is contained in:
Beniamino Galvani
2023-07-24 14:20:04 +02:00
committed by Fernando Fernandez Mancera
parent aaaf727b97
commit 52cca91dd2
11 changed files with 51 additions and 0 deletions

View File

@@ -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_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_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_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' -e 's|@NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT)|g'
############################################################################### ###############################################################################

View File

@@ -106,6 +106,9 @@
/* Default configuration option for main.plugins setting */ /* Default configuration option for main.plugins setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_PLUGINS #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 */ /* Default value for main.rc-manager setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_RC_MANAGER #mesondefine NM_CONFIG_DEFAULT_MAIN_RC_MANAGER

View File

@@ -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" NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT="$nm_config_logging_backend_default"
AC_SUBST(NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT) 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, AC_ARG_WITH(config-wifi-backend-default,
AS_HELP_STRING([--with-config-wifi-backend-default=backend], AS_HELP_STRING([--with-config-wifi-backend-default=backend],
[Default value for wifi.backend]), [Default value for wifi.backend]),
@@ -1440,6 +1460,7 @@ echo
echo "Configuration plugins (main.plugins=${config_plugins_default})" echo "Configuration plugins (main.plugins=${config_plugins_default})"
echo " ifcfg-rh: ${enable_ifcfg_rh}" 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 " ifupdown: ${enable_ifupdown}"
echo echo

View File

@@ -528,6 +528,17 @@ no-auto-default=*
</para> </para>
</listitem> </listitem>
</varlistentry> </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> </variablelist>
</refsect1> </refsect1>

View File

@@ -8,4 +8,5 @@
<!ENTITY NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT "@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@"> <!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_RC_MANAGER "@NM_CONFIG_DEFAULT_MAIN_RC_MANAGER@">
<!ENTITY NM_CONFIG_DEFAULT_MAIN_DHCP "@NM_CONFIG_DEFAULT_MAIN_DHCP@"> <!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@"> <!ENTITY NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT "@NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT@">

View File

@@ -290,6 +290,12 @@ glib_dep = declare_dependency(
enable_ifcfg_rh = get_option('ifcfg_rh') 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') enable_ifupdown = get_option('ifupdown')
if enable_ifupdown == 'auto' if enable_ifupdown == 'auto'
enable_ifupdown = (run_command('test', '-e', '/etc/debian_version').returncode() == 0) 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_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_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_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_CONFIG_DEFAULT_WIFI_BACKEND_TEXT', config_wifi_backend_default)
data_conf.set('NM_MAJOR_VERSION', nm_major_version) data_conf.set('NM_MAJOR_VERSION', nm_major_version)
data_conf.set('NM_MICRO_VERSION', nm_micro_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 += ' nm-cloud-setup: ' + enable_nm_cloud_setup.to_string() + '\n'
output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')\n' output += '\nConfiguration_plugins (main.plugins=' + config_plugins_default + ')\n'
output += ' ifcfg-rh: ' + enable_ifcfg_rh.to_string() + '\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 += ' ifupdown: ' + enable_ifupdown.to_string() + '\n'
output += '\nHandlers for /etc/resolv.conf:\n' + resolv_conf_summary output += '\nHandlers for /etc/resolv.conf:\n' + resolv_conf_summary
output += '\n' output += '\n'

View File

@@ -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('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('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('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 # handlers for resolv.conf
option('resolvconf', type: 'string', value: '', description: 'Enable resolvconf support') option('resolvconf', type: 'string', value: '', description: 'Enable resolvconf support')

View File

@@ -760,6 +760,7 @@ static const struct {
} default_values[] = { } default_values[] = {
{NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_DEFAULT_MAIN_PLUGINS}, {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, "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_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT, NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT,
NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT}, NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT},

View File

@@ -853,6 +853,7 @@ static const ConfigGroup config_groups[] = {
NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE, NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE,
NM_CONFIG_KEYFILE_KEY_MAIN_IGNORE_CARRIER, NM_CONFIG_KEYFILE_KEY_MAIN_IGNORE_CARRIER,
NM_CONFIG_KEYFILE_KEY_MAIN_IWD_CONFIG_PATH, 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_MONITOR_CONNECTION_FILES,
NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT, NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT,
NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS, NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS,

View File

@@ -150,6 +150,8 @@ extern char *_nm_config_match_env;
#define NM_CONFIG_DEVICE_STATE_DIR "" NMRUNDIR "/devices" #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_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 { typedef enum {
NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN = -1, NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN = -1,

View File

@@ -30,6 +30,7 @@
#define NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE "hostname-mode" #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_IGNORE_CARRIER "ignore-carrier"
#define NM_CONFIG_KEYFILE_KEY_MAIN_IWD_CONFIG_PATH "iwd-config-path" #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_MONITOR_CONNECTION_FILES "monitor-connection-files"
#define NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT "no-auto-default" #define NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT "no-auto-default"
#define NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS "plugins" #define NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS "plugins"