summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-06-06 10:32:38 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-06-06 10:32:38 +0000
commit648ac7812adfc4401ae654055ffb5676393b2fa2 (patch)
tree6718633fb04e2be638862fae4263eaf826061d4d
parentf269e27ce7e39e6484cf02a137dcda7458a7fd85 (diff)
Fix the object user data handling in security callbacks
-rw-r--r--hcid/dbus-hci.c8
-rw-r--r--hcid/dbus-security.c39
-rw-r--r--hcid/dbus-security.h13
3 files changed, 24 insertions, 36 deletions
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index 637c4bc6..61bd1cd1 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -1029,8 +1029,8 @@ int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
device);
old_fallback:
- return handle_passkey_request_old(connection, dev, adapter->path, sba,
- &ci->bdaddr);
+ return handle_passkey_request_old(connection, dev, adapter,
+ sba, &ci->bdaddr);
}
static void confirm_cb(struct agent *agent, DBusError *err, void *user_data)
@@ -1169,8 +1169,8 @@ int hcid_dbus_confirm_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci, char
return -1;
}
- return handle_confirm_request_old(connection, dev, adapter->path, sba,
- &ci->bdaddr, pin);
+ return handle_confirm_request_old(connection, dev, adapter,
+ sba, &ci->bdaddr, pin);
}
void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index a5c39775..dfa2c711 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -999,21 +999,13 @@ send:
return -1;
}
-int handle_passkey_request_old(DBusConnection *conn, int dev, const char *path,
- bdaddr_t *sba, bdaddr_t *dba)
+int handle_passkey_request_old(DBusConnection *conn, int dev,
+ struct adapter *adapter,
+ bdaddr_t *sba, bdaddr_t *dba)
{
struct passkey_agent *agent = default_agent;
- struct adapter *adapter = NULL;
GSList *l;
char addr[18];
- void *data;
-
- dbus_connection_get_object_user_data(conn, path, &data);
-
- if (!data)
- goto done;
-
- adapter = data;
ba2str(dba, addr);
@@ -1027,8 +1019,7 @@ int handle_passkey_request_old(DBusConnection *conn, int dev, const char *path,
}
}
-done:
- return call_passkey_agent(conn, agent, dev, path, sba, dba);
+ return call_passkey_agent(conn, agent, dev, adapter->path, sba, dba);
}
static DBusPendingCall *agent_confirm(const char *path, bdaddr_t *bda,
@@ -1175,27 +1166,21 @@ send:
return -1;
}
-int handle_confirm_request_old(DBusConnection *conn, int dev, const char *path,
- bdaddr_t *sba, bdaddr_t *dba, const char *pin)
+int handle_confirm_request_old(DBusConnection *conn, int dev,
+ struct adapter *adapter,
+ bdaddr_t *sba, bdaddr_t *dba,
+ const char *pin)
{
struct passkey_agent *agent = default_agent;
- struct adapter *adapter = NULL;
GSList *l;
char addr[18];
- void *data;
-
- dbus_connection_get_object_user_data(conn, path, &data);
-
- if (!data)
- goto done;
-
- adapter = data;
ba2str(dba, addr);
for (l = adapter->passkey_agents; l != NULL; l = l->next) {
struct passkey_agent *a = l->data;
- if (a != default_agent && g_slist_length(a->pending_requests) >= 1)
+ if (a != default_agent &&
+ g_slist_length(a->pending_requests) >= 1)
continue;
if (!strcmp(a->addr, addr)) {
agent = a;
@@ -1203,8 +1188,8 @@ int handle_confirm_request_old(DBusConnection *conn, int dev, const char *path,
}
}
-done:
- return call_confirm_agent(conn, agent, dev, path, sba, dba, pin);
+ return call_confirm_agent(conn, agent, dev, adapter->path,
+ sba, dba, pin);
}
static void send_cancel_request(struct pending_agent_request *req)
diff --git a/hcid/dbus-security.h b/hcid/dbus-security.h
index fc193d38..38c2d519 100644
--- a/hcid/dbus-security.h
+++ b/hcid/dbus-security.h
@@ -26,11 +26,14 @@
dbus_bool_t security_init(DBusConnection *conn, const char *path);
-int handle_passkey_request_old(DBusConnection *conn, int dev, const char *path,
- bdaddr_t *sba, bdaddr_t *dba);
-
-int handle_confirm_request_old(DBusConnection *conn, int dev, const char *path,
- bdaddr_t *sba, bdaddr_t *dba, const char *pin);
+int handle_passkey_request_old(DBusConnection *conn, int dev,
+ struct adapter *adapter,
+ bdaddr_t *sba, bdaddr_t *dba);
+
+int handle_confirm_request_old(DBusConnection *conn, int dev,
+ struct adapter *adapter,
+ bdaddr_t *sba, bdaddr_t *dba,
+ const char *pin);
void release_default_agent_old(void);