Skip to content

Commit

Permalink
fixup! wireless: set security from key_mgmt or guess
Browse files Browse the repository at this point in the history
  • Loading branch information
cfconrad committed Sep 27, 2024
1 parent b222551 commit 27f714a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions rust/migrate-wicked/src/wireless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,34 +446,31 @@ fn guess_wireless_security_protocol(
) -> Result<model::SecurityProtocol, anyhow::Error> {
let mgmt = &network.key_management;

let v = if any(mgmt, &["wpa-eap", "wpa-eap-sha256"]) {
Ok(model::SecurityProtocol::WPA2Enterprise)
let result = if any(mgmt, &["wpa-eap", "wpa-eap-sha256"]) {
model::SecurityProtocol::WPA2Enterprise
} else if any(mgmt, &["wpa-eap-suite-b-192", "wpa-eap-suite-b"]) {
Ok(model::SecurityProtocol::WPA3Only)
model::SecurityProtocol::WPA3Only
} else if any(mgmt, &["wpa-psk", "wpa-psk-sha256"]) {
Ok(model::SecurityProtocol::WPA2)
model::SecurityProtocol::WPA2
} else if any(mgmt, &["sae", "ft-sae"]) {
Ok(model::SecurityProtocol::WPA3Personal)
model::SecurityProtocol::WPA3Personal
} else if any(mgmt, &["owe"]) {
Ok(model::SecurityProtocol::OWE)
model::SecurityProtocol::OWE
} else if any(mgmt, &["none"]) {
Ok(model::SecurityProtocol::WEP)
model::SecurityProtocol::WEP
} else if network.wpa_eap.is_some() {
Ok(model::SecurityProtocol::WPA2Enterprise)
model::SecurityProtocol::WPA2Enterprise
} else if network.wpa_psk.is_some() {
Ok(model::SecurityProtocol::WPA2)
model::SecurityProtocol::WPA2
} else {
Ok(model::SecurityProtocol::WEP)
model::SecurityProtocol::WEP
};
log::warn!(
"Unsupported key-management protocol(s) '{}' guessing '{}'",
mgmt.join(","),
match v {
Ok(s) => s.to_string(),
_ => "-".to_string(),
}
result
);
v
Ok(result)
}

fn wireless_security_protocol(network: &Network) -> Result<model::SecurityProtocol, anyhow::Error> {
Expand Down

0 comments on commit 27f714a

Please sign in to comment.