Le jeudi 15 décembre 2011 à 16:57 +0100, Lennart Poettering a écrit : > On Thu, 15.12.11 16:21, Frederic Crozat (fcro...@suse.com) wrote: > > > > > Le jeudi 15 décembre 2011 à 16:11 +0100, Lennart Poettering a écrit : > > > On Thu, 08.12.11 13:55, Frederic Crozat (fcro...@suse.com) wrote: > > > > > > > Hi, > > > > > > > > when cryptoloop files are present in /etc/crypttab, systemd is not > > > > correctly creating dependencies for mounting them. Attached patch fixes > > > > this issue. > > > > > > Hmm, cryptoloop? Isn't this kinda obsolete? Can't dm-crypt handle those > > > two in compat mode? Can you elaborate on what cryptoloop precisely does > > > here differently than dm-crypt, and why we want to support this? (Sorry, > > > I am simply not up-to-date on cryptoloop, and would like to be brought > > > up to speed, on what this is...) > > > > Sorry, I incorrectly wrote "cryptoloop", while talking about file-based > > cryptsetup (ie dm-crypt). So, it is not about an "obsolete" thing :) > > Oh, that makes a lot more sense then. May I ask you to repost the patch > with a correct commit text?
Here it is: -- Frederic Crozat <fcro...@suse.com> SUSE
>From 652c2db8bb47c7fef243406e2be22aa4efcd3c0e Mon Sep 17 00:00:00 2001 From: Frederic Crozat <fcro...@suse.com> Date: Thu, 8 Dec 2011 13:51:17 +0100 Subject: [PATCH] cryptsetup-generator: correctly create unit for encrypted file Ensure unit created for encrypted file is a path unit and not a device one. --- src/cryptsetup-generator.c | 51 +++++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/cryptsetup-generator.c b/src/cryptsetup-generator.c index a48b7a4..0cae431 100644 --- a/src/cryptsetup-generator.c +++ b/src/cryptsetup-generator.c @@ -64,7 +64,7 @@ static int create_disk( const char *password, const char *options) { - char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL; + char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL, *path_file = NULL; int r; FILE *f = NULL; bool noauto, nofail; @@ -93,10 +93,50 @@ static int create_disk( goto fail; } - if (!(d = unit_name_from_path(u, ".device"))) { - r = -ENOMEM; - log_error("Failed to allocate device name."); - goto fail; + if (!startswith(device,"/dev/")) { + + if (!(d = unit_name_build_escape("cryptsetup", name, ".path"))) { + r = -ENOMEM; + log_error("Failed to allocate path name."); + goto fail; + } + + if (asprintf(&path_file, "%s/%s", arg_dest, d) < 0) { + r = -ENOMEM; + log_error("Failed to allocate unit file name."); + goto fail; + } + + if (!(f = fopen(path_file, "wxe"))) { + r = -errno; + log_error("Failed to create unit file: %m"); + goto fail; + } + + fprintf(f, + "[Unit]\n" + "Description=Cryptography Setup for %s\n" + "DefaultDependencies=no\n" + "[Path]\n" + "PathExists=%s\n", + device, device); + + fflush(f); + + if (ferror(f)) { + r = -errno; + log_error("Failed to write file: %m"); + goto fail; + } + + f = NULL; + } else { + + if (!(d = unit_name_from_path(u, ".device"))) { + r = -ENOMEM; + log_error("Failed to allocate device name."); + goto fail; + } } if (!(f = fopen(p, "wxe"))) { @@ -222,6 +262,7 @@ fail: free(n); free(d); free(e); + free(path_file); free(from); free(to); -- 1.7.7
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel