Skip to content

Commit 9542239

Browse files
committed
cryptsetup: introduce new cryptsetup-pre.traget unit so that services can make sure they are started before and stopped after any LUKS setup
https://bugzilla.redhat.com/show_bug.cgi?id=1097938
1 parent 6f04529 commit 9542239

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3933,7 +3933,8 @@ systemgenerator_PROGRAMS += \
39333933
systemd-cryptsetup-generator
39343934

39353935
dist_systemunit_DATA += \
3936-
units/cryptsetup.target
3936+
units/cryptsetup.target \
3937+
units/cryptsetup-pre.target
39373938

39383939
systemd_cryptsetup_SOURCES = \
39393940
src/cryptsetup/cryptsetup.c

man/systemd.special.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<filename>bluetooth.target</filename>,
5353
<filename>ctrl-alt-del.target</filename>,
5454
<filename>cryptsetup.target</filename>,
55+
<filename>cryptsetup-pre.target</filename>,
5556
<filename>dbus.service</filename>,
5657
<filename>dbus.socket</filename>,
5758
<filename>default.target</filename>,
@@ -840,6 +841,27 @@
840841
transaction.</para>
841842

842843
<variablelist>
844+
<varlistentry>
845+
<term><filename>cryptsetup-pre.target</filename></term>
846+
<listitem>
847+
<para>This passive target unit
848+
may be pulled in by services
849+
that want to run before any
850+
encrypted block device is set
851+
up. All encrypted block
852+
devices are set up after this
853+
target has been reached. Since
854+
the shutdown order is
855+
implicitly the reverse
856+
start-up order between units
857+
this target is particularly
858+
useful to ensure that a
859+
service is shut down only
860+
after all encrypted block
861+
devices are fully
862+
stopped.</para>
863+
</listitem>
864+
</varlistentry>
843865
<varlistentry>
844866
<term><filename>local-fs-pre.target</filename></term>
845867
<listitem>

src/cryptsetup/cryptsetup-generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int create_disk(
127127
"Conflicts=umount.target\n"
128128
"BindsTo=dev-mapper-%i.device\n"
129129
"IgnoreOnIsolate=true\n"
130-
"After=systemd-readahead-collect.service systemd-readahead-replay.service\n",
130+
"After=systemd-readahead-collect.service systemd-readahead-replay.service cryptsetup-pre.target\n",
131131
f);
132132

133133
if (!nofail)

units/cryptsetup-pre.target

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is part of systemd.
2+
#
3+
# systemd is free software; you can redistribute it and/or modify it
4+
# under the terms of the GNU Lesser General Public License as published by
5+
# the Free Software Foundation; either version 2.1 of the License, or
6+
# (at your option) any later version.
7+
8+
[Unit]
9+
Description=Encrypted Volumes (Pre)
10+
Documentation=man:systemd.special(7)
11+
RefuseManualStart=yes

0 commit comments

Comments
 (0)