From 87bad8afad46a418ee7a4de4c8acd7e670c137d9 Mon Sep 17 00:00:00 2001 From: Jintao Lin Date: Tue, 6 Dec 2022 00:37:04 +0000 Subject: [PATCH] dbus: Pass in MAC address in CreateInterface method chromeOS uses random generated MAC address for AP interface so that the device could remain anonymous and untrackable. Add an address parameter for CreateInterface method to pass in OS managed MAC address. Signed-off-by: Jintao Lin --- doc/dbus.doxygen | 1 + wpa_supplicant/dbus/dbus_new_handlers.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 3fc3146a7..7950c9b2e 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -43,6 +43,7 @@ registered in the bus with fi.w1.wpa_supplicant1 name. ConfigFilesConfiguration file pathNo CreatebWhether to create a new interface in the kernelNo TypesInterface type to create (sta or ap)No + AddresssMAC address in colon-delimited format to be used in the created interfaceNo diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index d2c78ecfa..83f46a9eb 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -774,6 +774,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, char *confname = NULL; char *bridge_ifname = NULL; bool create_iface = false; + u8 *if_addr = NULL; enum wpa_driver_if_type if_type = WPA_IF_STATION; dbus_message_iter_init(message, &iter); @@ -826,6 +827,18 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, goto error; } wpa_dbus_dict_entry_clear(&entry); + } else if (os_strcmp(entry.key, "Address") == 0 && + entry.type == DBUS_TYPE_STRING) { + if_addr = os_malloc(ETH_ALEN); + if (if_addr == NULL) { + wpa_dbus_dict_entry_clear(&entry); + goto oom; + } + if (hwaddr_aton(entry.str_value, if_addr)) { + wpa_dbus_dict_entry_clear(&entry); + goto error; + } + wpa_dbus_dict_entry_clear(&entry); } else { wpa_dbus_dict_entry_clear(&entry); goto error; @@ -855,7 +868,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, __func__, ifname); if (!global->ifaces || wpa_drv_if_add(global->ifaces, if_type, ifname, - NULL, NULL, NULL, mac_addr, + if_addr, NULL, NULL, mac_addr, NULL) < 0) { reply = wpas_dbus_error_unknown_error( message, @@ -895,6 +908,7 @@ out: os_free(ifname); os_free(confname); os_free(bridge_ifname); + os_free(if_addr); return reply; error: