chiark / gitweb /
systemd: return error when asked to stop unknown unit
authorMichal Sekletar <msekleta@redhat.com>
Tue, 19 Jun 2012 08:00:54 +0000 (10:00 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 19 Jun 2012 09:38:22 +0000 (11:38 +0200)
Command systemctl stop foo.service, will print error message, when
foo.service is unknown to systemd, i.e. there is no unit file loaded for
this service.
https://bugzilla.redhat.com/show_bug.cgi?id=732874

src/core/dbus-manager.c

index e96929a55c502c422553814e5c63c285986eeff4..45243270338c6411495576429caa0f1c9399d622 100644 (file)
@@ -1587,6 +1587,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                                 job_type = JOB_RELOAD;
                 }
 
                                 job_type = JOB_RELOAD;
                 }
 
+                if (job_type == JOB_STOP && u->load_state == UNIT_ERROR && unit_active_state(u) == UNIT_INACTIVE) {
+                        dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name);
+                        return bus_send_error_reply(connection, message, &error, -EPERM);
+                }
+
                 if ((job_type == JOB_START && u->refuse_manual_start) ||
                     (job_type == JOB_STOP && u->refuse_manual_stop) ||
                     ((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&
                 if ((job_type == JOB_START && u->refuse_manual_start) ||
                     (job_type == JOB_STOP && u->refuse_manual_stop) ||
                     ((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&