[systemd-devel] [PATCH] systemd: return error when asked to stop unknown unit

2012-06-19 Thread Michal Sekletar
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 |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index e96929a..4524327 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) 

-- 
1.7.10.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemd: return error when asked to stop unknown unit

2012-06-19 Thread Michal Schmidt

On 06/19/2012 10:00 AM, Michal Sekletar wrote:

+if (job_type == JOB_STOP  u-load_state == UNIT_ERROR  
unit_active_state(u) == UNIT_INACTIVE) {


In case anyone's wondering why there's the check for the unit's active 
state: It is possible to have units that are active and have a load 
error at the same time. We want to be able to stop these units.


Thanks, applied.

Michal
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel