chiark / gitweb /
fstab-generator: cescape device name in root-fsck service
authorAndrei Borzenkov <arvidjaar@gmail.com>
Wed, 3 Jun 2015 17:50:59 +0000 (20:50 +0300)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:01:46 +0000 (10:01 +0100)
We unescape ExecStart line when parsing it, so escape device name
before adding it to unit file.

fixes #50

src/shared/generator.c

index 807569a1b8b008bde3f9fba4d5295e639d857f69..e58bbea77ccf7ec306fa009a853056c315a13cdd 100644 (file)
 static int write_fsck_sysroot_service(const char *dir, const char *what) {
         const char *unit;
         _cleanup_free_ char *device = NULL;
+        _cleanup_free_ char *escaped;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
 
+        escaped = cescape(what);
+        if (!escaped)
+                return log_oom();
+
         unit = strjoina(dir, "/systemd-fsck-root.service");
         log_debug("Creating %s", unit);
 
@@ -61,11 +66,12 @@ static int write_fsck_sysroot_service(const char *dir, const char *what) {
                 "[Service]\n"
                 "Type=oneshot\n"
                 "RemainAfterExit=yes\n"
-                "ExecStart=" SYSTEMD_FSCK_PATH " %2$s\n"
+                "ExecStart=" SYSTEMD_FSCK_PATH " %4$s\n"
                 "TimeoutSec=0\n",
                 program_invocation_short_name,
                 what,
-                device);
+                device,
+                escaped);
 
         r = fflush_and_check(f);
         if (r < 0)