From 10a7998495be98f04d7ae835d458d0a59e07e3df Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 2 Jan 2026 17:53:52 +0700 Subject: [PATCH 1/2] wpa_supplicant: Fix detection of open networks --- internal/wifi/wpasupplicant/bss.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/internal/wifi/wpasupplicant/bss.go b/internal/wifi/wpasupplicant/bss.go index 799e9f9..ab1b5b7 100644 --- a/internal/wifi/wpasupplicant/bss.go +++ b/internal/wifi/wpasupplicant/bss.go @@ -137,13 +137,13 @@ func (b *BSS) GetSignal() (int16, error) { // DetermineSecurityType determines the security type based on BSS properties func (p *BSSProperties) DetermineSecurityType() string { - // Check for WPA2 (RSN) - if len(p.RSN) > 0 { + // Check for WPA2 (RSN) - need to check if KeyMgmt has actual values + if hasKeyManagement(p.RSN) { return "psk" } // Check for WPA - if len(p.WPA) > 0 { + if hasKeyManagement(p.WPA) { return "psk" } @@ -155,3 +155,20 @@ func (p *BSSProperties) DetermineSecurityType() string { // Open network return "open" } + +// hasKeyManagement checks if a WPA/RSN map contains actual key management methods +func hasKeyManagement(secMap map[string]dbus.Variant) bool { + if len(secMap) == 0 { + return false + } + + // Check if KeyMgmt field exists and has values + if keyMgmtVariant, ok := secMap["KeyMgmt"]; ok { + // KeyMgmt is an array of strings + if keyMgmt, ok := keyMgmtVariant.Value().([]string); ok { + return len(keyMgmt) > 0 + } + } + + return false +} From 5532457cdf7252972f9776ce7bf60fdb9c51accf Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 2 Jan 2026 17:54:07 +0700 Subject: [PATCH 2/2] wpa_supplicant: Fix connection --- internal/wifi/wpasupplicant/backend.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/wifi/wpasupplicant/backend.go b/internal/wifi/wpasupplicant/backend.go index 406b8f5..4fa8e8b 100644 --- a/internal/wifi/wpasupplicant/backend.go +++ b/internal/wifi/wpasupplicant/backend.go @@ -154,11 +154,11 @@ func (b *WPABackend) IsScanning() (bool, error) { func (b *WPABackend) Connect(ssid, password string) error { // Create network configuration config := make(map[string]interface{}) - config["ssid"] = fmt.Sprintf("\"%s\"", ssid) // wpa_supplicant expects quoted SSID + config["ssid"] = ssid // Raw SSID string, no quotes if password != "" { // For WPA/WPA2-PSK networks - config["psk"] = fmt.Sprintf("\"%s\"", password) + config["psk"] = password // Raw password string, no quotes } else { // For open networks config["key_mgmt"] = "NONE"