SHA256
1
0
forked from pool/systemd
systemd/crypt-loop-file.patch
Cristian Rodríguez 5c11ee24a0 Accepting request 139371 from openSUSE:Factory:Staging:Systemd
- Create and own more systemd drop-in directories.

- Improve mini packages for bootstrapping.
- do not mount /tmp as tmpfs by default.

- Fix install script when there is no inittab

- Create a systemd-mini specfile to prevent cycle in bootstrapping

OBS-URL: https://build.opensuse.org/request/show/139371
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=300
2012-10-26 12:34:44 +00:00

79 lines
2.6 KiB
Diff

Index: systemd-190/src/cryptsetup/cryptsetup-generator.c
===================================================================
--- systemd-190.orig/src/cryptsetup/cryptsetup-generator.c
+++ systemd-190/src/cryptsetup/cryptsetup-generator.c
@@ -136,7 +136,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;
@@ -168,11 +168,51 @@ static int create_disk(
goto fail;
}
- d = unit_name_from_path(u, ".device");
- if (!d) {
- r = -ENOMEM;
- log_error("Failed to allocate device name.");
- goto fail;
+ if (!startswith(device,"/dev/")) {
+ d = unit_name_from_path_instance("cryptsetup", name, ".path");
+ if (!d) {
+ 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;
+ }
+
+ f = fopen(path_file, "wxe");
+ if (!f) {
+ 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 {
+ d = unit_name_from_path(u, ".device");
+ if (!d) {
+ r = -ENOMEM;
+ log_error("Failed to allocate device name.");
+ goto fail;
+ }
}
f = fopen(p, "wxe");
@@ -298,6 +338,7 @@ fail:
free(n);
free(d);
free(e);
+ free(path_file);
free(from);
free(to);