Skip to content

Commit 4245f6a

Browse files
authored
Fix crash on captive portal Wi-Fi by ensuring NMConnection is fully initialized (#354)
1 parent 82b45bb commit 4245f6a

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/Widgets/WifiInterface.vala

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,22 @@ public class Network.WifiInterface : Network.WidgetNMInterface {
264264
}
265265

266266
var flags = i.ap.get_wpa_flags () | i.ap.get_rsn_flags ();
267-
var is_secured = true;
267+
var is_secured = flags != NM.@80211ApSecurityFlags.NONE;
268268

269269
var connection = NM.SimpleConnection.new ();
270270

271-
if (flags != NM.@80211ApSecurityFlags.NONE) {
272-
var s_con = new NM.SettingConnection ();
273-
s_con.uuid = NM.Utils.uuid_generate ();
274-
connection.add_setting (s_con);
271+
// Always create a proper connection and wireless setting for libnma
272+
var s_con = new NM.SettingConnection ();
273+
s_con.uuid = NM.Utils.uuid_generate ();
274+
s_con.id = NM.Utils.ssid_to_utf8 (i.ap.get_ssid ().get_data ());
275+
s_con.type = NM.SettingWireless.SETTING_NAME;
276+
connection.add_setting (s_con);
275277

278+
var s_wifi = new NM.SettingWireless ();
279+
s_wifi.ssid = i.ap.get_ssid ();
280+
connection.add_setting (s_wifi);
281+
282+
if (is_secured) {
276283
if (NM.@80211ApSecurityFlags.KEY_MGMT_OWE in flags ||
277284
NM.@80211ApSecurityFlags.KEY_MGMT_OWE_TM in flags) {
278285
var s_wsec = new NM.SettingWirelessSecurity ();
@@ -286,10 +293,6 @@ public class Network.WifiInterface : Network.WidgetNMInterface {
286293
connection.add_setting (s_wsec);
287294
}
288295

289-
var s_wifi = new NM.SettingWireless ();
290-
s_wifi.ssid = i.ap.get_ssid ();
291-
connection.add_setting (s_wifi);
292-
293296
// If the AP is WPA[2]-Enterprise then we need to set up a minimal 802.1x setting before
294297
// prompting the user to configure the authentication, otherwise, the dialog works out
295298
// what sort of credentials to prompt for automatically
@@ -303,9 +306,7 @@ public class Network.WifiInterface : Network.WidgetNMInterface {
303306
s_8021x.phase2_auth = "mschapv2";
304307
connection.add_setting (s_8021x);
305308
}
306-
}
307309

308-
if (is_secured) {
309310
// In theory, we could just activate normal WEP/WPA connections without spawning a WifiDialog
310311
// and NM would create its own dialog, but Mutter's focus stealing prevention often hides it
311312
// so we spawn our own

0 commit comments

Comments
 (0)