diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2018-03-19 16:38:42 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-03-20 09:32:20 +0100 |
commit | e09ffb0c81a12558427fe61568b97e71115eb402 (patch) | |
tree | a71eb6ef9e904e1a9b38b03d344671f16b03194a | |
parent | 497a18aee9945348d0692c6c434e4d030d0b1a49 (diff) | |
download | NetworkManager-e09ffb0c81a12558427fe61568b97e71115eb402.tar.gz |
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
3 files changed, 6 insertions, 6 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index 33f7833957..1484dd43c8 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -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); diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Hidden.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Hidden.cexpected index 026993b8bd..cf325f3512 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Hidden.cexpected +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Hidden.cexpected @@ -1,5 +1,4 @@ ESSID="Test SSID" -MODE=Managed SSID_HIDDEN=yes MAC_ADDRESS_RANDOMIZATION=default TYPE=Wireless diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 40c5404fb5..0dcfe93908 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -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); |