[PATCH 1/3] Revert "wifi: disable Ad-Hoc WPA connections (lp:905748)"

2013-01-30 Thread Stanislaw Gruszka
From: Nicolas Cavallari 

From: Nicolas Cavallari 

This reverts commit 69247a00eacd00617acbf1dfcee8497437b8ad39,
which disabled all security in Ad-Hoc networks, due to a bug
of wpa_supplicant that only affected WPA-None.
---
 libnm-util/nm-utils.c  |  4 
 src/nm-device-wifi.c   | 60 --
 src/settings/nm-settings.c | 45 --
 3 files changed, 109 deletions(-)

diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 51ddfeb..40bd67a 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -1323,8 +1323,6 @@ 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) {
@@ -1351,8 +1349,6 @@ 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) {
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index 9101f4d..8a23e1b 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -999,36 +999,6 @@ deactivate (NMDevice *dev)
 }
 
 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
 check_connection_compatible (NMDevice *device,
  NMConnection *connection,
  GError **error)
@@ -1086,14 +1056,6 @@ check_connection_compatible (NMDevice *device,
}
}
 
-   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;
-   }
-
/* Early exit if supplicant or device don't support AP mode */
if (g_strcmp0 (nm_setting_wireless_get_mode (s_wireless), 
NM_SETTING_WIRELESS_MODE_AP) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP)) {
@@ -1312,18 +1274,6 @@ 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);
@@ -3003,16 +2953,6 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason 
*reason)
}
g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_MODE);
 
-   /* 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 i

[PATCH 1/3] Revert "wifi: disable Ad-Hoc WPA connections (lp:905748)"

2012-08-09 Thread Nicolas . Cavallari
From: Nicolas Cavallari 

This reverts commit 69247a00eacd00617acbf1dfcee8497437b8ad39,
which disabled all security in Ad-Hoc networks, due to a bug
of wpa_supplicant that only affected WPA-None.
---
 libnm-util/nm-utils.c  |4 ---
 src/nm-device-wifi.c   |   60 
 src/settings/nm-settings.c |   45 -
 3 files changed, 109 deletions(-)

diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 65bbd25..607c0e6 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -1285,8 +1285,6 @@ 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) {
@@ -1313,8 +1311,6 @@ 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) {
diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index e2ff77e..0809ce0 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -967,36 +967,6 @@ real_deactivate (NMDevice *dev)
 }
 
 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,
   GError **error)
@@ -1054,14 +1024,6 @@ real_check_connection_compatible (NMDevice *device,
}
}
 
-   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;
-   }
-
// FIXME: check channel/freq/band against bands the hardware supports
// FIXME: check encryption against device capabilities
// FIXME: check bitrate against device capabilities
@@ -1222,18 +1184,6 @@ 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);
@@ -2789,16 +2739,6 @@ 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;
-   }
-