SHA256
1
0
forked from pool/systemd
systemd/force-lvm-restart-after-cryptsetup-target-is-reached.patch
Dr. Werner Fink 58624a23ff Accepting request 172582 from home:fcrozat:branches:Base:System
- Update to release 202:
  + 'systemctl list-jobs' got some polishing. '--type=' argument
    may now be passed more than once. 'systemctl list-sockets' has
    been added.
  + systemd gained a new unit 'systemd-static-nodes.service'
    that generates static device nodes earlier during boot, and
    can run in conjunction with udev.
  + systemd-nspawn now places all containers in the new /machine
    top-level cgroup directory in the name=systemd hierarchy.
  + bootchart can now store its data in the journal.
  + journactl can now take multiple --unit= and --user-unit=
    switches.
  + The cryptsetup logic now understands the "luks.key=" kernel
    command line switch. If a configured key file is missing, it
    will fallback to prompting the user.
- Rebase some patches
- Update handle-SYSTEMCTL_OPTIONS-environment-variable.patch to
  properly handle SYSTEMCTL_OPTIONS

- Fix regression in the default for tmp auto-deletion
  (systemd-tmp-safe-defaults.patch, FATE#314974).

- Add chromebook lid switch as a power switch to logind rule to
  enable suspend on lid close

- Update to release 202:
  + 'systemctl list-jobs' got some polishing. '--type=' argument
    may now be passed more than once. 'systemctl list-sockets' has
    been added.
  + systemd gained a new unit 'systemd-static-nodes.service'

OBS-URL: https://build.opensuse.org/request/show/172582
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=365
2013-04-19 20:31:17 +00:00

105 lines
3.4 KiB
Diff

From: Frederic Crozat <fcrozat@suse.com>
Date: Mon, 7 Nov 2011 18:04:20 +0100
Subject: force lvm restart after cryptsetup target is reached
---
src/cryptsetup/cryptsetup-generator.c | 57 ++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index ac0ed58..9b8e229 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <stdlib.h>
#include "log.h"
#include "util.h"
@@ -64,6 +65,54 @@ static bool has_option(const char *haystack, const char *needle) {
return false;
}
+static int create_storage_after_cryptsetup (void) {
+ _cleanup_free_ char *to = NULL, *p = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
+
+ if (asprintf(&p, "%s/storage-after-cryptsetup.service", arg_dest) < 0)
+ return log_oom();
+
+ if (!(f = fopen(p, "wxe"))) {
+ log_error("Failed to create unit file: %m");
+ return -errno;
+ }
+
+ fprintf(f,
+ "[Unit]\n"
+ "Description=Restart storage after cryptsetup\n"
+ "DefaultDependencies=no\n"
+ "After=cryptsetup.target\n"
+ "Wants=cryptsetup.target\n"
+ "Before=local-fs.target\n"
+ "Before=shutdown.target\n");
+
+ fprintf(f,
+ "\n[Service]\n"
+ "RemainAfterExit=true\n"
+ "Type=oneshot\n"
+ "TimeoutSec=0\n"
+ "ExecStart=/usr/bin/systemctl restart lvm.service\n");
+
+ fflush(f);
+
+ if (ferror(f)) {
+ log_error("Failed to write file: %m");
+ return -errno;
+ }
+
+ if (asprintf(&to, "%s/local-fs.target.wants/storage-after-cryptsetup.service", arg_dest) < 0)
+ return log_oom();
+
+ mkdir_parents(to, 0755);
+
+ if (symlink("../storage-after-cryptsetup.service", to) < 0) {
+ log_error("Failed to create symlink ../storage-after-cryptsetup.service to '%s': %m", to);
+ return -errno;
+ }
+
+ return 0;
+}
+
static int create_disk(
const char *name,
const char *device,
@@ -331,6 +380,7 @@ int main(int argc, char *argv[]) {
_cleanup_fclose_ FILE *f = NULL;
unsigned n = 0;
int r = EXIT_SUCCESS;
+ bool no_crypttab = false;
char **i;
_cleanup_strv_free_ char **arg_proc_cmdline_disks_done = NULL;
_cleanup_strv_free_ char **arg_proc_cmdline_disks = NULL;
@@ -360,8 +410,10 @@ int main(int argc, char *argv[]) {
f = fopen("/etc/crypttab", "re");
if (!f) {
- if (errno == ENOENT)
+ if (errno == ENOENT) {
+ no_crypttab = true;
r = EXIT_SUCCESS;
+ }
else {
r = EXIT_FAILURE;
log_error("Failed to open /etc/crypttab: %m");
@@ -445,5 +497,8 @@ int main(int argc, char *argv[]) {
r = EXIT_FAILURE;
}
+ if ((r == EXIT_SUCCESS && !no_crypttab) && (create_storage_after_cryptsetup () < 0))
+ r = EXIT_FAILURE;
+
return r;
}