From: Lennart Poettering Date: Thu, 17 Feb 2022 16:23:48 +0000 (+0100) Subject: pid1: watch bus name always when we have it X-Git-Tag: v251-rc1~262^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e8b312e5a22538f91defb89cf2997e09e106297;p=thirdparty%2Fsystemd.git pid1: watch bus name always when we have it Previously we'd only watch configured service bus names if Type=dbus was set. Let's also watch it for other types. This is useful to pick up the main PID of such a service. In fact the code to pick it up was already in place, alas it didn't do anything given the signal was never received for it. Fix that. (It's also useful for debugging) --- diff --git a/src/core/service.c b/src/core/service.c index cb5233a5cf1..1344fb9e8b7 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -709,17 +709,19 @@ static int service_setup_bus_name(Service *s) { assert(s); /* If s->bus_name is not set, then the unit will be refused by service_verify() later. */ - if (s->type != SERVICE_DBUS || !s->bus_name) + if (!s->bus_name) return 0; - r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); - if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); + if (s->type == SERVICE_DBUS) { + r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); - /* We always want to be ordered against dbus.socket if both are in the transaction. */ - r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); - if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); + /* We always want to be ordered against dbus.socket if both are in the transaction. */ + r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return log_unit_error_errno(UNIT(s), r, "Failed to add dependency on " SPECIAL_DBUS_SOCKET ": %m"); + } r = unit_watch_bus_name(UNIT(s), s->bus_name); if (r == -EEXIST)