summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-09 13:55:35 +0200
committerGitHub <noreply@github.com>2020-04-09 13:55:35 +0200
commit4d1f2c621fb0ef21be3bff4cb231c8526cccd94b (patch)
tree9b2627ddd320bfb971d47a863668f69e50210fa2 /src/shared
parenta1db42eb0b3b3a6e00bc02d724052d1ef41584a9 (diff)
parent241c4b6adae3ec015f69b34174511e6912d1f0d0 (diff)
downloadsystemd-4d1f2c621fb0ef21be3bff4cb231c8526cccd94b.tar.gz
Merge pull request #15345 from keszybz/systemctl-show-spaces
Show Environment= entries with spaces in systemctl
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-util.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index dbbd0dcae6..05762c68a3 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -21,6 +21,7 @@
#include "bus-util.h"
#include "cap-list.h"
#include "cgroup-util.h"
+#include "escape.h"
#include "mountpoint-util.h"
#include "nsflags.h"
#include "parse-util.h"
@@ -500,18 +501,20 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
return r;
while ((r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &str)) > 0) {
- bool good;
+ _cleanup_free_ char *e = NULL;
- if (first && !value)
- printf("%s=", name);
-
- /* This property has multiple space-separated values, so
- * neither spaces nor newlines can be allowed in a value. */
- good = str[strcspn(str, " \n")] == '\0';
+ e = shell_maybe_quote(str, ESCAPE_BACKSLASH_ONELINE);
+ if (!e)
+ return -ENOMEM;
- printf("%s%s", first ? "" : " ", good ? str : "[unprintable]");
+ if (first) {
+ if (!value)
+ printf("%s=", name);
+ first = false;
+ } else
+ fputs(" ", stdout);
- first = false;
+ fputs(e, stdout);
}
if (r < 0)
return r;