SHA256
1
0
forked from pool/systemd
systemd/force-lvm-restart-after-cryptsetup-target-is-reached.patch

105 lines
3.3 KiB
Diff
Raw Normal View History

From: Frederic Crozat <fcrozat@suse.com>
Date: Mon, 7 Nov 2011 18:04:20 +0100
Subject: force lvm restart after cryptsetup target is reached
---
2013-04-19 22:31:17 +02:00
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
Accepting request 176957 from home:fcrozat:branches:Base:System - Update to release 204: + systemd-nspawn creates etc/resolv.conf in container if needed. + systemd-nspawn will store metadata about container in container cgroup including its root directory. + cgroup hierarchy has been reworked, all objects are now suffxed (with .session for user sessions, .user for users, .nspawn for containers). All cgroup names are now escaped to preven collision of object names. + systemctl list-dependencies gained --plain, --reverse, --after and --before switches. + systemd-inhibit shows processes name taking inhibitor lock. + nss-myhostname will now resolve "localhost" implicitly. + .include is not allowed recursively anymore and only in unit files. Drop-in files should be favored in most cases. + systemd-analyze gained "critical-chain" command, to get slowest chain of units run during boot-up. + systemd-nspawn@.service has been added to easily run nspawn container for system services. Just start "systemd-nspawn@foobar.service" and container from /var/lib/container/foobar" will be booted. + systemd-cgls has new --machine parameter to list processes from one container. + ConditionSecurity= can now check for apparmor and SMACK. + /etc/systemd/sleep.conf has been introduced to configure which kernel operation will be execute when "suspend", "hibernate" or "hybrid-sleep" is requrested. It allow new kernel "freeze" state to be used too. (This setting won't have any effect if pm-utils is installed). + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape passed argument if applicable. OBS-URL: https://build.opensuse.org/request/show/176957 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 17:26:40 +02:00
index 81b7708..1940985 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"
2013-04-19 22:31:17 +02:00
@@ -64,6 +65,54 @@ static bool has_option(const char *haystack, const char *needle) {
return false;
}
+static int create_storage_after_cryptsetup (void) {
2013-04-19 22:31:17 +02:00
+ _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,
Accepting request 176957 from home:fcrozat:branches:Base:System - Update to release 204: + systemd-nspawn creates etc/resolv.conf in container if needed. + systemd-nspawn will store metadata about container in container cgroup including its root directory. + cgroup hierarchy has been reworked, all objects are now suffxed (with .session for user sessions, .user for users, .nspawn for containers). All cgroup names are now escaped to preven collision of object names. + systemctl list-dependencies gained --plain, --reverse, --after and --before switches. + systemd-inhibit shows processes name taking inhibitor lock. + nss-myhostname will now resolve "localhost" implicitly. + .include is not allowed recursively anymore and only in unit files. Drop-in files should be favored in most cases. + systemd-analyze gained "critical-chain" command, to get slowest chain of units run during boot-up. + systemd-nspawn@.service has been added to easily run nspawn container for system services. Just start "systemd-nspawn@foobar.service" and container from /var/lib/container/foobar" will be booted. + systemd-cgls has new --machine parameter to list processes from one container. + ConditionSecurity= can now check for apparmor and SMACK. + /etc/systemd/sleep.conf has been introduced to configure which kernel operation will be execute when "suspend", "hibernate" or "hybrid-sleep" is requrested. It allow new kernel "freeze" state to be used too. (This setting won't have any effect if pm-utils is installed). + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape passed argument if applicable. OBS-URL: https://build.opensuse.org/request/show/176957 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 17:26:40 +02:00
@@ -334,6 +383,7 @@ int main(int argc, char *argv[]) {
2013-04-19 22:31:17 +02:00
_cleanup_fclose_ FILE *f = NULL;
unsigned n = 0;
int r = EXIT_SUCCESS;
+ bool no_crypttab = false;
char **i;
Accepting request 176957 from home:fcrozat:branches:Base:System - Update to release 204: + systemd-nspawn creates etc/resolv.conf in container if needed. + systemd-nspawn will store metadata about container in container cgroup including its root directory. + cgroup hierarchy has been reworked, all objects are now suffxed (with .session for user sessions, .user for users, .nspawn for containers). All cgroup names are now escaped to preven collision of object names. + systemctl list-dependencies gained --plain, --reverse, --after and --before switches. + systemd-inhibit shows processes name taking inhibitor lock. + nss-myhostname will now resolve "localhost" implicitly. + .include is not allowed recursively anymore and only in unit files. Drop-in files should be favored in most cases. + systemd-analyze gained "critical-chain" command, to get slowest chain of units run during boot-up. + systemd-nspawn@.service has been added to easily run nspawn container for system services. Just start "systemd-nspawn@foobar.service" and container from /var/lib/container/foobar" will be booted. + systemd-cgls has new --machine parameter to list processes from one container. + ConditionSecurity= can now check for apparmor and SMACK. + /etc/systemd/sleep.conf has been introduced to configure which kernel operation will be execute when "suspend", "hibernate" or "hybrid-sleep" is requrested. It allow new kernel "freeze" state to be used too. (This setting won't have any effect if pm-utils is installed). + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape passed argument if applicable. OBS-URL: https://build.opensuse.org/request/show/176957 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 17:26:40 +02:00
if (argc > 1 && argc != 4) {
@@ -361,8 +411,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");
Accepting request 176957 from home:fcrozat:branches:Base:System - Update to release 204: + systemd-nspawn creates etc/resolv.conf in container if needed. + systemd-nspawn will store metadata about container in container cgroup including its root directory. + cgroup hierarchy has been reworked, all objects are now suffxed (with .session for user sessions, .user for users, .nspawn for containers). All cgroup names are now escaped to preven collision of object names. + systemctl list-dependencies gained --plain, --reverse, --after and --before switches. + systemd-inhibit shows processes name taking inhibitor lock. + nss-myhostname will now resolve "localhost" implicitly. + .include is not allowed recursively anymore and only in unit files. Drop-in files should be favored in most cases. + systemd-analyze gained "critical-chain" command, to get slowest chain of units run during boot-up. + systemd-nspawn@.service has been added to easily run nspawn container for system services. Just start "systemd-nspawn@foobar.service" and container from /var/lib/container/foobar" will be booted. + systemd-cgls has new --machine parameter to list processes from one container. + ConditionSecurity= can now check for apparmor and SMACK. + /etc/systemd/sleep.conf has been introduced to configure which kernel operation will be execute when "suspend", "hibernate" or "hybrid-sleep" is requrested. It allow new kernel "freeze" state to be used too. (This setting won't have any effect if pm-utils is installed). + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape passed argument if applicable. OBS-URL: https://build.opensuse.org/request/show/176957 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 17:26:40 +02:00
@@ -464,5 +516,8 @@ next:
r = EXIT_FAILURE;
}
+ if ((r == EXIT_SUCCESS && !no_crypttab) && (create_storage_after_cryptsetup () < 0))
+ r = EXIT_FAILURE;
+
return r;
}