]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/manager.c
Merge pull request #13904 from keur/job_mode_triggering
[thirdparty/systemd.git] / src / core / manager.c
index 700493ee0dde0503f21ed6f288e17418916f09a0..aaf894c9ecf450f5b745308c71497f3149245c7e 100644 (file)
@@ -1738,6 +1738,9 @@ int manager_add_job(
         if (mode == JOB_ISOLATE && !unit->allow_isolate)
                 return sd_bus_error_setf(error, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
 
+        if (mode == JOB_TRIGGERING && type != JOB_STOP)
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "--job-mode=triggering is only valid for stop.");
+
         log_unit_debug(unit, "Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode));
 
         type = job_type_collapse(type, unit);
@@ -1758,6 +1761,12 @@ int manager_add_job(
                         goto tr_abort;
         }
 
+        if (mode == JOB_TRIGGERING) {
+                r = transaction_add_triggering_jobs(tr, unit);
+                if (r < 0)
+                        goto tr_abort;
+        }
+
         r = transaction_activate(tr, m, mode, affected_jobs, error);
         if (r < 0)
                 goto tr_abort;