summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-01-26 20:07:14 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-09 11:06:38 +0000
commit3d1426ac72cf220cf0f08d2dbc7ec98115024eee (patch)
tree394f883be9f5d3a4e54d244a9dce9c680a58e3bf /test
parenta3c1b66b7a784280b0763ee4014c258144ae7876 (diff)
downloaddbus-3d1426ac72cf220cf0f08d2dbc7ec98115024eee.tar.gz
Add a regression test for making systemd activation appear to fail
Diffstat (limited to 'test')
-rw-r--r--test/sd-activation.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/sd-activation.c b/test/sd-activation.c
index b9ea323f..2a7366df 100644
--- a/test/sd-activation.c
+++ b/test/sd-activation.c
@@ -211,6 +211,37 @@ test_activation (Fixture *f,
"org.freedesktop.systemd1");
dbus_message_unref (m);
+ /* A malicious process tries to disrupt the activation.
+ * In a more realistic scenario this would be another parallel
+ * connection. */
+ m = dbus_message_new_signal ("/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Activator", "ActivationFailure");
+ if (!dbus_message_set_destination (m, "org.freedesktop.DBus"))
+ g_error ("OOM");
+
+ do
+ {
+ const char *unit = "dbus-com.example.SystemdActivatable2.service";
+ const char *error_name = "com.example.Malice";
+ const char *error_message = "I'm on yr bus, making yr activations fail";
+
+ if (!dbus_message_append_args (m,
+ DBUS_TYPE_STRING, &unit,
+ DBUS_TYPE_STRING, &error_name,
+ DBUS_TYPE_STRING, &error_message,
+ DBUS_TYPE_INVALID))
+ g_error ("OOM");
+ }
+ while (0);
+
+ dbus_connection_send (f->caller, m, NULL);
+ dbus_message_unref (m);
+
+ /* This is just to make sure that the malicious message has arrived and
+ * been processed by the dbus-daemon, i.e. @caller won the race
+ * with @activated. */
+ take_well_known_name (f, f->caller, "com.example.Sync");
+
/* The activatable service takes its name. Here I'm faking it by using
* an existing connection; in real life it would be yet another
* connection. */