Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:hschaa:wireless
wpa_supplicant
wpa_supplicant-dbus-blobs.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File wpa_supplicant-dbus-blobs.patch of Package wpa_supplicant
Index: wpa_supplicant-0.5.8/config.c =================================================================== --- wpa_supplicant-0.5.8.orig/config.c +++ wpa_supplicant-0.5.8/config.c @@ -70,13 +70,14 @@ static char * wpa_config_parse_string(co if (hlen & 1) return NULL; *len = hlen / 2; - str = os_malloc(*len); + str = os_malloc(*len + 1); if (str == NULL) return NULL; if (hexstr2bin(value, str, *len)) { os_free(str); return NULL; } + str[*len] = '\0'; return (char *) str; } } Index: wpa_supplicant-0.5.8/ctrl_iface_dbus.c =================================================================== --- wpa_supplicant-0.5.8.orig/ctrl_iface_dbus.c +++ wpa_supplicant-0.5.8/ctrl_iface_dbus.c @@ -536,6 +536,10 @@ static DBusHandlerResult wpas_iface_mess reply = wpas_dbus_iface_set_ap_scan(message, wpa_s); else if (!strcmp(method, "state")) reply = wpas_dbus_iface_get_state(message, wpa_s); + else if (!strcmp(method, "setBlobs")) + reply = wpas_dbus_iface_set_blobs(message, wpa_s); + else if (!strcmp(method, "removeBlobs")) + reply = wpas_dbus_iface_remove_blobs(message, wpa_s); } /* If the message was handled, send back the reply */ Index: wpa_supplicant-0.5.8/ctrl_iface_dbus_handlers.c =================================================================== --- wpa_supplicant-0.5.8.orig/ctrl_iface_dbus_handlers.c +++ wpa_supplicant-0.5.8/ctrl_iface_dbus_handlers.c @@ -1203,3 +1203,129 @@ DBusMessage * wpas_dbus_iface_get_state( return reply; } + + +/** + * wpas_dbus_iface_set_blobs - Store named binary blobs (ie, for certificates) + * @message: Pointer to incoming dbus message + * @global: %wpa_supplicant global data structure + * Returns: A dbus message containing a UINT32 indicating success (1) or + * failure (0) + * + * Asks wpa_supplicant to internally store a one or more binary blobs. + */ +DBusMessage * wpas_dbus_iface_set_blobs(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + DBusMessage *reply = NULL; + struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING }; + DBusMessageIter iter, iter_dict; + + dbus_message_iter_init(message, &iter); + + if (!wpa_dbus_dict_open_read(&iter, &iter_dict)) + return wpas_dbus_new_invalid_opts_error(message, NULL); + + while (wpa_dbus_dict_has_dict_entry(&iter_dict)) { + struct wpa_config_blob *blob; + + if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) { + reply = wpas_dbus_new_invalid_opts_error(message, NULL); + break; + } + + if (entry.type != DBUS_TYPE_ARRAY || + entry.array_type != DBUS_TYPE_BYTE) { + reply = wpas_dbus_new_invalid_opts_error(message, + "Byte array expected."); + break; + } + + if ( (entry.array_len <= 0) + || (entry.array_len > 65536) + || !strlen(entry.key)) { + reply = wpas_dbus_new_invalid_opts_error(message, + "Invalid array size."); + break; + } + + blob = os_zalloc(sizeof(*blob)); + if (blob == NULL) { + reply = dbus_message_new_error(message, + WPAS_ERROR_ADD_ERROR, + "Not enough memory to add blob."); + break; + } + blob->data = os_zalloc(entry.array_len); + if (blob->data == NULL) { + reply = dbus_message_new_error(message, + WPAS_ERROR_ADD_ERROR, + "Not enough memory to add blob data."); + os_free(blob); + break; + } + + blob->name = os_strdup(entry.key); + blob->len = entry.array_len; + os_memcpy(blob->data, (u8 *) entry.bytearray_value, + entry.array_len); + if (blob->name == NULL || blob->data == NULL) { + wpa_config_free_blob(blob); + reply = dbus_message_new_error(message, + WPAS_ERROR_ADD_ERROR, + "Error adding blob."); + break; + } + + /* Success */ + wpa_config_remove_blob(wpa_s->conf, blob->name); + wpa_config_set_blob(wpa_s->conf, blob); + wpa_dbus_dict_entry_clear(&entry); + } + wpa_dbus_dict_entry_clear(&entry); + + return reply ? reply : wpas_dbus_new_success_reply(message);; +} + +/** + * wpas_dbus_iface_remove_blob - Remove named binary blobs + * @message: Pointer to incoming dbus message + * @global: %wpa_supplicant global data structure + * Returns: A dbus message containing a UINT32 indicating success (1) or + * failure (0) + * + * Asks wpa_supplicant to remove one or more previously stored binary blobs. + */ +DBusMessage * wpas_dbus_iface_remove_blobs(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + DBusMessageIter iter, array; + char *err_msg = NULL; + + dbus_message_iter_init(message, &iter); + + if ((dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY) + || (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_STRING)) + return wpas_dbus_new_invalid_opts_error(message, NULL); + + dbus_message_iter_recurse(&iter, &array); + while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) { + const char *name; + + dbus_message_iter_get_basic(&array, &name); + if (!strlen(name)) + err_msg = "Invalid blob name."; + + if (wpa_config_remove_blob(wpa_s->conf, name) != 0) + err_msg = "Error removing blob."; + dbus_message_iter_next(&array); + } + + if (err_msg) { + return dbus_message_new_error(message, WPAS_ERROR_REMOVE_ERROR, + err_msg); + } + + return wpas_dbus_new_success_reply(message); +} + Index: wpa_supplicant-0.5.8/ctrl_iface_dbus_handlers.h =================================================================== --- wpa_supplicant-0.5.8.orig/ctrl_iface_dbus_handlers.h +++ wpa_supplicant-0.5.8/ctrl_iface_dbus_handlers.h @@ -71,6 +71,12 @@ DBusMessage * wpas_dbus_iface_set_ap_sca DBusMessage * wpas_dbus_iface_get_state(DBusMessage *message, struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_iface_set_blobs(DBusMessage *message, + struct wpa_supplicant *wpa_s); + +DBusMessage * wpas_dbus_iface_remove_blobs(DBusMessage *message, + struct wpa_supplicant *wpa_s); + #endif /* CONFIG_CTRL_IFACE_DBUS */ #endif /* CTRL_IFACE_DBUS_HANDLERS_H */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor