summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2008-04-08 21:28:26 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2008-04-08 21:28:26 +0000
commita6bf5ec452e5426906fc9991d738e3a5ae27050c (patch)
tree4918762c3b37dab071e64a34d43de85ca9aaa521
parent38e740cddb16d29f4dae3b289dcd0830d6246988 (diff)
cleanup: connection status is verified twice for RequestAuthorization
-rw-r--r--hcid/dbus-database.c9
-rw-r--r--hcid/dbus-security.c26
-rw-r--r--hcid/dbus-security.h3
3 files changed, 14 insertions, 24 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index 93f37ad4..4479f78c 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -409,14 +409,15 @@ static DBusHandlerResult unregister_service(DBusConnection *conn,
static DBusHandlerResult request_authorization(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- const char *sender, *address, *path;
+ const char *sender, *address, *uuid;
struct service *service;
+ char path[MAX_PATH_LENGTH];
bdaddr_t bdaddr;
gboolean trusted;
int adapter_id;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
- DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE)
+ DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID) == FALSE)
return error_invalid_arguments(conn, msg, NULL);
sender = dbus_message_get_sender(msg);
@@ -449,7 +450,9 @@ static DBusHandlerResult request_authorization(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
- return handle_authorize_request_old(conn, msg, service, address, path);
+ snprintf(path, sizeof(path), "/org/bluez/hci%d", adapter_id);
+ return handle_authorize_request_old(conn, msg,
+ service, path, address, uuid);
}
static DBusHandlerResult cancel_authorization_request(DBusConnection *conn,
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index bab3a79d..16ca7585 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -695,7 +695,7 @@ static DBusPendingCall *auth_agent_call_authorize(struct authorization_agent *ag
const char *adapter_path,
const char *service_path,
const char *address,
- const char *path)
+ const char *uuid)
{
DBusMessage *message;
DBusPendingCall *call;
@@ -711,7 +711,7 @@ static DBusPendingCall *auth_agent_call_authorize(struct authorization_agent *ag
DBUS_TYPE_STRING, &adapter_path,
DBUS_TYPE_STRING, &address,
DBUS_TYPE_STRING, &service_path,
- DBUS_TYPE_STRING, &path,
+ DBUS_TYPE_STRING, &uuid,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(agent->conn, message,
@@ -728,13 +728,11 @@ static DBusPendingCall *auth_agent_call_authorize(struct authorization_agent *ag
DBusHandlerResult handle_authorize_request_old(DBusConnection *conn,
DBusMessage *msg,
struct service *service,
+ const char *path,
const char *address,
const char *uuid)
{
struct auth_agent_req *req;
- char adapter_path[PATH_MAX];
- bdaddr_t bdaddr;
- int adapter_id;
debug("handle_authorize_request");
@@ -743,23 +741,11 @@ DBusHandlerResult handle_authorize_request_old(DBusConnection *conn,
return error_auth_agent_does_not_exist(conn, msg);
}
- str2ba(address, &bdaddr);
-
- adapter_id = hci_for_each_dev(HCI_UP, find_conn, (long) &bdaddr);
- if (adapter_id < 0)
- return error_not_connected(conn, msg);
-
- debug("Found %s connected to hci%d", address, adapter_id);
-
- snprintf(adapter_path, sizeof(adapter_path), "/org/bluez/hci%d",
- adapter_id);
-
- req = auth_agent_req_new(msg, default_auth_agent, adapter_path,
+ req = auth_agent_req_new(msg, default_auth_agent, path,
address, service->object_path, uuid);
- req->call = auth_agent_call_authorize(default_auth_agent, adapter_path,
- service->object_path, address,
- uuid);
+ req->call = auth_agent_call_authorize(default_auth_agent, path,
+ service->object_path, address, uuid);
if (!req->call) {
auth_agent_req_free(req);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
diff --git a/hcid/dbus-security.h b/hcid/dbus-security.h
index aafbae91..fc193d38 100644
--- a/hcid/dbus-security.h
+++ b/hcid/dbus-security.h
@@ -43,8 +43,9 @@ void cancel_passkey_agent_requests(GSList *agents, const char *path, bdaddr_t *d
DBusHandlerResult handle_authorize_request_old(DBusConnection *conn,
DBusMessage *msg,
struct service *service,
+ const char *path,
const char *address,
- const char *path);
+ const char *uuid);
DBusHandlerResult cancel_authorize_request_old(DBusConnection *conn,
DBusMessage *msg,