summaryrefslogtreecommitdiff
path: root/src/core/dbus-manager.c
diff options
context:
space:
mode:
authorMichal Sekletar <msekleta@redhat.com>2012-06-19 10:00:54 +0200
committerMichal Schmidt <mschmidt@redhat.com>2012-06-19 11:38:22 +0200
commit9722ef2565fdddd64deaa99d7665ca0fdafed1a5 (patch)
tree644fa824edc46e682f9b4c0de6da392524b97129 /src/core/dbus-manager.c
parentb30b4260255702345eab1ac076bb00869057c16b (diff)
systemd: return error when asked to stop unknown unit
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
Diffstat (limited to 'src/core/dbus-manager.c')
-rw-r--r--src/core/dbus-manager.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index e96929a55c..4524327033 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1587,6 +1587,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
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) &&