From: Tim Sweetman via B4 Relay <devnull+agenttimblog.gmail.com@kernel.org>
To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Subject: [PATCH BlueZ] client: Handle system bus setup failure
Date: Fri, 28 Aug 2026 15:52:10 -0500 [thread overview]
Message-ID: <20260828-master-v1-1-4810753bb693@gmail.com> (raw)
From: Tim Sweetman <agenttimblog@gmail.com>
g_dbus_setup_bus() returns NULL when it cannot connect to the system
bus. bluetoothctl currently passes that NULL connection to
g_dbus_attach_object_manager(), causing libdbus to abort on its
connection assertion.
Initialize a DBusError, report the connection failure, and exit cleanly
before using the connection.
Fixes: https://github.com/bluez/bluez/issues/2446
---
Tested with make check (34 tests).
---
client/main.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/client/main.c b/client/main.c
index 069e20485..d7cecb118 100644
--- a/client/main.c
+++ b/client/main.c
@@ -4017,6 +4017,7 @@ static bool timeout_quit(void *user_data)
int main(int argc, char *argv[])
{
GDBusClient *client;
+ DBusError error;
int status;
int timeout;
unsigned int timeout_id;
@@ -4048,7 +4049,21 @@ int main(int argc, char *argv[])
else
auto_register_agent = g_strdup("");
- dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+ dbus_error_init(&error);
+ dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &error);
+ if (dbus_conn == NULL) {
+ if (dbus_error_is_set(&error)) {
+ fprintf(stderr, "Failed to connect to system bus: %s\n",
+ error.message);
+ dbus_error_free(&error);
+ } else {
+ fprintf(stderr, "Failed to connect to system bus\n");
+ }
+
+ g_free(auto_register_agent);
+ return EXIT_FAILURE;
+ }
+
g_dbus_attach_object_manager(dbus_conn);
bt_shell_set_env("DBUS_CONNECTION", dbus_conn);
---
base-commit: e8141342284be2a52e16565b96b513ebe1297d84
change-id: 20260828-master-e87099ea4429
Best regards,
--
Tim Sweetman <agenttimblog@gmail.com>
next reply other threads:[~2026-08-28 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 20:52 Tim Sweetman via B4 Relay [this message]
2026-08-28 22:16 ` [BlueZ] client: Handle system bus setup failure bluez.test.bot
2026-09-12 22:42 ` bluez.test.bot
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=20260828-master-v1-1-4810753bb693@gmail.com \
--to=devnull+agenttimblog.gmail.com@kernel.org \
--cc=agenttimblog@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