chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: fix bus_print_property with strv
[elogind.git]
/
src
/
libsystemd-bus
/
bus-util.c
diff --git
a/src/libsystemd-bus/bus-util.c
b/src/libsystemd-bus/bus-util.c
index eec70ed15270c56e246e01597caa56695e4e09d9..2b1cd0bc8375efdc91052a426098a5a8c0cd37ff 100644
(file)
--- a/
src/libsystemd-bus/bus-util.c
+++ b/
src/libsystemd-bus/bus-util.c
@@
-151,7
+151,7
@@
int bus_verify_polkit(
#ifdef ENABLE_POLKIT
else {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
#ifdef ENABLE_POLKIT
else {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-
unsigned
authorized = false, challenge = false;
+
int
authorized = false, challenge = false;
r = sd_bus_call_method(
bus,
r = sd_bus_call_method(
bus,
@@
-178,9
+178,9
@@
int bus_verify_polkit(
return r;
}
return r;
}
- r = sd_bus_message_
read(reply, "(bb)", &authorized, &challenge
);
- if (r
<
0)
- r
eturn r
;
+ r = sd_bus_message_
enter_container(reply, 'r', "bba{ss}"
);
+ if (r
>=
0)
+ r
= sd_bus_message_read(reply, "bb", &authorized, &challenge)
;
if (authorized)
return 1;
if (authorized)
return 1;
@@
-270,7
+270,7
@@
int bus_verify_polkit_async(
#ifdef ENABLE_POLKIT
q = hashmap_remove(*registry, m);
if (q) {
#ifdef ENABLE_POLKIT
q = hashmap_remove(*registry, m);
if (q) {
-
unsigned
authorized, challenge;
+
int
authorized, challenge;
/* This is the second invocation of this function, and
* there's already a response from polkit, let's
/* This is the second invocation of this function, and
* there's already a response from polkit, let's
@@
-545,33
+545,28
@@
int bus_print_property(const char *name, sd_bus_message *property, bool all) {
case SD_BUS_TYPE_ARRAY:
if (streq(contents, "s")) {
case SD_BUS_TYPE_ARRAY:
if (streq(contents, "s")) {
- bool space = false;
- char tp;
- const char *cnt;
+ bool first = true;
+ const char *str;
r = sd_bus_message_enter_container(property, SD_BUS_TYPE_ARRAY, contents);
if (r < 0)
return r;
r = sd_bus_message_enter_container(property, SD_BUS_TYPE_ARRAY, contents);
if (r < 0)
return r;
- r = sd_bus_message_peek_type(property, &tp, &cnt);
+ while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) {
+ if (first)
+ printf("%s=", name);
+
+ printf("%s%s", first ? "" : " ", str);
+
+ first = false;
+ }
if (r < 0)
return r;
if (r < 0)
return r;
- if (all || cnt) {
- const char *str;
-
+ if (first && all)
printf("%s=", name);
printf("%s=", name);
-
- while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) >= 0) {
- printf("%s%s", space ? " " : "", str);
-
- space = true;
- }
- if (r < 0)
- return r;
-
+ if (!first || all)
puts("");
puts("");
- }
r = sd_bus_message_exit_container(property);
if (r < 0)
r = sd_bus_message_exit_container(property);
if (r < 0)
@@
-628,7
+623,7
@@
int bus_print_property(const char *name, sd_bus_message *property, bool all) {
return 0;
}
return 0;
}
-int bus_print_all_properties(sd_bus *bus, const char *path, char **filter, bool all) {
+int bus_print_all_properties(sd_bus *bus, const char *
dest, const char *
path, char **filter, bool all) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
@@
-637,7
+632,7
@@
int bus_print_all_properties(sd_bus *bus, const char *path, char **filter, bool
assert(path);
r = sd_bus_call_method(bus,
assert(path);
r = sd_bus_call_method(bus,
-
"org.freedesktop.machine1"
,
+
dest
,
path,
"org.freedesktop.DBus.Properties",
"GetAll",
path,
"org.freedesktop.DBus.Properties",
"GetAll",
@@
-671,8
+666,14
@@
int bus_print_all_properties(sd_bus *bus, const char *path, char **filter, bool
r = bus_print_property(name, reply, all);
if (r < 0)
return r;
r = bus_print_property(name, reply, all);
if (r < 0)
return r;
- if (r == 0 && all)
- printf("%s=[unprintable]\n", name);
+ if (r == 0) {
+ if (all)
+ printf("%s=[unprintable]\n", name);
+ /* skip what we didn't read */
+ r = sd_bus_message_skip(reply, contents);
+ if (r < 0)
+ return r;
+ }
r = sd_bus_message_exit_container(reply);
if (r < 0)
r = sd_bus_message_exit_container(reply);
if (r < 0)
@@
-866,7
+867,7
@@
int bus_map_all_properties(sd_bus *bus,
return r;
v = (uint8_t *)userdata + prop->offset;
return r;
v = (uint8_t *)userdata + prop->offset;
-
if (map[i].set)
+ if (map[i].set)
r = prop->set(bus, member, m, &error, v);
else
r = map_basic(bus, member, m, &error, v);
r = prop->set(bus, member, m, &error, v);
else
r = map_basic(bus, member, m, &error, v);