[PATCH 1/3] Revert "systemd: Escape only needed characters for machined"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This reverts commit 0e0149ce91d84f40b98acf4c4bb0da6e29b9c15c.

That commit was added to comply with systemd rules that were changed in
the meantime, so this patch is pointless.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/util/virsystemd.c  | 23 +++++++----------------
 tests/virsystemdtest.c |  4 ++--
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 337d6a208ab6..abd883c73844 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -38,17 +38,8 @@

 VIR_LOG_INIT("util.systemd");

-/**
- * virSystemdEscapeName:
- *
- * This function escapes various characters in @name and appends that
- * escaped string to @buf, in order to comply with the requirements
- * from systemd/machined.  Parameter @full_escape decides whether to
- * also escape dot as a first character and '-'.
- */
 static void virSystemdEscapeName(virBufferPtr buf,
-                                 const char *name,
-                                 bool full_escape)
+                                 const char *name)
 {
     static const char hextable[16] = "0123456789abcdef";

@@ -66,7 +57,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"            \
         ":-_.\\"

-    if (full_escape && *name == '.') {
+    if (*name == '.') {
         ESCAPE(*name);
         name++;
     }
@@ -74,7 +65,7 @@ static void virSystemdEscapeName(virBufferPtr buf,
     while (*name) {
         if (*name == '/')
             virBufferAddChar(buf, '-');
-        else if ((full_escape && *name == '-') ||
+        else if (*name == '-' ||
                  *name == '\\' ||
                  !strchr(VALID_CHARS, *name))
             ESCAPE(*name);
@@ -94,9 +85,9 @@ char *virSystemdMakeScopeName(const char *name,
     virBuffer buf = VIR_BUFFER_INITIALIZER;

     virBufferAddLit(&buf, "machine-");
-    virSystemdEscapeName(&buf, drivername, true);
+    virSystemdEscapeName(&buf, drivername);
     virBufferAddLit(&buf, "\\x2d");
-    virSystemdEscapeName(&buf, name, true);
+    virSystemdEscapeName(&buf, name);
     virBufferAddLit(&buf, ".scope");

     if (virBufferCheckError(&buf) < 0)
@@ -113,7 +104,7 @@ char *virSystemdMakeSliceName(const char *partition)
     if (*partition == '/')
         partition++;

-    virSystemdEscapeName(&buf, partition, true);
+    virSystemdEscapeName(&buf, partition);
     virBufferAddLit(&buf, ".slice");

     if (virBufferCheckError(&buf) < 0)
@@ -139,7 +130,7 @@ char *virSystemdMakeMachineName(const char *name,
         virBufferAsprintf(&buf, "%s-%s-", username, drivername);
     }

-    virSystemdEscapeName(&buf, name, false);
+    virSystemdEscapeName(&buf, name);

     machinename = virBufferContentAndReset(&buf);
  cleanup:
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 49d37c2032ec..06fec5495bc2 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -517,9 +517,9 @@ mymain(void)
     } while (0)

     TEST_MACHINE("demo", "qemu-demo");
-    TEST_MACHINE("demo-name", "qemu-demo-name");
+    TEST_MACHINE("demo-name", "qemu-demo\\x2dname");
     TEST_MACHINE("demo!name", "qemu-demo\\x21name");
-    TEST_MACHINE(".demo", "qemu-.demo");
+    TEST_MACHINE(".demo", "qemu-\\x2edemo");
     TEST_MACHINE("bull\U0001f4a9", "qemu-bull\\xf0\\x9f\\x92\\xa9");

 # define TESTS_PM_SUPPORT_HELPER(name, function)                        \
-- 
2.7.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]