summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-05 02:54:08 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-05 03:07:39 +0100
commit275b39fe4bf19f244114dbefa58e0d77047eff4a (patch)
treecfc43742b5e181606663eae253f2e02c40d86476 /src/libsystemd-bus/bus-message.c
parent9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75 (diff)
bus: support entering containers without specifying the type
On request om Tom Gundersen...
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 78adf11ae8..7a4c65d689 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -2982,12 +2982,28 @@ int sd_bus_message_enter_container(sd_bus_message *m, char type, const char *con
size_t before;
int r;
- if (!m)
- return -EINVAL;
- if (!m->sealed)
- return -EPERM;
- if (!contents)
- return -EINVAL;
+ assert_return(m, -EINVAL);
+ assert_return(m->sealed, -EPERM);
+ assert_return(type != 0 || !contents, -EINVAL);
+
+ if (type == 0 || !contents) {
+ const char *cc;
+ char tt;
+
+ /* Allow entering into anonymous containers */
+ r = sd_bus_message_peek_type(m, &tt, &cc);
+ if (r <= 0)
+ return r;
+
+ if (type != 0 && type != tt)
+ return -ENXIO;
+
+ if (contents && !streq(contents, cc))
+ return -ENXIO;
+
+ type = tt;
+ contents = cc;
+ }
/*
* We enforce a global limit on container depth, that is much