richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ecbff1
From 0d13caa0714c32af45165310e93f62c965f45b01 Mon Sep 17 00:00:00 2001
ecbff1
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ecbff1
Date: Thu, 12 Oct 2017 22:34:54 +0200
ecbff1
Subject: [PATCH] units: replace remote-cryptsetup-pre.target with
ecbff1
 remote-fs-pre.target
ecbff1
ecbff1
remote-cryptsetup-pre.target was designed as an active unit (that pulls in
ecbff1
network-online.target), the opposite of remote-fs-pre.target (a passive unit,
ecbff1
with individual provider services ordering itself before it and pulling it in,
ecbff1
for example iscsi.service and nfs-client.target).
ecbff1
ecbff1
To make remote-cryptsetup-pre.target really work, those services should be
ecbff1
ordered before it too. But this would require updates to all those services,
ecbff1
not just changes from systemd side.
ecbff1
ecbff1
But the requirements for remote-fs-pre.target and remote-cryptset-pre.target
ecbff1
are fairly similar (e.g. iscsi devices can certainly be used for both), so
ecbff1
let's reuse remote-fs-pre.target also for remote cryptsetup units. This loses
ecbff1
a bit of flexibility, but does away with the requirement for various provider
ecbff1
services to know about remote-cryptsetup-pre.target.
ecbff1
ecbff1
Cherry-picked from: a0dd209763f9e67054ee322a2dfd52bccf345c2e
ecbff1
Resolves: #1477757
ecbff1
---
ecbff1
 Makefile.am                           |  3 +--
ecbff1
 man/crypttab.xml                      |  2 +-
ecbff1
 man/systemd.special.xml               | 20 ++++----------------
ecbff1
 src/cryptsetup/cryptsetup-generator.c |  2 +-
ecbff1
 units/remote-cryptsetup-pre.target    | 15 ---------------
ecbff1
 units/remote-cryptsetup.target        |  2 +-
ecbff1
 6 files changed, 8 insertions(+), 36 deletions(-)
ecbff1
 delete mode 100644 units/remote-cryptsetup-pre.target
ecbff1
ecbff1
diff --git a/Makefile.am b/Makefile.am
ecbff1
index 13c93f485..f06bc29c2 100644
ecbff1
--- a/Makefile.am
ecbff1
+++ b/Makefile.am
ecbff1
@@ -4864,8 +4864,7 @@ systemgenerator_PROGRAMS += \
ecbff1
 dist_systemunit_DATA += \
ecbff1
 	units/cryptsetup.target \
ecbff1
 	units/cryptsetup-pre.target \
ecbff1
-	units/remote-cryptsetup.target \
ecbff1
-	units/remote-cryptsetup-pre.target
ecbff1
+	units/remote-cryptsetup.target
ecbff1
 
ecbff1
 systemd_cryptsetup_SOURCES = \
ecbff1
 	src/cryptsetup/cryptsetup.c
ecbff1
diff --git a/man/crypttab.xml b/man/crypttab.xml
ecbff1
index 7085a1623..a9197ab40 100644
ecbff1
--- a/man/crypttab.xml
ecbff1
+++ b/man/crypttab.xml
ecbff1
@@ -196,7 +196,7 @@
ecbff1
         started after the network is available, similarly to
ecbff1
         <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
ecbff1
         units marked with <option>_netdev</option>. The service unit to set up this device
ecbff1
-        will be ordered between <filename>remote-cryptsetup-pre.target</filename> and
ecbff1
+        will be ordered between <filename>remote-fs-pre.target</filename> and
ecbff1
         <filename>remote-cryptsetup.target</filename>, instead of
ecbff1
         <filename>cryptsetup-pre.target</filename> and
ecbff1
         <filename>cryptsetup.target</filename>.</para></listitem>
ecbff1
diff --git a/man/systemd.special.xml b/man/systemd.special.xml
ecbff1
index 5529d3bf7..e04f08bd3 100644
ecbff1
--- a/man/systemd.special.xml
ecbff1
+++ b/man/systemd.special.xml
ecbff1
@@ -81,7 +81,6 @@
ecbff1
     <filename>poweroff.target</filename>,
ecbff1
     <filename>printer.target</filename>,
ecbff1
     <filename>reboot.target</filename>,
ecbff1
-    <filename>remote-cryptsetup-pre.target</filename>,
ecbff1
     <filename>remote-cryptsetup.target</filename>,
ecbff1
     <filename>remote-fs.target</filename>,
ecbff1
     <filename>remote-fs-pre.target</filename>,
