teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

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

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