]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: use bus_unit_check_load_state() in transaction_add_job_and_dependencies() 2085/head
authorFranck Bui <fbui@suse.com>
Wed, 2 Dec 2015 16:03:28 +0000 (17:03 +0100)
committerFranck Bui <fbui@suse.com>
Wed, 2 Dec 2015 16:03:28 +0000 (17:03 +0100)
src/core/transaction.c
src/systemctl/systemctl.c

index 15e79d00b30c15c24e629fa5f7c985134a8b8096..88c064f096d08b9744d56f06ed45f77281608671 100644 (file)
@@ -27,6 +27,7 @@
 #include "bus-error.h"
 #include "terminal-util.h"
 #include "transaction.h"
+#include "dbus-unit.h"
 
 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
 
@@ -860,30 +861,12 @@ int transaction_add_job_and_dependencies(
         if (!IN_SET(unit->load_state, UNIT_LOADED, UNIT_ERROR, UNIT_NOT_FOUND, UNIT_MASKED))
                 return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
 
-        if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
-                if (unit->load_error == -ENOENT || unit->manager->test_run)
-                        return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
-                                                 "Unit %s failed to load: %s.",
-                                                 unit->id,
-                                                 strerror(-unit->load_error));
-                else
-                        return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
-                                                 "Unit %s failed to load: %s. "
-                                                 "See system logs and 'systemctl status %s' for details.",
-                                                 unit->id,
-                                                 strerror(-unit->load_error),
-                                                 unit->id);
+        if (type != JOB_STOP) {
+                r = bus_unit_check_load_state(unit, e);
+                if (r < 0)
+                        return r;
         }
 
-        if (type != JOB_STOP && unit->load_state == UNIT_NOT_FOUND)
-                return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
-                                         "Unit %s failed to load: %s.",
-                                         unit->id, strerror(-unit->load_error));
-
-        if (type != JOB_STOP && unit->load_state == UNIT_MASKED)
-                return sd_bus_error_setf(e, BUS_ERROR_UNIT_MASKED,
-                                         "Unit %s is masked.", unit->id);
-
         if (!unit_job_is_applicable(unit, type))
                 return sd_bus_error_setf(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE,
                                          "Job type %s is not applicable for unit %s.",
index 1448d974bd4d0d6ec1418445584a4f09894542ef..b88009c044aabffd544e0e96390853f1ad5c9aab 100644 (file)
@@ -2631,7 +2631,13 @@ static int start_unit_one(
 
                 verb = method_to_verb(method);
 
-                return log_error_errno(r, "Failed to %s %s: %s", verb, name, bus_error_message(error, r));
+                log_error("Failed to %s %s: %s", verb, name, bus_error_message(error, r));
+
+                if (!sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) &&
+                    !sd_bus_error_has_name(error, BUS_ERROR_UNIT_MASKED))
+                        log_error("See system logs and 'systemctl status %s' for details.", name);
+
+                return r;
         }
 
         r = sd_bus_message_read(reply, "o", &path);