From 7dad4ead9b4bb5904e05b90d30f1db8e0075d9a5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 2 Nov 2026 17:40:33 +0900 Subject: [PATCH] core/dbus: skip setting up API bus when it is already disconnected. If it is already disconnected, we cannot setup the API bus anyway, and shows several spurious errors for e.g. failure in sd_bus_negotiate_creds(). Co-authored-by: Alvaro Leiva Geisse (cherry picked from commit f96742e512040439500efac881a7c25b128fc2d5) (cherry picked from commit 9dbbb8ad2bc9424a5b032b142a3d6fc3872e5fae) --- src/core/dbus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/dbus.c b/src/core/dbus.c index 12aeec4bb9a..7710784e87d 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -829,6 +829,14 @@ static int api_bus_instance_id_reply(sd_bus_message *reply, void *userdata, sd_b assert(reply); assert_se(bus = sd_bus_message_get_bus(reply)); + r = sd_bus_is_open(bus); + if (r < 0) + log_warning_errno(r, "Failed to check if bus is open, assuming it is, ignoring: %m"); + else if (r == 0) { + log_debug("API bus connection closed before its instance ID was received."); + return 0; /* Let's skip the setup and wait for signal_disconnected(). */ + } + /* Whatever the outcome, we get only one shot at coldplugging the saved subscription state onto * this connection: consume it. */ _cleanup_strv_free_ char **subscribed_as_strv = TAKE_PTR(m->subscribed_as_strv);