summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-introspect.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-21 18:08:39 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-21 18:08:39 +0100
commit7fb411f035e68b5f3f5e2893157739c9da9917b0 (patch)
treefc342dcdf2623ec3421ea253bd5ce0a8b571f7a4 /src/libsystemd-bus/bus-introspect.c
parentb2bb3469fd01cec57f1f1726edb5b851ff8427ad (diff)
bus: when introspecting, turn unprivileged flag into inverse annoation of "privileged"
Internally, it makes sense to have a default of "privileged" for methods, and a flag to open it up. However, externally in the bus introspection turn this around since negative options actually suck.
Diffstat (limited to 'src/libsystemd-bus/bus-introspect.c')
-rw-r--r--src/libsystemd-bus/bus-introspect.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libsystemd-bus/bus-introspect.c b/src/libsystemd-bus/bus-introspect.c
index 504fab1b4b..4d5c25a23f 100644
--- a/src/libsystemd-bus/bus-introspect.c
+++ b/src/libsystemd-bus/bus-introspect.c
@@ -26,10 +26,11 @@
#include "bus-internal.h"
#include "bus-protocol.h"
-int introspect_begin(struct introspect *i) {
+int introspect_begin(struct introspect *i, bool trusted) {
assert(i);
zero(*i);
+ i->trusted = trusted;
i->f = open_memstream(&i->introspection, &i->size);
if (!i->f)
@@ -87,8 +88,10 @@ static void introspect_write_flags(struct introspect *i, int type, int flags) {
fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f);
}
- if ((type == _SD_BUS_VTABLE_METHOD || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) && (flags & SD_BUS_VTABLE_UNPRIVILEGED))
- fputs(" <annotation name=\"org.freedesktop.systemd1.Unprivileged\" value=\"true\"/>\n", i->f);
+ if (!i->trusted &&
+ (type == _SD_BUS_VTABLE_METHOD || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) &&
+ !(flags & SD_BUS_VTABLE_UNPRIVILEGED))
+ fputs(" <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f);
}
static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) {
@@ -121,6 +124,10 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
for (; v->type != _SD_BUS_VTABLE_END; v++) {
+ /* Ignore methods, signals and properties that are
+ * marked "hidden", but do show the interface
+ * itself */
+
if (v->type != _SD_BUS_VTABLE_START && (v->flags & SD_BUS_VTABLE_HIDDEN))
continue;