summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2013-02-15 16:10:36 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-16 09:53:49 -0500
commitd0a5cdb280f904eafacb09bbc391afd03c207b62 (patch)
treecb70328c4f4fe7feafd58d7a71fb20be634ff894 /src
parent265a7a2a604a9cf92e8aa167ed48afb78e6602ea (diff)
systemctl: Don't give re-activation warning if unit is masked
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index becd68ff6e..ddf46b66d5 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1336,7 +1336,9 @@ static void check_triggering_units(
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
DBusMessageIter iter, sub;
const char *interface = "org.freedesktop.systemd1.Unit",
- *triggered_by_property = "TriggeredBy";
+ *load_state_property = "LoadState",
+ *triggered_by_property = "TriggeredBy",
+ *state;
char _cleanup_free_ *unit_path = NULL, *n = NULL;
bool print_warning_label = true;
int r;
@@ -1362,6 +1364,41 @@ static void check_triggering_units(
&reply,
NULL,
DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &load_state_property,
+ DBUS_TYPE_INVALID);
+ if (r < 0)
+ return;
+
+ if (!dbus_message_iter_init(reply, &iter) ||
+ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
+ log_error("Failed to parse reply.");
+ return;
+ }
+
+ dbus_message_iter_recurse(&iter, &sub);
+
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+ log_error("Failed to parse reply.");
+ return;
+ }
+
+ dbus_message_iter_get_basic(&sub, &state);
+
+ if (streq(state, "masked"))
+ return;
+
+ dbus_message_unref(reply);
+ reply = NULL;
+
+ r = bus_method_call_with_reply(
+ bus,
+ "org.freedesktop.systemd1",
+ unit_path,
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ &reply,
+ NULL,
+ DBUS_TYPE_STRING, &interface,
DBUS_TYPE_STRING, &triggered_by_property,
DBUS_TYPE_INVALID);
if (r < 0)