]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: RequiresMountsFor if source is a file
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 29 Mar 2013 22:01:11 +0000 (22:01 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 1 Apr 2013 04:37:48 +0000 (00:37 -0400)
Fixes: https://bugzilla.novell.com/show_bug.cgi?id=730496
       https://bugs.freedesktop.org/show_bug.cgi?id=60821

TODO
src/cryptsetup/cryptsetup-generator.c

diff --git a/TODO b/TODO
index 22caac4938f53db19867cd5cd35f7c9c274e6a8e..5009653dd17848c05a868ae9dc5d46e9af4c2432 100644 (file)
--- a/TODO
+++ b/TODO
@@ -365,7 +365,6 @@ Features:
 
 * cryptsetup:
   - cryptsetup-generator: warn if the password files are world-readable
-  - cryptsetup-generator: add RequiresMountsFor= to cryptseup service files referencing a file, similar for devices
   - cryptsetup-generator: allow specification of passwords in crypttab itself
   - move cryptsetup key caching into kernel keyctl?
     https://bugs.freedesktop.org/show_bug.cgi?id=54982
index 8959bf51c8c72fb757ac93c14d003d20c5caf170..a8c856f7df45ea993fa11d755d927f27e546ffab 100644 (file)
@@ -102,18 +102,17 @@ static int create_disk(
                 return -errno;
         }
 
-        fprintf(f,
+        fputs(
                 "# Automatically generated by systemd-cryptsetup-generator\n\n"
                 "[Unit]\n"
-                "Description=Cryptography Setup for %%I\n"
+                "Description=Cryptography Setup for %I\n"
                 "Documentation=man:systemd-cryptsetup@.service(8) man:crypttab(5)\n"
                 "SourcePath=/etc/crypttab\n"
                 "Conflicts=umount.target\n"
                 "DefaultDependencies=no\n"
-                "BindsTo=%s dev-mapper-%%i.device\n"
-                "After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
-                "Before=umount.target\n",
-                d, d);
+                "BindsTo=dev-mapper-%i.device\n"
+                "After=systemd-readahead-collect.service systemd-readahead-replay.service\n",
+                f);
 
         if (!nofail)
                 fprintf(f,
@@ -126,6 +125,17 @@ static int create_disk(
         else
                 fputs("Before=local-fs.target\n", f);
 
+        if (is_device_path(u))
+                fprintf(f,
+                        "BindsTo=%s\n"
+                        "After=%s\n"
+                        "Before=umount.target\n",
+                        d, d);
+        else
+                fprintf(f,
+                        "RequiresMountsFor=%s\n",
+                        u);
+
         fprintf(f,
                 "\n[Service]\n"
                 "Type=oneshot\n"