Diff between 45306a3f3b5fea4515136ca1e92637e1c8965dbd and 7b38d4472b23fc638c30589f574e359b68563065

Changed Files

File Additions Deletions Status
src/agent.c +10 -2 modified

Full Patch

diff --git a/src/agent.c b/src/agent.c
index ac1688b..39c7c1c 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -958,7 +958,7 @@ static DBusMessage *request_default(DBusConnection *conn, DBusMessage *msg,
 							void *user_data)
 {
 	struct agent *agent;
-	const char *sender;
+	const char *sender, *path;
 
 	sender = dbus_message_get_sender(msg);
 
@@ -966,6 +966,13 @@ static DBusMessage *request_default(DBusConnection *conn, DBusMessage *msg,
 	if (!agent)
 		return btd_error_does_not_exist(msg);
 
+	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+						DBUS_TYPE_INVALID) == FALSE)
+		return btd_error_invalid_args(msg);
+
+	if (g_str_equal(path, agent->path) == FALSE)
+		return btd_error_does_not_exist(msg);
+
 	set_default_agent(agent);
 
 	return dbus_message_new_method_return(msg);
@@ -977,7 +984,8 @@ static const GDBusMethodTable methods[] = {
 			NULL, register_agent) },
 	{ GDBUS_METHOD("UnregisterAgent", GDBUS_ARGS({ "agent", "o" }),
 			NULL, unregister_agent) },
-	{ GDBUS_METHOD("RequestDefault", NULL, NULL, request_default ) },
+	{ GDBUS_METHOD("RequestDefaultAgent", GDBUS_ARGS({ "agent", "o" }),
+			NULL, request_default ) },
 	{ }
 };