mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 15:40:22 +01:00
ifcfg-rh: preserve NULL wifi mode when persisting a connection
The wireless mode property can be unset (NULL), in which case it assumed to be equivalent to "infrastructure". If we convert an unset mode to infrastructure, the connection will change on write, triggering errors like: settings-connection[...]: write: successfully updated (ifcfg-rh: persist (null)), connection was modified in the process device (wlp4s0): Activation: (wifi) access point 'test1' has security, but secrets are required. device (wlp4s0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed') device (wlp4s0): The connection was modified since activation device (wlp4s0): state change: need-auth -> failed (reason 'no-secrets', sys-iface-state: 'managed') To fix this, remove the MODE key when the mode is unset so that the property is read back exactly as it was. Note that initscripts need the MODE set, but in most cases there are other issues that make Wi-Fi connection written by NM not compatible with initscripts. https://bugzilla.redhat.com/show_bug.cgi?id=1549972
This commit is contained in:
parent
497a18aee9
commit
e09ffb0c81
3 changed files with 6 additions and 6 deletions
|
|
@ -906,14 +906,16 @@ write_wireless_setting (NMConnection *connection,
|
|||
}
|
||||
|
||||
mode = nm_setting_wireless_get_mode (s_wireless);
|
||||
if (!mode || !strcmp (mode, "infrastructure")) {
|
||||
if (!mode)
|
||||
svUnsetValue(ifcfg, "MODE");
|
||||
else if (nm_streq (mode, NM_SETTING_WIRELESS_MODE_INFRA))
|
||||
svSetValueStr (ifcfg, "MODE", "Managed");
|
||||
} else if (!strcmp (mode, "adhoc")) {
|
||||
else if (nm_streq (mode, NM_SETTING_WIRELESS_MODE_ADHOC)) {
|
||||
svSetValueStr (ifcfg, "MODE", "Ad-Hoc");
|
||||
adhoc = TRUE;
|
||||
} else if (!strcmp (mode, "ap")) {
|
||||
} else if (nm_streq (mode, NM_SETTING_WIRELESS_MODE_AP))
|
||||
svSetValueStr (ifcfg, "MODE", "Ap");
|
||||
} else {
|
||||
else {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
|
||||
"Invalid mode '%s' in '%s' setting",
|
||||
mode, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
ESSID="Test SSID"
|
||||
MODE=Managed
|
||||
SSID_HIDDEN=yes
|
||||
MAC_ADDRESS_RANDOMIZATION=default
|
||||
TYPE=Wireless
|
||||
|
|
|
|||
|
|
@ -3513,7 +3513,6 @@ test_write_wifi_hidden (void)
|
|||
|
||||
g_object_set (s_wifi,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||
NM_SETTING_WIRELESS_HIDDEN, TRUE,
|
||||
NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue