Disable passkey agents (reject any pin request) for a device when an audit to it is in progress

This commit is contained in:
Johan Hedberg 2006-10-12 20:01:29 +00:00
parent 4b12168ab3
commit ae1a0e6ffe
3 changed files with 33 additions and 9 deletions

View File

@ -476,7 +476,7 @@ static int call_passkey_agent(DBusConnection *conn,
ba2str(dba, bda);
if (!agent) {
debug("call_passkey_agent(): no agent registered");
debug("call_passkey_agent(): no agent available");
goto failed;
}
@ -563,6 +563,9 @@ int handle_passkey_request(DBusConnection *conn, int dev, const char *path,
adapter = data;
if (!bacmp(&adapter->agents_disabled, dba))
goto done;
ba2str(dba, addr);
for (l = adapter->passkey_agents; l != NULL; l = l->next) {

View File

@ -135,7 +135,16 @@ static void audit_requestor_exited(const char *name, struct audit *audit)
debug("AuditRemoteDevice requestor %s exited", name);
audits = slist_remove(audits, audit);
if (audit->io) {
struct adapter *adapter = NULL;
send_audit_status(audit, "AuditRemoteDeviceComplete");
dbus_connection_get_object_path_data(audit->conn,
audit->adapter_path,
(void *) &adapter);
if (adapter)
bacpy(&adapter->agents_disabled, BDADDR_ANY);
g_io_channel_close(audit->io);
}
if (audit->timeout)
@ -299,12 +308,18 @@ static gboolean l2raw_connect_complete(GIOChannel *io, GIOCondition cond, struct
l2cap_info_req *req = (l2cap_info_req *) (buf + L2CAP_CMD_HDR_SIZE);
socklen_t len;
int sk, ret;
struct adapter *adapter = NULL;
if (cond & G_IO_NVAL) {
g_io_channel_unref(io);
return FALSE;
}
dbus_connection_get_object_path_data(audit->conn, audit->adapter_path,
(void *) &adapter);
if (adapter)
bacpy(&adapter->agents_disabled, BDADDR_ANY);
if (cond & (G_IO_ERR | G_IO_HUP)) {
error("Error on raw l2cap socket");
goto failed;
@ -394,22 +409,22 @@ static DBusHandlerResult audit_remote_device(DBusConnection *conn,
if (slist_find(adapter->pin_reqs, &peer, pin_req_cmp))
return error_bonding_in_progress(conn, msg);
/* Just return if an audit for the same device is already queued */
if (slist_find(audits, &peer, audit_addr_cmp))
return DBUS_HANDLER_RESULT_HANDLED;
if (!read_l2cap_info(&local, &peer, NULL, NULL, NULL, NULL))
return error_audit_already_exists(conn, msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
/* Just return if an audit for the same device is already queued */
if (slist_find(audits, &peer, audit_addr_cmp))
return send_message_and_unref(conn, reply);
if (adapter->discov_active || (adapter->pdiscov_active && !adapter->pinq_idle))
queue = TRUE;
else
queue = audit_in_progress();
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
audit = audit_new(conn, msg, &peer, &local);
if (!audit) {
dbus_message_unref(reply);
@ -426,6 +441,8 @@ static DBusHandlerResult audit_remote_device(DBusConnection *conn,
return error_connection_attempt_failed(conn, msg, 0);
}
bacpy(&adapter->agents_disabled, &peer);
audit->io = g_io_channel_unix_new(sk);
audit->io_id = g_io_add_watch(audit->io,
G_IO_OUT | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
@ -482,6 +499,7 @@ static DBusHandlerResult cancel_audit_remote_device(DBusConnection *conn,
if (audit->io) {
send_audit_status(audit, "AuditRemoteDeviceComplete");
bacpy(&adapter->agents_disabled, BDADDR_ANY);
g_io_channel_close(audit->io);
}
if (audit->timeout)
@ -653,6 +671,8 @@ void process_audits_list(const char *adapter_path)
continue;
}
bacpy(&adapter->agents_disabled, &audit->peer);
audit->io = g_io_channel_unix_new(sk);
audit->io_id = g_io_add_watch(audit->io,
G_IO_OUT | G_IO_NVAL | G_IO_HUP | G_IO_ERR,

View File

@ -124,6 +124,7 @@ struct adapter {
char *discov_requestor; /* discovery requestor unique name */
DBusMessage *discovery_cancel; /* discovery cancel message request */
struct slist *passkey_agents;
bdaddr_t agents_disabled; /* temporarely disable agents for bda */
struct slist *active_conn;
struct bonding_request_info *bonding;
struct slist *pin_reqs;