Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: wpa_supplicant/dbus/dbus_new_handlers.c

Issue 6783033: CHROMIUMOS: wpa_supplicant: Accept raw PMK in new DBus API (Closed) Base URL: ssh://gitrw.chromium.org:9222/hostap.git@master
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * WPA Supplicant / dbus-based control interface 2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc. 3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com> 4 * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
5 * Copyright (c) 2009, Jouni Malinen <j@w1.fi> 5 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 * 10 *
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return reply; 188 return reply;
189 } 189 }
190 190
191 191
192 static const char *dont_quote[] = { 192 static const char *dont_quote[] = {
193 "key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap", 193 "key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
194 "opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path", 194 "opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
195 "bssid", NULL 195 "bssid", NULL
196 }; 196 };
197 197
198 static dbus_bool_t should_quote_opt(const char *key) 198 static dbus_bool_t should_quote_opt(const char *key,
199 » » » » size_t value_length,
200 » » » » char *value)
199 { 201 {
200 int i = 0; 202 int i = 0;
201 while (dont_quote[i] != NULL) { 203 while (dont_quote[i] != NULL) {
202 if (os_strcmp(key, dont_quote[i]) == 0) 204 if (os_strcmp(key, dont_quote[i]) == 0)
203 return FALSE; 205 return FALSE;
204 i++; 206 i++;
205 } 207 }
208
209 /*
210 * Do not quote psk value which is a raw key.
211 */
212 if ((os_strcmp(key, "psk") == 0) && (value_length == PMK_LEN*2)) {
213 u8 tmp_buf[PMK_LEN];
214
215 if (hexstr2bin(value, tmp_buf, PMK_LEN) == 0)
216 return FALSE;
217 }
218
206 return TRUE; 219 return TRUE;
207 } 220 }
208 221
209 /** 222 /**
210 * get_iface_by_dbus_path - Get a new network interface 223 * get_iface_by_dbus_path - Get a new network interface
211 * @global: Pointer to global data from wpa_supplicant_init() 224 * @global: Pointer to global data from wpa_supplicant_init()
212 * @path: Pointer to a dbus object path representing an interface 225 * @path: Pointer to a dbus object path representing an interface
213 * Returns: Pointer to the interface or %NULL if not found 226 * Returns: Pointer to the interface or %NULL if not found
214 */ 227 */
215 static struct wpa_supplicant * get_iface_by_dbus_path( 228 static struct wpa_supplicant * get_iface_by_dbus_path(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 value = os_zalloc(size); 279 value = os_zalloc(size);
267 if (value == NULL) 280 if (value == NULL)
268 goto error; 281 goto error;
269 282
270 ret = wpa_snprintf_hex(value, size, 283 ret = wpa_snprintf_hex(value, size,
271 (u8 *) entry.bytearray_value, 284 (u8 *) entry.bytearray_value,
272 entry.array_len); 285 entry.array_len);
273 if (ret <= 0) 286 if (ret <= 0)
274 goto error; 287 goto error;
275 } else if (entry.type == DBUS_TYPE_STRING) { 288 } else if (entry.type == DBUS_TYPE_STRING) {
276 » » » if (should_quote_opt(entry.key)) { 289 » » » size = os_strlen(entry.str_value);
277 » » » » size = os_strlen(entry.str_value); 290 » » » if (size <= 0)
278 » » » » if (size <= 0) 291 » » » » goto error;
279 » » » » » goto error;
280 292
293 if (should_quote_opt(entry.key, size,
294 entry.str_value)) {
281 size += 3; 295 size += 3;
282 value = os_zalloc(size); 296 value = os_zalloc(size);
283 if (value == NULL) 297 if (value == NULL)
284 goto error; 298 goto error;
285 299
286 ret = os_snprintf(value, size, "\"%s\"", 300 ret = os_snprintf(value, size, "\"%s\"",
287 entry.str_value); 301 entry.str_value);
288 if (ret < 0 || (size_t) ret != (size - 1)) 302 if (ret < 0 || (size_t) ret != (size - 1))
289 goto error; 303 goto error;
290 } else { 304 } else {
(...skipping 2870 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 dbus_message_iter_recurse(&iter, &variant_iter); 3175 dbus_message_iter_recurse(&iter, &variant_iter);
3162 3176
3163 reply = set_network_properties(message, net->wpa_s, ssid, 3177 reply = set_network_properties(message, net->wpa_s, ssid,
3164 &variant_iter); 3178 &variant_iter);
3165 if (reply) 3179 if (reply)
3166 wpa_printf(MSG_DEBUG, "dbus control interface couldn't set " 3180 wpa_printf(MSG_DEBUG, "dbus control interface couldn't set "
3167 "network properties"); 3181 "network properties");
3168 3182
3169 return reply; 3183 return reply;
3170 } 3184 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698