summaryrefslogtreecommitdiffstats
path: root/hcid
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
parent4b12168ab36fa7777e4e2fd4f6a81eb5569518ed (diff)
Disable passkey agents (reject any pin request) for a device when an audit to it is in progress
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-security.c5
-rw-r--r--hcid/dbus-test.c36
-rw-r--r--hcid/dbus.h1
3 files changed, 33 insertions, 9 deletions
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index ab4ce205..20e35a6c 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -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) {
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,
diff --git a/hcid/dbus.h b/hcid/dbus.h
index 60577ba0..64118d63 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -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;