summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-test.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-10-12 20:01:29 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-10-12 20:01:29 +0000
commitae1a0e6ffe8d14341f98d15a7a00dd6c21e3b3b5 (patch)
treeabc57584536f9aa5fd0af60e72a575dd0b649b05 /hcid/dbus-test.c
parent4b12168ab36fa7777e4e2fd4f6a81eb5569518ed (diff)
Disable passkey agents (reject any pin request) for a device when an audit to it is in progress
Diffstat (limited to 'hcid/dbus-test.c')
-rw-r--r--hcid/dbus-test.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/hcid/dbus-test.c b/hcid/dbus-test.c
index c8c977ea..b15965d4 100644
--- a/hcid/dbus-test.c
+++ b/hcid/dbus-test.c
@@ -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,