core/dbus-manager: propagate meaningful dbus errors from EnqueueMarkedJobs

Previously, when `systemctl reload-or-restart --marked` failed the following
error was shown:

  Failed to start jobs: Failed to enqueue some jobs, see logs for details: Invalid argument

but no details were actually logged.

This change records failure reasons in the journal to help users identify root causes:

  # journalctl -b -e
  [...]
  systemd[1]: Queuing reload/restart jobs for marked units…
  systemd[1]: Operation refused, unit klogd.service may be requested by dependency only (it is configured to refuse manual start/stop).
This commit is contained in:
Franck Bui
2026-01-16 14:36:40 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent f9a3f729ac
commit 502d6f4bc9
+6 -5
View File
@@ -2125,6 +2125,8 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
char *k;
int ret = 0;
HASHMAP_FOREACH_KEY(u, k, m->units) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
/* ignore aliases */
if (u->id != k)
continue;
@@ -2137,17 +2139,16 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
else
continue;
r = mac_selinux_unit_access_check(u, message, "start", reterr_error);
r = mac_selinux_unit_access_check(u, message, "start", &error);
if (r >= 0)
r = bus_unit_queue_job_one(message, u,
JOB_TRY_RESTART, JOB_FAIL, flags,
reply, reterr_error);
reply, &error);
if (ERRNO_IS_NEG_RESOURCE(r))
return r;
if (r < 0) {
if (ret >= 0)
ret = r;
sd_bus_error_free(reterr_error);
RET_GATHER(ret, r);
log_warning_errno(r, "%s", bus_error_message(&error, r));
}
}