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