[systemd-devel] [PATCH 1/2] cryptsetup: RequiresMountsFor if source is a file
Thomas Weißschuh
thomas at t-8ch.de
Wed Mar 27 10:52:56 PDT 2013
Fixes bug 60821
---
TODO | 1 -
src/cryptsetup/cryptsetup-generator.c | 22 ++++++++++++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/TODO b/TODO
index e54f84b..fc05317 100644
--- a/TODO
+++ b/TODO
@@ -354,7 +354,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
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 8959bf5..00e7f7d 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -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 at .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 (startswith(u, "/dev/"))
+ 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"
--
1.8.2
More information about the systemd-devel
mailing list