valeriyvdovin / rpms / systemd

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