923a60
From e8f522de0e698d956f5d5305beec3862ae258f9a Mon Sep 17 00:00:00 2001
923a60
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
923a60
Date: Sat, 1 Jul 2017 16:17:12 -0400
923a60
Subject: [PATCH] Revert "bus: when dumping string property values escape the
923a60
 chars we use as end-of-line and end-of-item marks"
923a60
MIME-Version: 1.0
923a60
Content-Type: text/plain; charset=UTF-8
923a60
Content-Transfer-Encoding: 8bit
923a60
923a60
This reverts commit 27e9c5af817147ea1c678769e45e83f2e4b4ae96.
923a60
923a60
Property values already use escaping, so escaping them a second time is
923a60
confusing. It also should be mostly unnecessary: we take care to make property
923a60
values only contains strings which (after the initial escaping) are printable
923a60
and parseable without any futher escaping.
923a60
923a60
Before revert:
923a60
$ systemctl list-dependencies 'dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device'
923a60
dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device
923a60
● ├─dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.swap
923a60
● └─systemd-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service
923a60
$ systemctl show -p Wants,Requires 'dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device'
923a60
Requires=systemd-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service
923a60
Wants=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.swap
923a60
923a60
Difference between systemctl show before revert and now:
923a60
-Slice=system-systemd\x5cx2dcryptsetup.slice
923a60
+Slice=system-systemd\x2dcryptsetup.slice
923a60
923a60
-Id=systemd-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service
923a60
+Id=systemd-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service
923a60
923a60
-Names=systemd-cryptsetup@luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.service
923a60
+Names=systemd-cryptsetup@luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.service
923a60
923a60
-Requires=system-systemd\x5cx2dcryptsetup.slice
923a60
+Requires=system-systemd\x2dcryptsetup.slice
923a60
923a60
-BindsTo=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device dev-disk-by\x5cx2duuid-8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device
923a60
+BindsTo=dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device dev-disk-by\x2duuid-8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device
923a60
923a60
-RequiredBy=dev-mapper-luks\x5cx2d8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device cryptsetup.target
923a60
+RequiredBy=dev-mapper-luks\x2d8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device cryptsetup.target
923a60
923a60
-WantedBy=dev-disk-by\x5cx2duuid-8db85dcf\x5cx2d6230\x5cx2d4e88\x5cx2d940d\x5cx2dba176d062b31.device
923a60
+WantedBy=dev-disk-by\x2duuid-8db85dcf\x2d6230\x2d4e88\x2d940d\x2dba176d062b31.device
923a60
923a60
(cherry picked from commit 3dfbc968e8343172faf754a3c81e27f0dbd8f157)
923a60
923a60
Resolves: #1643172
923a60
---
923a60
 src/libsystemd/sd-bus/bus-util.c | 19 +++----------------
923a60
 1 file changed, 3 insertions(+), 16 deletions(-)
923a60
923a60
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
923a60
index b1bdbad2dd..9b77059a93 100644
923a60
--- a/src/libsystemd/sd-bus/bus-util.c
923a60
+++ b/src/libsystemd/sd-bus/bus-util.c
923a60
@@ -643,15 +643,8 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
923a60
                 if (r < 0)
923a60
                         return r;
923a60
 
923a60
-                if (all || !isempty(s)) {
923a60
-                        _cleanup_free_ char *escaped = NULL;
923a60
-
923a60
-                        escaped = xescape(s, "\n");
923a60
-                        if (!escaped)
923a60
-                                return -ENOMEM;
923a60
-
923a60
-                        printf("%s=%s\n", name, escaped);
923a60
-                }
923a60
+                if (all || !isempty(s))
923a60
+                        printf("%s=%s\n", name, s);
923a60
 
923a60
                 return 1;
923a60
         }
923a60
@@ -742,16 +735,10 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) {
923a60
                                 return r;
923a60
 
923a60
                         while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) {
923a60
-                                _cleanup_free_ char *escaped = NULL;
923a60
-
923a60
                                 if (first)
923a60
                                         printf("%s=", name);
923a60
 
923a60
-                                escaped = xescape(str, "\n ");
923a60
-                                if (!escaped)
923a60
-                                        return -ENOMEM;
923a60
-
923a60
-                                printf("%s%s", first ? "" : " ", escaped);
923a60
+                                printf("%s%s", first ? "" : " ", str);
923a60
 
923a60
                                 first = false;
923a60
                         }