ecbff1
@@ -406,18 +405,6 @@
ecbff1
           this target unit, for compatibility with SysV.</para>
ecbff1
         </listitem>
ecbff1
       </varlistentry>
ecbff1
-      <varlistentry>
ecbff1
-        <term><filename>remote-cryptsetup-pre.target</filename></term>
ecbff1
-        <listitem>
ecbff1
-          <para>This target unit is automatically ordered before all cryptsetup devices
ecbff1
-          marked with the <option>_netdev</option>. It can be used to execute additional
ecbff1
-          units before such devices are set up.</para>
ecbff1
-
ecbff1
-          <para>It is ordered after <filename>network.target</filename> and
ecbff1
-          <filename>network-online.target</filename>, and also pulls the latter in as a
ecbff1
-          <varname>Wants=</varname> dependency.</para>
ecbff1
-        </listitem>
ecbff1
-      </varlistentry>
ecbff1
       <varlistentry>
ecbff1
         <term><filename>remote-cryptsetup.target</filename></term>
ecbff1
         <listitem>
ecbff1
@@ -768,9 +755,10 @@
ecbff1
         <term><filename>remote-fs-pre.target</filename></term>
ecbff1
         <listitem>
ecbff1
           <para>This target unit is automatically ordered before all
ecbff1
-          remote mount point units (see above). It can be used to run
ecbff1
-          certain units before the remote mounts are established. Note
ecbff1
-          that this unit is generally not part of the initial
ecbff1
+          mount point units (see above) and cryptsetup devices
ecbff1
+          marked with the <option>_netdev</option>. It can be used to run
ecbff1
+          certain units before remote encrypted devices and mounts are established.
ecbff1
+          Note that this unit is generally not part of the initial
ecbff1
           transaction, unless the unit that wants to be ordered before
ecbff1
           all remote mounts pulls it in via a
ecbff1
           <varname>Wants=</varname> type dependency. If the unit wants
ecbff1
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
ecbff1
index 49dc8f14b..82a280d86 100644
ecbff1
--- a/src/cryptsetup/cryptsetup-generator.c
ecbff1
+++ b/src/cryptsetup/cryptsetup-generator.c
ecbff1
@@ -114,7 +114,7 @@ static int create_disk(
ecbff1
                 "IgnoreOnIsolate=true\n"
ecbff1
                 "After=systemd-readahead-collect.service systemd-readahead-replay.service\n"
ecbff1
                 "After=%s\n",
ecbff1
-                netdev ? "remote-cryptsetup-pre.target" : "cryptsetup-pre.target");
ecbff1
+                netdev ? "remote-fs-pre.target" : "cryptsetup-pre.target");
ecbff1
 
ecbff1
         if (!nofail)
ecbff1
                 fprintf(f,
ecbff1
diff --git a/units/remote-cryptsetup-pre.target b/units/remote-cryptsetup-pre.target
ecbff1
deleted file mode 100644
ecbff1
index a375e6188..000000000
ecbff1
--- a/units/remote-cryptsetup-pre.target
ecbff1
+++ /dev/null
ecbff1
@@ -1,15 +0,0 @@
ecbff1
-#  This file is part of systemd.
ecbff1
-#
ecbff1
-#  systemd is free software; you can redistribute it and/or modify it
ecbff1
-#  under the terms of the GNU Lesser General Public License as published by
ecbff1
-#  the Free Software Foundation; either version 2.1 of the License, or
ecbff1
-#  (at your option) any later version.
ecbff1
-
ecbff1
-[Unit]
ecbff1
-Description=Remote Encrypted Volumes (Pre)
ecbff1
-Documentation=man:systemd.special(7)
ecbff1
-RefuseManualStart=yes
ecbff1
-Before=remote-cryptsetup.target
ecbff1
-
ecbff1
-After=network.target network-online.target
ecbff1
-Wants=network-online.target
ecbff1
diff --git a/units/remote-cryptsetup.target b/units/remote-cryptsetup.target
ecbff1
index c306d521f..d485b0672 100644
ecbff1
--- a/units/remote-cryptsetup.target
ecbff1
+++ b/units/remote-cryptsetup.target
ecbff1
@@ -8,7 +8,7 @@
ecbff1
 [Unit]
ecbff1
 Description=Remote Encrypted Volumes
ecbff1
 Documentation=man:systemd.special(7)
ecbff1
-After=remote-cryptsetup-pre.target
ecbff1
+After=remote-fs-pre.target
ecbff1
 DefaultDependencies=no
ecbff1
 Conflicts=shutdown.target
ecbff1