dryang / rpms / systemd

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