mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 08:48:31 -05:00
dbus: Fix D-Bus network and BSS object registration/unregistration
Do not try to unregister BSS objects twice (the latter one with invalid path) and make sure all network objects get added and removed properly (the ones read from configuration file were not being registered, but were tried to be unregistered).
This commit is contained in:
parent
c2f5126941
commit
8e56d18993
@ -1062,6 +1062,8 @@ static struct ctrl_iface_dbus_new_priv * wpas_dbus_ctrl_iface_init(
|
|||||||
wpas_dbus_global_properties,
|
wpas_dbus_global_properties,
|
||||||
wpas_dbus_global_signals);
|
wpas_dbus_global_signals);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
|
||||||
|
WPAS_DBUS_NEW_PATH);
|
||||||
ctrl_iface = wpa_dbus_ctrl_iface_init(global, WPAS_DBUS_NEW_PATH,
|
ctrl_iface = wpa_dbus_ctrl_iface_init(global, WPAS_DBUS_NEW_PATH,
|
||||||
WPAS_DBUS_NEW_SERVICE,
|
WPAS_DBUS_NEW_SERVICE,
|
||||||
obj_desc);
|
obj_desc);
|
||||||
@ -1084,6 +1086,8 @@ static struct ctrl_iface_dbus_new_priv * wpas_dbus_ctrl_iface_init(
|
|||||||
static void wpas_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_new_priv *iface)
|
static void wpas_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_new_priv *iface)
|
||||||
{
|
{
|
||||||
if (iface) {
|
if (iface) {
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
|
||||||
|
WPAS_DBUS_NEW_PATH);
|
||||||
dbus_connection_unregister_object_path(iface->con,
|
dbus_connection_unregister_object_path(iface->con,
|
||||||
WPAS_DBUS_NEW_PATH);
|
WPAS_DBUS_NEW_PATH);
|
||||||
wpa_dbus_ctrl_iface_deinit(iface);
|
wpa_dbus_ctrl_iface_deinit(iface);
|
||||||
@ -1135,6 +1139,8 @@ static int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
|
|||||||
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
||||||
wpas_dbus_get_path(wpa_s), ssid->id);
|
wpas_dbus_get_path(wpa_s), ssid->id);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
|
||||||
|
net_obj_path);
|
||||||
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
|
||||||
if (!obj_desc) {
|
if (!obj_desc) {
|
||||||
wpa_printf(MSG_ERROR, "Not enough memory "
|
wpa_printf(MSG_ERROR, "Not enough memory "
|
||||||
@ -1229,6 +1235,8 @@ static int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
|
|||||||
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
|
||||||
wpas_dbus_get_path(wpa_s), nid);
|
wpas_dbus_get_path(wpa_s), nid);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
|
||||||
|
net_obj_path);
|
||||||
ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
|
ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
@ -1269,6 +1277,8 @@ static int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
|
|||||||
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
|
"%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
|
||||||
wpas_dbus_get_path(wpa_s), id);
|
wpas_dbus_get_path(wpa_s), id);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
|
||||||
|
bss_obj_path);
|
||||||
if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
|
if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
|
||||||
wpa_printf(MSG_ERROR,
|
wpa_printf(MSG_ERROR,
|
||||||
"Cannot unregister BSSID dbus object %s.",
|
"Cannot unregister BSSID dbus object %s.",
|
||||||
@ -1340,6 +1350,8 @@ static int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
|
|||||||
wpas_dbus_getter_bss_properties, NULL,
|
wpas_dbus_getter_bss_properties, NULL,
|
||||||
arg, wpa_dbus_free, R);
|
arg, wpa_dbus_free, R);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
|
||||||
|
bss_obj_path);
|
||||||
if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
|
if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
|
||||||
wpa_s->ifname, obj_desc)) {
|
wpa_s->ifname, obj_desc)) {
|
||||||
wpa_printf(MSG_ERROR,
|
wpa_printf(MSG_ERROR,
|
||||||
@ -1619,6 +1631,7 @@ static int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
|
|||||||
wpas_dbus_interface_properties,
|
wpas_dbus_interface_properties,
|
||||||
wpas_dbus_interface_signals);
|
wpas_dbus_interface_signals);
|
||||||
|
|
||||||
|
wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'", path);
|
||||||
if (wpa_dbus_register_object_per_iface(ctrl_iface, path, wpa_s->ifname,
|
if (wpa_dbus_register_object_per_iface(ctrl_iface, path, wpa_s->ifname,
|
||||||
obj_desc))
|
obj_desc))
|
||||||
goto err;
|
goto err;
|
||||||
@ -1638,8 +1651,6 @@ err:
|
|||||||
static int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
|
static int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
struct ctrl_iface_dbus_new_priv *ctrl_iface;
|
struct ctrl_iface_dbus_new_priv *ctrl_iface;
|
||||||
struct wpa_ssid *ssid;
|
|
||||||
struct wpa_bss *bss;
|
|
||||||
|
|
||||||
/* Do nothing if the control interface is not turned on */
|
/* Do nothing if the control interface is not turned on */
|
||||||
if (wpa_s == NULL || wpa_s->global == NULL)
|
if (wpa_s == NULL || wpa_s->global == NULL)
|
||||||
@ -1648,16 +1659,8 @@ static int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
|
|||||||
if (ctrl_iface == NULL)
|
if (ctrl_iface == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* unregister all BSSs and networks from dbus */
|
wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
|
||||||
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list)
|
wpas_dbus_get_path(wpa_s));
|
||||||
wpas_dbus_unregister_bss(wpa_s, bss->bssid, bss->id);
|
|
||||||
|
|
||||||
ssid = wpa_s->conf->ssid;
|
|
||||||
while (ssid) {
|
|
||||||
wpas_dbus_unregister_network(wpa_s, ssid->id);
|
|
||||||
ssid = ssid->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
|
if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
|
||||||
wpas_dbus_get_path(wpa_s)))
|
wpas_dbus_get_path(wpa_s)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -379,6 +379,9 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
|
|||||||
wpa_s->ctrl_iface = NULL;
|
wpa_s->ctrl_iface = NULL;
|
||||||
}
|
}
|
||||||
if (wpa_s->conf != NULL) {
|
if (wpa_s->conf != NULL) {
|
||||||
|
struct wpa_ssid *ssid;
|
||||||
|
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
|
||||||
|
wpas_notify_network_removed(wpa_s, ssid);
|
||||||
wpa_config_free(wpa_s->conf);
|
wpa_config_free(wpa_s->conf);
|
||||||
wpa_s->conf = NULL;
|
wpa_s->conf = NULL;
|
||||||
}
|
}
|
||||||
@ -2112,11 +2115,11 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
|
|||||||
wpa_clear_keys(wpa_s, NULL);
|
wpa_clear_keys(wpa_s, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wpa_supplicant_cleanup(wpa_s);
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
wpas_notify_iface_removed(wpa_s);
|
wpas_notify_iface_removed(wpa_s);
|
||||||
|
|
||||||
wpa_supplicant_cleanup(wpa_s);
|
|
||||||
|
|
||||||
if (wpa_s->drv_priv)
|
if (wpa_s->drv_priv)
|
||||||
wpa_drv_deinit(wpa_s);
|
wpa_drv_deinit(wpa_s);
|
||||||
}
|
}
|
||||||
@ -2139,6 +2142,7 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
|
|||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s;
|
struct wpa_supplicant *wpa_s;
|
||||||
struct wpa_interface t_iface;
|
struct wpa_interface t_iface;
|
||||||
|
struct wpa_ssid *ssid;
|
||||||
|
|
||||||
if (global == NULL || iface == NULL)
|
if (global == NULL || iface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2179,6 +2183,9 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
|
||||||
|
wpas_notify_network_added(wpa_s, ssid);
|
||||||
|
|
||||||
wpa_s->next = global->ifaces;
|
wpa_s->next = global->ifaces;
|
||||||
global->ifaces = wpa_s;
|
global->ifaces = wpa_s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user