Commit bf86d1f2 authored by Martin Pitt's avatar Martin Pitt

Check for correct signatures when setting properties

Fixes systemd getting stuck on trying to set invalid property types.
Patch backported from v218.

Closes: #781602
parent 50446f97
......@@ -10,6 +10,8 @@ systemd (215-15) UNRELEASED; urgency=medium
* Make logind work in environments without CAP_SYS_ADMIN (mostly
containers). Thanks Christian Seiler for the backporting!
(Closes: #778608)
* Check for correct signatures when setting properties. Fixes systemd
getting stuck on trying to set invalid property types. (Closes: #781602)
-- Martin Pitt <mpitt@debian.org> Wed, 08 Apr 2015 10:53:38 +0200
......
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 20 Nov 2014 20:58:39 +0100
Subject: sd-bus: create clean error when a property Set() call with incorrect
signature is passed in
---
src/libsystemd/sd-bus/bus-objects.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index dbb04e5..d8ee8ff 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -619,6 +619,9 @@ static int property_get_set_callbacks_run(
return r;
} else {
+ const char *signature = NULL;
+ char type = 0;
+
if (c->vtable->type != _SD_BUS_VTABLE_WRITABLE_PROPERTY)
return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_PROPERTY_READ_ONLY, "Property '%s' is not writable.", c->member);
@@ -630,6 +633,13 @@ static int property_get_set_callbacks_run(
c->last_iteration = bus->iteration_counter;
+ r = sd_bus_message_peek_type(m, &type, &signature);
+ if (r < 0)
+ return r;
+
+ if (type != 'v' || !streq(strempty(signature), strempty(c->vtable->x.property.signature)))
+ return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Incorrect parameters for property '%s', expected '%s', got '%s'.", c->member, strempty(c->vtable->x.property.signature), strempty(signature));
+
r = sd_bus_message_enter_container(m, 'v', c->vtable->x.property.signature);
if (r < 0)
return r;
......@@ -147,6 +147,7 @@ core-if-two-start-jobs-for-the-same-swap-device-node.patch
units-make-sure-container-getty-.service-stops-resta.patch
timesyncd-enable-timesyncd-in-virtual-machines.patch
logind-handle-runtime-dir-without-CAP_SYS_ADMIN.patch
sd-bus-create-clean-error-when-a-property-Set-call-w.patch
## Debian specific patches:
Add-back-support-for-Debian-specific-config-files.patch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment