Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 09/11] client: allow a capability with the auto agent
Date: Tue, 15 Sep 2026 17:15:26 -0400	[thread overview]
Message-ID: <20260915211528.1223784-10-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260915211528.1223784-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The auto agent registers with no capability, which is KeyboardDisplay,
so a peer pairing with it may well choose the entry of a passkey. That
is a method the auto agent cannot answer: it only replies by itself to
the confirmation and the authorization requests, and the passkey entry
is left to the user, who is not there to answer it in a test.

The pairing then only completes once the request times out, 30 seconds
later, and it completes as a failure.

Accept a capability after the name, e.g. auto:NoInputNoOutput, to let
the capability be the one pairing Just Works, which requires no answer
at all. Plain auto keeps registering as before.

Assisted-by: opencode:claude-opus-5
---
 client/agent.c       | 14 ++++++++++++--
 client/main.c        | 14 +++++++++++---
 doc/bluetoothctl.rst |  6 +++++-
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index ff5e57ff27a5..a678d5f785a9 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -403,11 +403,21 @@ void agent_register(DBusConnection *conn, GDBusProxy *manager,
 
 	agent_capability = capability;
 
-	if (!strcasecmp(agent_capability, "auto")) {
+	if (!strncasecmp(agent_capability, "auto", 4) &&
+			(!agent_capability[4] || agent_capability[4] == ':')) {
 		bt_shell_printf("Warning: setting auto response is not secure, "
 				"it bypass user confirmation/authorization, it "
 				"shall only be used for test automation.\n");
-		agent_capability = "";
+		/* The capability to register with can be given after a
+		 * colon, e.g. auto:NoInputNoOutput, so the pairing does
+		 * not choose a method the auto response cannot answer,
+		 * like the entry of a passkey.
+		 */
+		if (agent_capability[4])
+			agent_capability += 5;
+		else
+			agent_capability = "";
+
 		methods = auto_methods;
 	}
 
diff --git a/client/main.c b/client/main.c
index d8d2e32d9556..4d13fa1b1e1a 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1416,9 +1416,17 @@ static void cmd_agent(int argc, char *argv[])
 	dbus_bool_t enable;
 	const char *capability;
 
-	if (!parse_argument(argc, argv, agent_arguments, "capability",
-						&enable, &capability))
+	/* The capability of the auto response is given after a colon,
+	 * e.g. auto:NoInputNoOutput, so it cannot be looked up in the
+	 * list of arguments.
+	 */
+	if (argc > 1 && !strncasecmp(argv[1], "auto:", 5)) {
+		enable = TRUE;
+		capability = argv[1];
+	} else if (!parse_argument(argc, argv, agent_arguments, "capability",
+						&enable, &capability)) {
 		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
 
 	if (enable == TRUE) {
 		g_free(auto_register_agent);
@@ -4034,7 +4042,7 @@ static const struct bt_shell_menu main_menu = {
 							NULL },
 	{ "discoverable-timeout", "[value]", cmd_discoverable_timeout,
 					"Set discoverable timeout", NULL },
-	{ "agent",        "<on/off/auto/capability>", cmd_agent,
+	{ "agent",        "<on/off/auto[:capability]/capability>", cmd_agent,
 				"Enable/disable agent with given capability",
 							capability_generator},
 	{ "default-agent",NULL,       cmd_default_agent,
diff --git a/doc/bluetoothctl.rst b/doc/bluetoothctl.rst
index ed4cd0703281..cc58e1f5be19 100644
--- a/doc/bluetoothctl.rst
+++ b/doc/bluetoothctl.rst
@@ -301,11 +301,15 @@ for pairing and allows you to choose the IO capabilities of the controller.
 The valid agent capabilities are: DisplayOnly, DisplayYesNo, KeyboardDisplay,
 KeyboardOnly, NoInputNoOutput.
 
-:Usage: **> agent <on/off/auto/capability>**
+:Usage: **> agent <on/off/auto[:capability]/capability>**
 :Uses: **org.bluez.AgentManager(5)** method **RegisterAgent**
 :<on/off/auto/capability>: Agent mode - "on", "off", "auto", or capability type (DisplayOnly, DisplayYesNo, KeyboardDisplay, KeyboardOnly, NoInputNoOutput) (required)
 :Example Enable agent with default capability:
 	| **> agent on**
+:Example Enable agent answering automatically, only for test automation:
+	| **> agent auto**
+:Example Enable agent answering automatically with the given capability:
+	| **> agent auto:NoInputNoOutput**
 :Example Disable agent:
 	| **> agent off**
 :Example Enable agent that can only display pairing codes:
-- 
2.55.0


  parent reply	other threads:[~2026-09-15 21:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 21:15 [PATCH BlueZ v1 00/11] Cover a BAP stream to a coordinated set Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 01/11] shared/bass: add a ready callback Luiz Augusto von Dentz
2026-09-15 21:58   ` Cover a BAP stream to a coordinated set bluez.test.bot
2026-09-16  0:55   ` bluez.test.bot
2026-09-15 21:15 ` [PATCH BlueZ v1 02/11] bass: wait for the session to be ready before pushing a source Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 03/11] test: functional: report what a test is waiting for Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 04/11] test: functional: answer the notification registered by the victim Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 05/11] doc: describe the BAP coordinated set test cases Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 06/11] emulator: use the handle of the receiving side Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 07/11] emulator: allow the maximum number of CIS of a CIG Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 08/11] device: keep the long term key of both roles Luiz Augusto von Dentz
2026-09-15 21:15 ` Luiz Augusto von Dentz [this message]
2026-09-15 21:15 ` [PATCH BlueZ v1 10/11] test: functional: fail as soon as an operation fails Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 11/11] test: functional: add the BAP coordinated set tests Luiz Augusto von Dentz
2026-09-16 18:30 ` [PATCH BlueZ v1 00/11] Cover a BAP stream to a coordinated set patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260915211528.1223784-10-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox