* [PATCH BlueZ] client: Handle system bus connection failures
@ 2026-10-08 18:13 Gabriel Berfield
2026-10-08 22:42 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Berfield @ 2026-10-08 18:13 UTC (permalink / raw)
To: linux-bluetooth
Report the system-bus connection error and exit before attaching the
object manager when the connection is unavailable. This avoids a libdbus
assertion abort in restricted environments and releases the initialized
shell state on failure.
Fixes: 8a05f2b1ac91 ("client: Add initial parts for the command line client")
Link: https://github.com/bluez/bluez/issues/2446
Assisted-by: Codex:GPT-6
---
This is a current-master submission for the already reported issue #2446.
Related original submission:
https://lore.kernel.org/linux-bluetooth/20260828-master-v1-1-4810753bb693%40gmail.com/
Base: 866b0b8b162f52fa8a5452d2017093806ba1b570.
Validation: client built; all 35 make check programs passed; checkpatch
reported zero errors and warnings. With core dumps disabled, an unavailable
D-Bus address aborts the unpatched client but the candidate exits 1 with the
connection error. A read-only query against the live system bus exits 0.
This only handles client startup failure. It makes no claim about mouse
idle reconnects. Preparation and tests used Codex/GPT-6 assistance.
client/main.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/client/main.c b/client/main.c
index f5fdd7d12..fff75056e 100644
--- a/client/main.c
+++ b/client/main.c
@@ -4203,6 +4203,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;
@@ -4234,7 +4235,18 @@ 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) {
+ fprintf(stderr, "Failed to connect to system D-Bus: %s\n",
+ error.message ? error.message : "unavailable");
+ dbus_error_free(&error);
+ g_free(auto_register_agent);
+ bt_shell_cleanup();
+ return EXIT_FAILURE;
+ }
+
+ dbus_error_free(&error);
g_dbus_attach_object_manager(dbus_conn);
cs_set_dbus_conn(dbus_conn);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-08 22:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 18:13 [PATCH BlueZ] client: Handle system bus connection failures Gabriel Berfield
2026-10-08 22:42 ` [BlueZ] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox