teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0304-fstab-generator-cescape-device-name-in-root-fsck-ser.patch

923a60
From e591c1a47c067cd2d14dca569cc9f0cce9072200 Mon Sep 17 00:00:00 2001
923a60
From: Andrei Borzenkov <arvidjaar@gmail.com>
923a60
Date: Wed, 3 Jun 2015 20:50:59 +0300
923a60
Subject: [PATCH] fstab-generator: cescape device name in root-fsck service
923a60
923a60
We unescape ExecStart line when parsing it, so escape device name
923a60
before adding it to unit file.
923a60
923a60
fixes #50
923a60
923a60
Cherry-picked from: fa05e97
923a60
Resolves: #1306126
923a60
---
923a60
 src/shared/generator.c | 10 ++++++++--
923a60
 1 file changed, 8 insertions(+), 2 deletions(-)
923a60
923a60
diff --git a/src/shared/generator.c b/src/shared/generator.c
923a60
index 3af84a325c..be8e24eb49 100644
923a60
--- a/src/shared/generator.c
923a60
+++ b/src/shared/generator.c
923a60
@@ -35,8 +35,13 @@
923a60
 static int write_fsck_sysroot_service(const char *dir, const char *what) {
923a60
         const char *unit;
923a60
         _cleanup_free_ char *device = NULL;
923a60
+        _cleanup_free_ char *escaped;
923a60
         _cleanup_fclose_ FILE *f = NULL;
923a60
 
923a60
+        escaped = cescape(what);
923a60
+        if (!escaped)
923a60
+                return log_oom();
923a60
+
923a60
         unit = strjoina(dir, "/systemd-fsck-root.service");
923a60
         log_debug("Creating %s", unit);
923a60
 
923a60
@@ -61,11 +66,12 @@ static int write_fsck_sysroot_service(const char *dir, const char *what) {
923a60
                 "[Service]\n"
923a60
                 "Type=oneshot\n"
923a60
                 "RemainAfterExit=yes\n"
923a60
-                "ExecStart=" SYSTEMD_FSCK_PATH " %2$s\n"
923a60
+                "ExecStart=" SYSTEMD_FSCK_PATH " %4$s\n"
923a60
                 "TimeoutSec=0\n",
923a60
                 program_invocation_short_name,
923a60
                 what,
923a60
-                device);
923a60
+                device,
923a60
+                escaped);
923a60
 
923a60
         fflush(f);
923a60
         if (ferror(f))