Frederic Crozat
dd5f3ba981
- Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
133 lines
3.9 KiB
Diff
133 lines
3.9 KiB
Diff
From b9841589cf16950af7d123ecd128b84464d15a1d Mon Sep 17 00:00:00 2001
|
|
From: Frederic Crozat <fcrozat@suse.com>
|
|
Date: Mon, 7 Nov 2011 18:04:20 +0100
|
|
Subject: [PATCH] force lvm restart after cryptsetup target is reached
|
|
|
|
---
|
|
src/cryptsetup-generator.c | 80 ++++++++++++++++++++++++++++++++++++++++++++
|
|
1 files changed, 80 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/src/cryptsetup-generator.c b/src/cryptsetup-generator.c
|
|
index a48b7a4..14fcce8 100644
|
|
--- a/src/cryptsetup-generator.c
|
|
+++ b/src/cryptsetup-generator.c
|
|
@@ -22,12 +22,14 @@
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
+#include <stdlib.h>
|
|
|
|
#include "log.h"
|
|
#include "util.h"
|
|
#include "unit-name.h"
|
|
|
|
const char *arg_dest = "/tmp";
|
|
+bool random_seed = false;
|
|
|
|
static bool has_option(const char *haystack, const char *needle) {
|
|
const char *f = haystack;
|
|
@@ -58,6 +60,78 @@ static bool has_option(const char *haystack, const char *needle) {
|
|
return false;
|
|
}
|
|
|
|
+static int create_storage_after_cryptsetup (void) {
|
|
+ int r;
|
|
+ char *to = NULL, *p = NULL;
|
|
+ FILE *f = NULL;
|
|
+
|
|
+ if (asprintf(&p, "%s/storage-after-cryptsetup.service", arg_dest) < 0) {
|
|
+ r = -ENOMEM;
|
|
+ log_error("Failed to allocate unit file name.");
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ if (!(f = fopen(p, "wxe"))) {
|
|
+ r = -errno;
|
|
+ log_error("Failed to create unit file: %m");
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ fprintf(f,
|
|
+ "[Unit]\n"
|
|
+ "Description=Restart storage after cryptsetup\n"
|
|
+ "DefaultDependencies=no\n"
|
|
+ "After=cryptsetup.target\n"
|
|
+ "Wants=cryptsetup.target\n"
|
|
+ "Before=shutdown.target\n");
|
|
+ if (!random_seed) {
|
|
+ fprintf(f, "After=local-fs.target\n");
|
|
+ }
|
|
+
|
|
+ fprintf(f,
|
|
+ "\n[Service]\n"
|
|
+ "RemainAfterExit=true\n"
|
|
+ "Type=oneshot\n"
|
|
+ "TimeoutSec=0\n"
|
|
+ "ExecStart=/bin/systemctl restart lvm.service\n");
|
|
+
|
|
+ fflush(f);
|
|
+
|
|
+ if (ferror(f)) {
|
|
+ r = -errno;
|
|
+ log_error("Failed to write file: %m");
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ if (asprintf(&to, "%s/local-fs.target.wants/storage-after-cryptsetup.service", arg_dest) < 0) {
|
|
+ r = -ENOMEM;
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ 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);
|
|
+ r = -errno;
|
|
+ goto fail;
|
|
+ }
|
|
+
|
|
+ free(to);
|
|
+ to = NULL;
|
|
+
|
|
+ r = 0;
|
|
+ system ("TMPDIR=/run /usr/bin/sed -e 's/\\(After=.*\\) local-fs.target\\(.*\\)/\\1\\2/g' /lib/systemd/system/systemd-random-seed-load.service > /etc/systemd/system/systemd-random-seed-load.service ");
|
|
+fail:
|
|
+
|
|
+ free(p);
|
|
+ free(to);
|
|
+
|
|
+ if (f)
|
|
+ fclose(f);
|
|
+
|
|
+ return r;
|
|
+}
|
|
+
|
|
static int create_disk(
|
|
const char *name,
|
|
const char *device,
|
|
@@ -122,8 +196,11 @@ static int create_disk(
|
|
if (password && (streq(password, "/dev/urandom") ||
|
|
streq(password, "/dev/random") ||
|
|
streq(password, "/dev/hw_random")))
|
|
+ {
|
|
fprintf(f,
|
|
"After=systemd-random-seed-load.service\n");
|
|
+ random_seed = true;
|
|
+ }
|
|
else
|
|
fprintf(f,
|
|
"Before=local-fs.target\n");
|
|
@@ -293,6 +370,9 @@ int main(int argc, char *argv[]) {
|
|
free(options);
|
|
}
|
|
|
|
+ if (create_storage_after_cryptsetup () < 0)
|
|
+ r = EXIT_FAILURE;
|
|
+
|
|
finish:
|
|
return r;
|
|
}
|
|
--
|
|
1.7.7
|
|
|