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