mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 07:40:28 +01:00
wifi: disable Ad-Hoc WPA connections (lp:905748)
The kernel is broken for Ad-Hoc WPA, and creates the connections as open connections instead. Yeah, eventually we can use wpa_supplicant with RSN support, but for now we just have to disable Ad-Hoc WPA because it's a problem to say we're creating a protected network but then have the kernel not do that for us. Will be re-enabled once all the necessary bits have been fixed. Note that Ad-Hoc WPA has been broken since at least 2.6.32 with mac80211-based drivers, which is what most users will be using.
This commit is contained in:
parent
c455eafbef
commit
69247a00ea
3 changed files with 108 additions and 0 deletions
|
|
@ -1285,6 +1285,8 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
}
|
||||
break;
|
||||
case NMU_SEC_WPA_PSK:
|
||||
if (adhoc)
|
||||
return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */
|
||||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
|
|
@ -1311,6 +1313,8 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
}
|
||||
break;
|
||||
case NMU_SEC_WPA2_PSK:
|
||||
if (adhoc)
|
||||
return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */
|
||||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
|
|
|
|||
|
|
@ -971,6 +971,36 @@ real_deactivate (NMDevice *dev)
|
|||
wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_adhoc_wpa (NMConnection *connection)
|
||||
{
|
||||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
const char *mode, *key_mgmt;
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
* and turns them into open networks. It's been this way since at least
|
||||
* 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
|
||||
*/
|
||||
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_return_val_if_fail (s_wifi != NULL, FALSE);
|
||||
|
||||
mode = nm_setting_wireless_get_mode (s_wifi);
|
||||
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) != 0)
|
||||
return FALSE;
|
||||
|
||||
s_wsec = nm_connection_get_setting_wireless_security (connection);
|
||||
if (!s_wsec)
|
||||
return FALSE;
|
||||
|
||||
key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
|
||||
if (g_strcmp0 (key_mgmt, "wpa-none") != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_check_connection_compatible (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
|
|
@ -983,6 +1013,14 @@ real_check_connection_compatible (NMDevice *device,
|
|||
const GByteArray *mac;
|
||||
const GSList *mac_blacklist, *mac_blacklist_iter;
|
||||
|
||||
if (is_adhoc_wpa (connection)) {
|
||||
g_set_error_literal (error,
|
||||
NM_WIFI_ERROR,
|
||||
NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
|
||||
"WPA Ad-Hoc disabled due to kernel bugs");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
|
|
@ -1188,6 +1226,18 @@ real_complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
* and turns them into open networks. It's been this way since at least
|
||||
* 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
|
||||
*/
|
||||
if (is_adhoc_wpa (connection)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
"WPA Ad-Hoc disabled due to kernel bugs");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (ssid);
|
||||
str_ssid = nm_utils_ssid_to_utf8 (ssid);
|
||||
format = g_strdup_printf ("%s %%d", str_ssid);
|
||||
|
|
@ -2595,6 +2645,16 @@ real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
connection = nm_act_request_get_connection (req);
|
||||
g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
* and turns them into open networks. It's been this way since at least
|
||||
* 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
|
||||
*/
|
||||
if (is_adhoc_wpa (connection)) {
|
||||
nm_log_warn (LOGD_WIFI, "Ad-Hoc WPA disabled due to kernel bugs");
|
||||
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
||||
/* Set spoof MAC to the interface */
|
||||
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wireless);
|
||||
|
|
|
|||
|
|
@ -1035,6 +1035,37 @@ add_cb (NMSettings *self,
|
|||
dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection)));
|
||||
}
|
||||
|
||||
/* FIXME: remove if/when kernel supports adhoc wpa */
|
||||
static gboolean
|
||||
is_adhoc_wpa (NMConnection *connection)
|
||||
{
|
||||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
const char *mode, *key_mgmt;
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
* and turns them into open networks. It's been this way since at least
|
||||
* 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
|
||||
*/
|
||||
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_return_val_if_fail (s_wifi != NULL, FALSE);
|
||||
|
||||
mode = nm_setting_wireless_get_mode (s_wifi);
|
||||
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) != 0)
|
||||
return FALSE;
|
||||
|
||||
s_wsec = nm_connection_get_setting_wireless_security (connection);
|
||||
if (!s_wsec)
|
||||
return FALSE;
|
||||
|
||||
key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
|
||||
if (g_strcmp0 (key_mgmt, "wpa-none") != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nm_settings_add_connection (NMSettings *self,
|
||||
NMConnection *connection,
|
||||
|
|
@ -1062,6 +1093,19 @@ nm_settings_add_connection (NMSettings *self,
|
|||
return;
|
||||
}
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
* and turns them into open networks. It's been this way since at least
|
||||
* 2.6.30 or so; until that's fixed, disable WPA-protected Ad-Hoc networks.
|
||||
*/
|
||||
if (is_adhoc_wpa (connection)) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"WPA Ad-Hoc disabled due to kernel bugs");
|
||||
callback (self, NULL, error, context, user_data);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do any of the plugins support adding? */
|
||||
if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue