2013-01-24 10:41:58 +01:00
|
|
|
Index: systemd-195/src/cryptsetup/cryptsetup-generator.c
|
2011-12-12 16:59:25 +01:00
|
|
|
===================================================================
|
2013-01-24 10:41:58 +01:00
|
|
|
--- systemd-195.orig/src/cryptsetup/cryptsetup-generator.c
|
|
|
|
+++ systemd-195/src/cryptsetup/cryptsetup-generator.c
|
2012-11-02 17:30:32 +01:00
|
|
|
@@ -136,7 +136,7 @@ static int create_disk(
|
2011-12-12 16:59:25 +01:00
|
|
|
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;
|
2013-01-24 10:41:58 +01:00
|
|
|
@@ -168,11 +168,63 @@ static int create_disk(
|
2011-12-12 16:59:25 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2012-11-02 17:30:32 +01:00
|
|
|
- d = unit_name_from_path(u, ".device");
|
|
|
|
- if (!d) {
|
2011-12-12 16:59:25 +01:00
|
|
|
- r = -ENOMEM;
|
|
|
|
- log_error("Failed to allocate device name.");
|
|
|
|
- goto fail;
|
|
|
|
+ if (!startswith(device,"/dev/")) {
|
2013-01-24 10:41:58 +01:00
|
|
|
+ char *e;
|
|
|
|
+
|
|
|
|
+ d = strdup(n);
|
2012-11-02 17:30:32 +01:00
|
|
|
+ if (!d) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ log_error("Failed to allocate path name.");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2013-01-24 10:41:58 +01:00
|
|
|
+ e = endswith(d,".service");
|
|
|
|
+ if (!e) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ log_error("Failed to modify path name.");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *e = 0;
|
|
|
|
+
|
|
|
|
+ d = strcat(d,".path");
|
2012-11-02 17:30:32 +01:00
|
|
|
+ if (asprintf(&path_file, "%s/%s", arg_dest, d) < 0) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ log_error("Failed to allocate unit file name.");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2012-11-02 17:30:32 +01:00
|
|
|
+ f = fopen(path_file, "wxe");
|
|
|
|
+ if (!f) {
|
|
|
|
+ r = -errno;
|
2013-01-24 10:41:58 +01:00
|
|
|
+ log_error("Failed to create unit file %s: %m", path_file);
|
2012-11-02 17:30:32 +01:00
|
|
|
+ goto fail;
|
|
|
|
+ }
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2012-11-02 17:30:32 +01:00
|
|
|
+ fprintf(f,
|
|
|
|
+ "[Unit]\n"
|
|
|
|
+ "Description=Cryptography Setup for %s\n"
|
|
|
|
+ "DefaultDependencies=no\n"
|
|
|
|
+ "[Path]\n"
|
|
|
|
+ "PathExists=%s\n",
|
|
|
|
+ device, device);
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2012-11-02 17:30:32 +01:00
|
|
|
+ fflush(f);
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2012-11-02 17:30:32 +01:00
|
|
|
+ if (ferror(f)) {
|
|
|
|
+ r = -errno;
|
|
|
|
+ log_error("Failed to write file: %m");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
2011-12-12 16:59:25 +01:00
|
|
|
+
|
2012-11-02 17:30:32 +01:00
|
|
|
+ f = NULL;
|
2011-12-12 16:59:25 +01:00
|
|
|
+ } else {
|
2012-11-02 17:30:32 +01:00
|
|
|
+ d = unit_name_from_path(u, ".device");
|
|
|
|
+ if (!d) {
|
|
|
|
+ r = -ENOMEM;
|
|
|
|
+ log_error("Failed to allocate device name.");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
2011-12-12 16:59:25 +01:00
|
|
|
}
|
|
|
|
|
2012-11-02 17:30:32 +01:00
|
|
|
f = fopen(p, "wxe");
|
2013-01-24 10:41:58 +01:00
|
|
|
@@ -298,6 +350,7 @@ fail:
|
2011-12-12 16:59:25 +01:00
|
|
|
free(n);
|
|
|
|
free(d);
|
|
|
|
free(e);
|
|
|
|
+ free(path_file);
|
|
|
|
|
|
|
|
free(from);
|
|
|
|
free(to);
|