2012-01-18 17:44:20 +01:00
|
|
|
Index: systemd-37/src/cryptsetup/cryptsetup-generator.c
|
2011-12-09 15:44:59 +01:00
|
|
|
===================================================================
|
2012-01-18 17:44:20 +01:00
|
|
|
--- systemd-37.orig/src/cryptsetup/cryptsetup-generator.c
|
|
|
|
+++ systemd-37/src/cryptsetup/cryptsetup-generator.c
|
2011-12-09 15:44:59 +01:00
|
|
|
@@ -138,7 +138,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;
|
|
|
|
@@ -167,10 +167,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"))) {
|
|
|
|
@@ -300,6 +340,7 @@ fail:
|
|
|
|
free(n);
|
|
|
|
free(d);
|
|
|
|
free(e);
|
|
|
|
+ free(path_file);
|
|
|
|
|
|
|
|
free(from);
|
|
|
|
free(to);
|