summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-10-27 16:29:18 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-10-27 16:29:18 +0000
commit3ea416e2abc2758b7e43127fe38284660ca4a3e1 (patch)
treefecd98db7768dcbc09136395ebc2697d1de1677f
parentbb6ceac59219afb11180c15622ab58ca15a003b4 (diff)
Added authentication agent functions prototype
-rw-r--r--hcid/dbus-security.c59
-rw-r--r--hcid/dbus-service.c13
-rw-r--r--hcid/dbus.h12
3 files changed, 60 insertions, 24 deletions
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index 4f8523c4..eaf73574 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -206,7 +206,7 @@ static int agent_cmp(const struct passkey_agent *a, const struct passkey_agent *
return 0;
}
-static DBusHandlerResult register_agent(DBusConnection *conn,
+static DBusHandlerResult register_passkey_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct passkey_agent *agent, ref;
@@ -215,7 +215,7 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
const char *path, *addr;
if (!data) {
- error("register_agent called without any adapter info!");
+ error("register_passkey_agent called without any adapter info!");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -260,7 +260,7 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult unregister_agent(DBusConnection *conn,
+static DBusHandlerResult unregister_passkey_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct adapter *adapter;
@@ -270,7 +270,7 @@ static DBusHandlerResult unregister_agent(DBusConnection *conn,
const char *path, *addr;
if (!data) {
- error("uregister_agent called without any adapter info!");
+ error("unregister_passkey_agent called without any adapter info!");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -308,8 +308,8 @@ static DBusHandlerResult unregister_agent(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult register_default_agent(DBusConnection *conn,
- DBusMessage *msg, void *data)
+static DBusHandlerResult register_default_passkey_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
const char *path;
@@ -349,7 +349,7 @@ need_memory:
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
-static DBusHandlerResult unregister_default_agent(DBusConnection *conn,
+static DBusHandlerResult unregister_default_passkey_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBusMessage *reply;
@@ -385,9 +385,40 @@ static DBusHandlerResult unregister_default_agent(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
+static DBusHandlerResult register_default_auth_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusHandlerResult unregister_default_auth_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
static DBusHandlerResult authorize_service(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct service_agent *sagent;
+ const char *service, *address, *action;
+
+ if (!dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_STRING, &service,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_STRING, &action,
+ DBUS_TYPE_INVALID))
+ return error_invalid_arguments(conn, msg);
+
+ if (!dbus_connection_get_object_path_data(conn, service, (void*) &sagent))
+ return error_not_authorized(conn, msg);
+
+ /* Check if the connection id match */
+ if (strcmp(dbus_message_get_sender(msg), sagent->id))
+ return error_not_authorized(conn, msg);
+
+ /* FIXME: Forward to the default authentication agent */
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -399,12 +430,14 @@ static DBusHandlerResult cancel_service_authorization(DBusConnection *conn,
static struct service_data sec_services[] = {
- { "RegisterDefaultPasskeyAgent", register_default_agent },
- { "UnregisterDefaultPasskeyAgent", unregister_default_agent },
- { "RegisterPasskeyAgent", register_agent },
- { "UnregisterPasskeyAgent", unregister_agent },
- { "Authorize", authorize_service },
- { "CancelAuthorization", cancel_service_authorization },
+ { "RegisterDefaultPasskeyAgent", register_default_passkey_agent },
+ { "UnregisterDefaultPasskeyAgent", unregister_default_passkey_agent },
+ { "RegisterPasskeyAgent", register_passkey_agent },
+ { "UnregisterPasskeyAgent", unregister_passkey_agent },
+ { "RegisterDefaultAuthenticationAgent", register_default_auth_agent },
+ { "UnregisterDefaultAuthenticationAgent", unregister_default_auth_agent },
+ { "AuthorizeService", authorize_service },
+ { "CancelAuthorizationProcess", cancel_service_authorization },
{ NULL, NULL }
};
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index b4c5aa6d..53134a2c 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -39,14 +39,7 @@
#define START_REPLY_TIMEOUT 5000
#define SERVICE_RUNNING 1
-#define SERVICE_NOT_RUNNING 0
-
-struct service_agent {
- char *id; /* Connection id */
- char *name;
- char *description;
- int running;
-};
+#define SERVICE_NOT_RUNNING 0
struct service_call {
DBusConnection *conn;
@@ -541,9 +534,7 @@ static DBusHandlerResult msg_func_services(DBusConnection *conn,
dbus_pending_call_set_notify(pending, forward_reply, call_data, service_call_free);
return send_message_and_unref(conn, forward);
- } else if (strcmp("org.bluez.Security", iface) == 0)
- return handle_security_method(conn, msg, data);
- else
+ } else
return error_unknown_method(conn, msg);
}
diff --git a/hcid/dbus.h b/hcid/dbus.h
index a5f7f562..f0f58493 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;
+ struct slist *auth_agents; /* Authorization agents */
bdaddr_t agents_disabled; /* temporarely disable agents for bda */
struct slist *active_conn;
struct bonding_request_info *bonding;
@@ -152,6 +153,17 @@ struct pending_agent_request {
char *pin;
};
+struct authorization_agent {
+
+};
+
+struct service_agent {
+ char *id; /* Connection id */
+ char *name;
+ char *description;
+ int running;
+};
+
typedef int register_function_t(DBusConnection *conn, uint16_t id);
typedef int unregister_function_t(DBusConnection *conn, uint16_t id);