From bcd08128e47ca6d1151ce6416c52633f2e06dc09 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Mon, 5 Oct 2026 15:00:38 +0200 Subject: [PATCH] core: Don't abort when canceling a job through the private bus Messages on the private bus have no sender. As it is now, when a job is canceled through it, as "systemctl cancel" does when run as root, we pass a NULL name to sd_bus_track_contains(), which fails an assert_return(). In developer builds, that makes PID 1 abort. Otherwise it's only logged at debug level, and we consult polkit, as we should. Let's only check whether the sender owns the job for messages on the API bus. That's the only bus bus_job_track_sender() tracks senders on, so jobs enqueued through the private bus aren't tracked anyway. (cherry picked from commit bfeac4c30e1a818cda14c8d1b347d500a9dfe4e3) --- src/core/dbus-job.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index 4fca8e5a40..903a826649 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -52,8 +52,10 @@ int bus_job_method_cancel(sd_bus_message *message, void *userdata, sd_bus_error if (r < 0) return r; - /* Access is granted to the job owner */ - if (!sd_bus_track_contains(j->bus_track, sd_bus_message_get_sender(message))) { + /* Access is granted to the job owner. Only clients on the API bus are tracked, messages on the + * private bus have no sender. */ + if (sd_bus_message_get_bus(message) != j->manager->api_bus || + !sd_bus_track_contains(j->bus_track, sd_bus_message_get_sender(message))) { /* And for everybody else consult polkit */ r = bus_verify_manage_units_async(j->manager, message, reterr_error);