|
|
2aacef |
From 25e4d71e788ee7467e1d764c631de44d599e2b1c Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
2aacef |
Date: Fri, 13 Jan 2023 14:12:31 +0900
|
|
|
2aacef |
Subject: [PATCH] busctl: fix introspecting DBus properties
|
|
|
2aacef |
|
|
|
2aacef |
Follow-up for f2f7785d7a47ffa48ac929648794e1288509ddd8.
|
|
|
2aacef |
|
|
|
2aacef |
Fixes #26033.
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 2cbb171d20a07ec0a25296f167b0385de102d74e)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/busctl/busctl.c | 21 +++++++++++++++++++--
|
|
|
2aacef |
1 file changed, 19 insertions(+), 2 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
|
|
|
2aacef |
index f57a5d605d..cc2d0e3458 100644
|
|
|
2aacef |
--- a/src/busctl/busctl.c
|
|
|
2aacef |
+++ b/src/busctl/busctl.c
|
|
|
2aacef |
@@ -1022,10 +1022,11 @@ static int introspect(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
|
|
|
2aacef |
for (;;) {
|
|
|
2aacef |
Member *z;
|
|
|
2aacef |
- _cleanup_free_ char *buf = NULL;
|
|
|
2aacef |
+ _cleanup_free_ char *buf = NULL, *signature = NULL;
|
|
|
2aacef |
_cleanup_fclose_ FILE *mf = NULL;
|
|
|
2aacef |
size_t sz = 0;
|
|
|
2aacef |
- const char *name;
|
|
|
2aacef |
+ const char *name, *contents;
|
|
|
2aacef |
+ char type;
|
|
|
2aacef |
|
|
|
2aacef |
r = sd_bus_message_enter_container(reply, 'e', "sv");
|
|
|
2aacef |
if (r < 0)
|
|
|
2aacef |
@@ -1042,6 +1043,21 @@ static int introspect(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
if (r < 0)
|
|
|
2aacef |
return bus_log_parse_error(r);
|
|
|
2aacef |
|
|
|
2aacef |
+ r = sd_bus_message_peek_type(reply, &type, &contents);
|
|
|
2aacef |
+ if (r <= 0)
|
|
|
2aacef |
+ return bus_log_parse_error(r == 0 ? EINVAL : r);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ if (type == SD_BUS_TYPE_STRUCT_BEGIN)
|
|
|
2aacef |
+ signature = strjoin(CHAR_TO_STR(SD_BUS_TYPE_STRUCT_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_END));
|
|
|
2aacef |
+ else if (type == SD_BUS_TYPE_DICT_ENTRY_BEGIN)
|
|
|
2aacef |
+ signature = strjoin(CHAR_TO_STR(SD_BUS_TYPE_DICT_ENTRY_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_DICT_ENTRY_END));
|
|
|
2aacef |
+ else if (contents)
|
|
|
2aacef |
+ signature = strjoin(CHAR_TO_STR(type), contents);
|
|
|
2aacef |
+ else
|
|
|
2aacef |
+ signature = strdup(CHAR_TO_STR(type));
|
|
|
2aacef |
+ if (!signature)
|
|
|
2aacef |
+ return log_oom();
|
|
|
2aacef |
+
|
|
|
2aacef |
mf = open_memstream_unlocked(&buf, &sz);
|
|
|
2aacef |
if (!mf)
|
|
|
2aacef |
return log_oom();
|
|
|
2aacef |
@@ -1055,6 +1071,7 @@ static int introspect(int argc, char **argv, void *userdata) {
|
|
|
2aacef |
z = set_get(members, &((Member) {
|
|
|
2aacef |
.type = "property",
|
|
|
2aacef |
.interface = m->interface,
|
|
|
2aacef |
+ .signature = signature,
|
|
|
2aacef |
.name = (char*) name }));
|
|
|
2aacef |
if (z)
|
|
|
2aacef |
free_and_replace(z->value, buf);
|