daandemeyer / rpms / systemd

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