diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-01-13 06:12:31 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-01-15 16:39:46 +0100 |
commit | 2cbb171d20a07ec0a25296f167b0385de102d74e (patch) | |
tree | 0fb35e18fc51d02fd1c8b04853da379b172dfb38 /src | |
parent | test: support a non-default SysV directory (diff) | |
download | systemd-2cbb171d20a07ec0a25296f167b0385de102d74e.tar.xz systemd-2cbb171d20a07ec0a25296f167b0385de102d74e.zip |
busctl: fix introspecting DBus properties
Follow-up for f2f7785d7a47ffa48ac929648794e1288509ddd8.
Fixes #26033.
Diffstat (limited to 'src')
-rw-r--r-- | src/busctl/busctl.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 32c6ed7cac..2b5552889b 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -1023,10 +1023,11 @@ static int introspect(int argc, char **argv, void *userdata) { for (;;) { Member *z; - _cleanup_free_ char *buf = NULL; + _cleanup_free_ char *buf = NULL, *signature = NULL; _cleanup_fclose_ FILE *mf = NULL; size_t sz = 0; - const char *name; + const char *name, *contents; + char type; r = sd_bus_message_enter_container(reply, 'e', "sv"); if (r < 0) @@ -1043,6 +1044,21 @@ static int introspect(int argc, char **argv, void *userdata) { if (r < 0) return bus_log_parse_error(r); + r = sd_bus_message_peek_type(reply, &type, &contents); + if (r <= 0) + return bus_log_parse_error(r == 0 ? EINVAL : r); + + if (type == SD_BUS_TYPE_STRUCT_BEGIN) + signature = strjoin(CHAR_TO_STR(SD_BUS_TYPE_STRUCT_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_END)); + else if (type == SD_BUS_TYPE_DICT_ENTRY_BEGIN) + signature = strjoin(CHAR_TO_STR(SD_BUS_TYPE_DICT_ENTRY_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_DICT_ENTRY_END)); + else if (contents) + signature = strjoin(CHAR_TO_STR(type), contents); + else + signature = strdup(CHAR_TO_STR(type)); + if (!signature) + return log_oom(); + mf = open_memstream_unlocked(&buf, &sz); if (!mf) return log_oom(); @@ -1056,6 +1072,7 @@ static int introspect(int argc, char **argv, void *userdata) { z = set_get(members, &((Member) { .type = "property", .interface = m->interface, + .signature = signature, .name = (char*) name })); if (z) free_and_replace(z->value, buf); |