Skip to content

Commit 4d2c65e

Browse files
poetteringkeszybz
authored andcommitted
stdio-bridge: properly handle org.freedesktop.DBus.Local.Disconnected signal
Previously, we'd forward org.freedesktop.DBus.Local.Disconnected like any other message to the other side. But that's not OK, as messages in the org.freedesktop.DBus.Local.* namespace are supposed to never touch the wire, and are synthetic messages that the library uses to communicate with the app, but never with other apps. dbus-daemon never cared, but dbus-broker complains about this, hence clean this up. See: #28514 (cherry picked from commit 0321248) (cherry picked from commit 0dbb4ff)
1 parent 20a9528 commit 4d2c65e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/stdio-bridge/stdio-bridge.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,16 @@ static int run(int argc, char *argv[]) {
183183
assert_cc(sizeof(usec_t) == sizeof(uint64_t));
184184

185185
r = sd_bus_process(a, &m);
186-
if (r < 0)
187-
return log_error_errno(r, "Failed to process bus a: %m");
186+
if (r < 0) {
187+
if (ERRNO_IS_DISCONNECT(r)) /* Treat 'connection reset by peer' as clean exit condition */
188+
break;
188189

190+
return log_error_errno(r, "Failed to process bus a: %m");
191+
}
189192
if (m) {
193+
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected"))
194+
break;
195+
190196
r = sd_bus_send(b, m, NULL);
191197
if (r < 0)
192198
return log_error_errno(r, "Failed to send message: %m");
@@ -199,12 +205,14 @@ static int run(int argc, char *argv[]) {
199205
if (r < 0) {
200206
/* treat 'connection reset by peer' as clean exit condition */
201207
if (ERRNO_IS_DISCONNECT(r))
202-
return 0;
208+
break;
203209

204210
return log_error_errno(r, "Failed to process bus: %m");
205211
}
206-
207212
if (m) {
213+
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected"))
214+
break;
215+
208216
r = sd_bus_send(a, m, NULL);
209217
if (r < 0)
210218
return log_error_errno(r, "Failed to send message: %m");

0 commit comments

Comments
 (0)