build: allow configuring default for wifi.backend setting

Distributions may want to change the default wifi.backend, if for
example they are building without wpa_supplicant support.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/869

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1040
This commit is contained in:
James Hilliard
2021-12-02 18:34:10 -07:00
committed by Thomas Haller
parent 7377df2f2d
commit edc37b3adf
10 changed files with 44 additions and 2 deletions

View File

@@ -202,7 +202,8 @@ data_edit = sed \
-e 's|@NM_CONFIG_DEFAULT_LOGGING_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_LOGGING_BACKEND_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_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_WIFI_BACKEND_TEXT[@]|$(NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT)|g'
###############################################################################

View File

@@ -100,6 +100,9 @@
/* Default value for main.rc-manager setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_RC_MANAGER
/* Default configuration option for wifi.backend */
#mesondefine NM_CONFIG_DEFAULT_WIFI_BACKEND
/* Define the distribution version string */
#mesondefine NM_DIST_VERSION

View File

@@ -404,6 +404,25 @@ 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-wifi-backend-default,
AS_HELP_STRING([--with-config-wifi-backend-default=backend],
[Default value for wifi.backend]),
nm_config_wifi_backend_default="$withval",
nm_config_wifi_backend_default="wpa_supplicant")
if test "$nm_config_wifi_backend_default" != 'iwd' \
-a "$nm_config_wifi_backend_default" != 'wpa_supplicant'; then
AC_MSG_ERROR([The default Wi-Fi backend must be either wpa_supplicant or iwd.])
fi
if test "$nm_config_wifi_backend_default" = "iwd"; then
if test "$ac_with_iwd" != "yes"; then
AC_MSG_ERROR([Setting the default Wi-Fi backend to iwd requires iwd support.])
fi
fi
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_WIFI_BACKEND, "$nm_config_wifi_backend_default", [Default configuration option for wifi.backend])
NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT="$nm_config_wifi_backend_default"
AC_SUBST(NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT)
# Session tracking support
AC_ARG_WITH(systemd-logind,
AS_HELP_STRING([--with-systemd-logind=yes|no],

View File

@@ -198,6 +198,7 @@ if [[ $NO_DIST != 1 ]]; then
--enable-ifcfg-rh \
--enable-ifupdown \
--with-config-logging-backend-default=syslog \
--with-config-wifi-backend-default=wpa_supplicant \
--with-libaudit=yes-disabled-by-default \
--enable-polkit=yes \
--with-nm-cloud-setup=yes \

View File

@@ -1237,6 +1237,7 @@ managed=1
<para>
Specify the Wi-Fi backend used for the device. Currently, supported
are <literal>wpa_supplicant</literal> and <literal>iwd</literal> (experimental).
If unspecified, the default is "<literal>&NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT;</literal>".
</para>
</listitem>
</varlistentry>

View File

@@ -8,3 +8,4 @@
<!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_WIFI_BACKEND_TEXT "@NM_CONFIG_DEFAULT_WIFI_BACKEND_TEXT@">

View File

@@ -389,6 +389,14 @@ if config_logging_backend_default == 'default'
endif
config_h.set_quoted('NM_CONFIG_DEFAULT_LOGGING_BACKEND', config_logging_backend_default)
config_wifi_backend_default = get_option('config_wifi_backend_default')
if config_wifi_backend_default == 'default'
config_wifi_backend_default = 'wpa_supplicant'
elif config_wifi_backend_default == 'iwd'
assert(enable_iwd, 'Setting the default Wi-Fi backend to iwd requires iwd support.')
endif
config_h.set_quoted('NM_CONFIG_DEFAULT_WIFI_BACKEND', config_wifi_backend_default)
session_tracking = get_option('session_tracking')
session_trackers = []
@@ -890,6 +898,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_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)
data_conf.set('NM_MINOR_VERSION', nm_minor_version)

View File

@@ -21,6 +21,7 @@ option('polkit_agent_helper_1', type: 'string', value: '', description: 'Path na
option('selinux', type: 'boolean', value: true, description: 'Build with SELinux')
option('systemd_journal', type: 'boolean', value: true, description: 'Use systemd journal for logging')
option('config_logging_backend_default', type: 'combo', choices: ['default', 'syslog', 'journal'], value: 'default', description: 'Default value for logging.backend')
option('config_wifi_backend_default', type: 'combo', choices: ['default', 'wpa_supplicant', 'iwd'], value: 'default', description: 'Default value for wifi.backend')
option('hostname_persist', type: 'combo', choices: ['default', 'suse', 'gentoo', 'slackware'], value: 'default', description: 'Hostname persist method')
option('libaudit', type: 'combo', choices: ['yes', 'yes-disabled-by-default', 'no'], value: 'yes', description: 'Build with audit daemon support. yes-disabled-by-default enables support, but disables it unless explicitly configured via NetworkManager.conf')

View File

@@ -92,12 +92,15 @@ create_device(NMDeviceFactory *factory,
NULL);
backend = nm_strstrip_avoid_copy_a(300, backend, &backend_free);
if (!backend)
backend = "" NM_CONFIG_DEFAULT_WIFI_BACKEND;
nm_log_dbg(LOGD_PLATFORM | LOGD_WIFI,
"(%s) config: backend is %s%s%s%s",
iface,
NM_PRINT_FMT_QUOTE_STRING(backend),
WITH_IWD ? " (iwd support enabled)" : "");
if (!backend || !g_ascii_strcasecmp(backend, "wpa_supplicant")) {
if (!g_ascii_strcasecmp(backend, "wpa_supplicant")) {
NMDevice *device;
_NMDeviceWifiCapabilities capabilities;
_NM80211Mode mode;

View File

@@ -711,6 +711,9 @@ static const struct {
{NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_IWD_CONFIG_PATH, ""},
{NM_CONFIG_KEYFILE_GROUP_LOGGING, "backend", NM_CONFIG_DEFAULT_LOGGING_BACKEND},
{NM_CONFIG_KEYFILE_GROUP_LOGGING, "audit", NM_CONFIG_DEFAULT_LOGGING_AUDIT},
{NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE,
NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_BACKEND,
NM_CONFIG_DEFAULT_WIFI_BACKEND},
};
void