Fix enterprise Wi-Fi connections and known network prompts

This commit is contained in:
SirBlob committed 2026-10-04 02:24:47 -04:00
1 parent 7cdfbebc9e
commit 979de57fff
2 files changed
+30 -12

No files matched your search

+4 -1
View File
@@ -320,10 +320,12 @@ var enterpriseConnectScript =
"u=$(uuidgen); IFS= read -r pw; server_check=();" + "u=$(uuidgen); IFS= read -r pw; server_check=();" +
" [ -n \"$5\" ] && server_check=(802-1x.system-ca-certs yes 802-1x.domain-suffix-match \"$5\");" + " [ -n \"$5\" ] && server_check=(802-1x.system-ca-certs yes 802-1x.domain-suffix-match \"$5\");" +
" nmcli connection add type wifi con-name \"$1\" ssid \"$1\" connection.uuid \"$u\"" + " nmcli connection add type wifi con-name \"$1\" ssid \"$1\" connection.uuid \"$u\"" +
" connection.autoconnect no" +
" wifi-sec.key-mgmt wpa-eap 802-1x.eap \"$3\" 802-1x.phase2-auth \"$4\"" + " wifi-sec.key-mgmt wpa-eap 802-1x.eap \"$3\" 802-1x.phase2-auth \"$4\"" +
" 802-1x.identity \"$2\" 802-1x.auth-timeout 8 \"${server_check[@]}\" >/dev/null" + " 802-1x.identity \"$2\" 802-1x.auth-timeout 8 \"${server_check[@]}\" >/dev/null" +
" && printf 'set 802-1x.password %s\\nsave\\nquit\\n' \"$pw\" | nmcli connection edit uuid \"$u\" >/dev/null" + " && printf 'set 802-1x.password %s\\nsave\\nquit\\n' \"$pw\" | nmcli connection edit uuid \"$u\" >/dev/null" +
" && nmcli connection up uuid \"$u\"" + " && nmcli connection up uuid \"$u\"" +
" && { nmcli connection modify uuid \"$u\" connection.autoconnect yes; true; }" +
" || { nmcli connection delete uuid \"$u\" >/dev/null 2>&1; false; }" " || { nmcli connection delete uuid \"$u\" >/dev/null 2>&1; false; }"
var eapMethods = [ var eapMethods = [
@@ -342,8 +344,9 @@ function isEnterpriseSecurity(security, enterpriseSecurityTypes) {
return (enterpriseSecurityTypes || []).indexOf(security) !== -1 return (enterpriseSecurityTypes || []).indexOf(security) !== -1
} }
function networkFailureReason(reason, needsCredentials, reasons) { function networkFailureReason(reason, needsCredentials, reasons, isEnterprise) {
var r = reasons || {} var r = reasons || {}
if (isEnterprise && (reason === r.NoSecrets || reason === r.WifiAuthTimeout)) return "Wrong identity or password"
if (needsCredentials && reason === r.NoSecrets) return "Passphrase required" if (needsCredentials && reason === r.NoSecrets) return "Passphrase required"
if (needsCredentials && reason === r.WifiAuthTimeout) return "Wrong password" if (needsCredentials && reason === r.WifiAuthTimeout) return "Wrong password"
if (reason === r.WifiNetworkLost) return "Network lost" if (reason === r.WifiNetworkLost) return "Network lost"
+26 -11
View File
@@ -442,7 +442,7 @@ Panel {
// connectedWifiNetwork when handed null, so a row left stale by scan churn // connectedWifiNetwork when handed null, so a row left stale by scan churn
// would otherwise tear down whatever is connected now instead. // would otherwise tear down whatever is connected now instead.
if (net.connected) { disconnectRow(net.ssid); return } if (net.connected) { disconnectRow(net.ssid); return }
if (requiresCredentials(net.security) && !net.known) { openPasswordPrompt(net.ssid); return } if (needsCredentialPrompt(net)) { openPasswordPrompt(net.ssid); return }
connectDirectly(net.ssid) connectDirectly(net.ssid)
} }
@@ -698,6 +698,12 @@ Panel {
return Model.requiresCredentials(security, WifiSecurityType.Open, WifiSecurityType.Owe) return Model.requiresCredentials(security, WifiSecurityType.Open, WifiSecurityType.Owe)
} }
function needsCredentialPrompt(row) {
if (!row || !requiresCredentials(row.security)) return false
var liveNetwork = networkForSsid(row.ssid)
return !(row.known && liveNetwork && liveNetwork.known)
}
function openPasswordPrompt(ssid) { function openPasswordPrompt(ssid) {
var network = networkForSsid(ssid) var network = networkForSsid(ssid)
if (network && network.security === WifiSecurityType.Wpa3SuiteB192) { if (network && network.security === WifiSecurityType.Wpa3SuiteB192) {
@@ -757,14 +763,14 @@ Panel {
if (!network || actionKind === "" || actionSsid !== (network.name || "")) return if (!network || actionKind === "" || actionSsid !== (network.name || "")) return
actionTimeout.stop() actionTimeout.stop()
failureSsid = actionSsid failureSsid = actionSsid
failureReason = networkFailureReason(reason, requiresCredentials(network.security)) failureReason = networkFailureReason(reason, requiresCredentials(network.security), isEnterpriseSecurity(network.security))
actionSsid = "" actionSsid = ""
actionKind = "" actionKind = ""
refresh() refresh()
} }
function networkFailureReason(reason, needsCredentials) { function networkFailureReason(reason, needsCredentials, isEnterprise) {
return Model.networkFailureReason(reason, needsCredentials, connectionFailReasons) return Model.networkFailureReason(reason, needsCredentials, connectionFailReasons, isEnterprise)
} }
function shouldRepromptPassphrase(reason, needsCredentials) { function shouldRepromptPassphrase(reason, needsCredentials) {
@@ -791,7 +797,7 @@ Panel {
var method = Model.eapMethodFor(root.eapMethod) var method = Model.eapMethodFor(root.eapMethod)
enterpriseConnect.secret = passphrase enterpriseConnect.secret = passphrase
enterpriseConnect.command = ["bash", "-c", Model.enterpriseConnectScript, "nmcli-eap", enterpriseConnect.command = ["bash", "-c", Model.enterpriseConnectScript, "nmcli-eap",
ssid, identity, method.eap, method.phase2, root.serverDomainText.trim()] ssid, identity.trim(), method.eap, method.phase2, root.serverDomainText.trim()]
enterpriseConnect.running = true enterpriseConnect.running = true
}) })
} }
@@ -807,10 +813,16 @@ Panel {
secret = "" secret = ""
} }
onExited: function(exitCode) { onExited: function(exitCode) {
if (exitCode !== 0 && root.actionKind === "connect") root.failNetworkAction(root.networkForSsid(root.actionSsid), -1) if (exitCode !== 0 && root.actionKind === "connect") enterpriseFailFallback.restart()
} }
} }
Timer {
id: enterpriseFailFallback
interval: 500
onTriggered: if (root.actionKind === "connect") root.failNetworkAction(root.networkForSsid(root.actionSsid), -1)
}
function disconnect(network) { function disconnect(network) {
runNetworkAction("disconnect", network || connectedWifiNetwork, function(net) { net.disconnect() }) runNetworkAction("disconnect", network || connectedWifiNetwork, function(net) { net.disconnect() })
} }
@@ -1648,7 +1660,7 @@ Panel {
function submitCredentials() { function submitCredentials() {
if (!net || root.busy || root.passwordText.length === 0) return if (!net || root.busy || root.passwordText.length === 0) return
if (!isEnterprise) return root.connectWithPassphrase(net.ssid, root.passwordText) if (!isEnterprise) return root.connectWithPassphrase(net.ssid, root.passwordText)
if (root.identityText.length > 0) root.connectEnterprise(net.ssid, root.identityText, root.passwordText) if (root.identityText.trim().length > 0) root.connectEnterprise(net.ssid, root.identityText, root.passwordText)
} }
Connections { Connections {
@@ -1657,9 +1669,12 @@ Panel {
// Background auto-connect retries fire this too; only reprompt for // Background auto-connect retries fire this too; only reprompt for
// the connect started from this panel. Checked before // the connect started from this panel. Checked before
// failNetworkAction, which clears the action state. // failNetworkAction, which clears the action state.
var ours = root.actionKind === "connect" && root.actionSsid === (row.net.ssid || "") var panel = root
root.failNetworkAction(root.networkForSsid(row.net.ssid), reason) var ssid = row.net.ssid || ""
if (ours && root.shouldRepromptPassphrase(reason, row.requiresCredentials)) root.openPasswordPrompt(row.net.ssid) var ours = panel.actionKind === "connect" && panel.actionSsid === ssid
var reprompt = ours && panel.shouldRepromptPassphrase(reason, row.requiresCredentials)
panel.failNetworkAction(panel.networkForSsid(ssid), reason)
if (reprompt) panel.openPasswordPrompt(ssid)
} }
function onConnectedChanged() { function onConnectedChanged() {
if (row.net) root.checkActionCompletion(root.networkForSsid(row.net.ssid)) if (row.net) root.checkActionCompletion(root.networkForSsid(row.net.ssid))
@@ -1720,7 +1735,7 @@ Panel {
root.disconnectRow(row.net.ssid) root.disconnectRow(row.net.ssid)
return return
} }
if (row.requiresCredentials && !row.isKnown) { if (root.needsCredentialPrompt(row.net)) {
root.openPasswordPrompt(row.net.ssid) root.openPasswordPrompt(row.net.ssid)
return return
} }