1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
Description: disable WPA-secured adhoc wireless networks
Origin: backport, http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=69247a00eacd00617acbf1dfcee8497437b8ad39
Origin: backport, http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=8126947e088462439740d18e9a2e77005d499ce1
Origin: backport, http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=47f9eb80d81c5e4a2761e1507ba47ce8bae493db
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/905748
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655972
Index: network-manager/libnm-util/nm-utils.c
===================================================================
--- network-manager.orig/libnm-util/nm-utils.c 2012-08-22 13:22:20.060415083 +0200
+++ network-manager/libnm-util/nm-utils.c 2012-08-22 20:51:21.661305882 +0200
@@ -1216,6 +1216,8 @@
}
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) {
@@ -1232,6 +1234,8 @@
}
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) {
Index: network-manager/src/nm-device-wifi.c
===================================================================
--- network-manager.orig/src/nm-device-wifi.c 2012-08-22 13:22:20.104415512 +0200
+++ network-manager/src/nm-device-wifi.c 2012-08-22 20:51:21.673306001 +0200
@@ -1201,6 +1201,36 @@
}
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_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+ g_return_val_if_fail (s_wifi != NULL, FALSE);
+
+ mode = nm_setting_wireless_get_mode (s_wifi);
+ if (g_strcmp0 (mode, "adhoc") != 0)
+ return FALSE;
+
+ s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+ 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)
@@ -1237,6 +1267,14 @@
return FALSE;
}
+ 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
@@ -3027,6 +3065,16 @@
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;
+ }
+
/* Find a compatible AP in the scan list */
for (iter = priv->ap_list; iter; iter = g_slist_next (iter)) {
NMAccessPoint *candidate = NM_AP (iter->data);
Index: network-manager/src/system-settings/nm-sysconfig-settings.c
===================================================================
--- network-manager.orig/src/system-settings/nm-sysconfig-settings.c 2012-08-22 13:22:20.112415589 +0200
+++ network-manager/src/system-settings/nm-sysconfig-settings.c 2012-08-22 20:51:21.697306240 +0200
@@ -683,6 +683,38 @@
g_object_unref (pk_result);
}
+/* 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_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+ if (!s_wifi)
+ return FALSE;
+
+ mode = nm_setting_wireless_get_mode (s_wifi);
+ if (g_strcmp0 (mode, "adhoc") != 0)
+ return FALSE;
+
+ s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+ 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 void
add_connection (NMSettingsService *service,
NMConnection *connection,
@@ -695,6 +727,19 @@
PolkitCall *call;
GError *error = NULL;
+ /* 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_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
+ "WPA Ad-Hoc disabled due to kernel bugs");
+ callback (NM_SETTINGS_INTERFACE (service), error, 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_SYSCONFIG_SETTINGS_ERROR,
|