diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-05-02 20:56:40 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-05-02 20:56:40 +0000 |
commit | 93123d3eccdb503246f10b40ef2b62418bda6e8f (patch) | |
tree | f32bee6cc069760a3ca1c3cda2752adbd4acc399 | |
parent | 9491a544f622e40453265c30f24ce44a61440cc1 (diff) |
Check trusted device list before request authorization
-rw-r--r-- | hcid/dbus-service.c | 15 | ||||
-rw-r--r-- | network/server.c | 6 |
2 files changed, 17 insertions, 4 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index c446a6e4..69accf87 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -1236,6 +1236,7 @@ static void agent_auth_cb(struct agent *agent, DBusError *derr, void *user_data) g_free(auth); } + int service_req_auth(bdaddr_t *src, bdaddr_t *dst, const char *uuid, service_auth_cb cb, void *user_data) { @@ -1243,7 +1244,9 @@ int service_req_auth(bdaddr_t *src, bdaddr_t *dst, struct adapter *adapter; struct device *device; struct agent *agent; + struct service *service; char address[18]; + gboolean trusted; adapter = ba2adapter(src); if (!adapter) @@ -1259,10 +1262,18 @@ int service_req_auth(bdaddr_t *src, bdaddr_t *dst, if (!device) return -EPERM; - if (!search_service_by_uuid(uuid)) + service = search_service_by_uuid(uuid); + if (!service) return -EPERM; - /* FIXME: Missing check trusted file entries */ + trusted = read_trust(src, address, GLOBAL_TRUST); + if (!trusted) + trusted = read_trust(BDADDR_ANY, address, service->ident); + + if (trusted) { + cb(NULL, user_data); + return 0; + } agent = (device->agent ? : adapter->agent); if (!agent) diff --git a/network/server.c b/network/server.c index 0915d9d4..046b20b3 100644 --- a/network/server.c +++ b/network/server.c @@ -592,14 +592,16 @@ static gboolean bnep_setup(GIOChannel *chan, goto reply; } + setup = setup_session_new(address, dst_role, src_role, sk, to->watch); + /* Wait authorization before reply success */ if (authorize_connection(ns, address) < 0) { + setup_session_free(setup); + setup = NULL; rsp = BNEP_CONN_NOT_ALLOWED; goto reply; } - setup = setup_session_new(address, dst_role, src_role, sk, to->watch); - g_source_remove(to->id); to->id = 0; |