Merge pull request #17467 from keszybz/unconditionally-pull-in-cryptsetup-remote

Unconditionally pull in cryptsetup-remote.target in the initramfs
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-10-28 18:00:04 +01:00 committed by GitHub
commit 32c3a623ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 49 deletions

View File

@ -41,7 +41,6 @@
<filename>hybrid-sleep.target</filename>, <filename>hybrid-sleep.target</filename>,
<filename>suspend-then-hibernate.target</filename>, <filename>suspend-then-hibernate.target</filename>,
<filename>initrd.target</filename>, <filename>initrd.target</filename>,
<filename>initrd-cryptsetup.target</filename>,
<filename>initrd-fs.target</filename>, <filename>initrd-fs.target</filename>,
<filename>initrd-root-device.target</filename>, <filename>initrd-root-device.target</filename>,
<filename>initrd-root-fs.target</filename>, <filename>initrd-root-fs.target</filename>,
@ -183,10 +182,8 @@
<varlistentry> <varlistentry>
<term><filename>cryptsetup.target</filename></term> <term><filename>cryptsetup.target</filename></term>
<listitem> <listitem>
<para>A target that pulls in setup services for local encrypted block devices. <para>A target that pulls in setup services for all
See <filename>remote-cryptsetup.target</filename> below for the equivalent target for remote encrypted block devices.</para>
volumes, and <filename>initrd-cryptsetup.target</filename> below for the equivalent target in the
initrd.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -355,20 +352,12 @@
<varlistentry> <varlistentry>
<term><filename>initrd.target</filename></term> <term><filename>initrd.target</filename></term>
<listitem> <listitem>
<para>This is the default target in the initrd, similar to <filename>default.target</filename> <para>This is the default target in the initramfs, similar to <filename>default.target</filename>
in the main system. It is used to mount the real root and transition to it. See in the main system. It is used to mount the real root and transition to it. See
<citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry> for <citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
more discussion.</para> more discussion.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><filename>initrd-cryptsetup.target</filename></term>
<listitem>
<para>A target that pulls in setup services for all encrypted block devices. See
<filename>cryptsetup.target</filename> and <filename>remote-cryptsetup.target</filename> for the
equivalent targets in the real root.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><filename>initrd-fs.target</filename></term> <term><filename>initrd-fs.target</filename></term>
<listitem> <listitem>
@ -560,9 +549,7 @@
<para>Similar to <filename>cryptsetup.target</filename>, but for encrypted <para>Similar to <filename>cryptsetup.target</filename>, but for encrypted
devices which are accessed over the network. It is used for devices which are accessed over the network. It is used for
<citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>8</manvolnum></citerefentry> <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>8</manvolnum></citerefentry>
entries marked with <option>_netdev</option>. entries marked with <option>_netdev</option>.</para>
See <filename>cryptsetup.target</filename> for the equivalent target for local volumes, and
<filename>initrd-cryptsetup.target</filename> for the equivalent target in the initrd.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -455,16 +455,10 @@ static int create_disk(
} }
} }
const char *target;
if (in_initrd())
target = "initrd-cryptsetup.target";
else if (netdev)
target = "remote-cryptsetup.target";
else
target = "cryptsetup.target";
if (!nofail) if (!nofail)
fprintf(f, "Before=%s\n", target); fprintf(f,
"Before=%s\n",
netdev ? "remote-cryptsetup.target" : "cryptsetup.target");
if (password && !keydev) { if (password && !keydev) {
r = print_dependencies(f, password); r = print_dependencies(f, password);
@ -527,7 +521,8 @@ static int create_disk(
return log_error_errno(r, "Failed to write unit file %s: %m", n); return log_error_errno(r, "Failed to write unit file %s: %m", n);
if (!noauto) { if (!noauto) {
r = generator_add_symlink(arg_dest, target, r = generator_add_symlink(arg_dest,
netdev ? "remote-cryptsetup.target" : "cryptsetup.target",
nofail ? "wants" : "requires", n); nofail ? "wants" : "requires", n);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -1,17 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Initrd Encrypted Volumes
Documentation=man:systemd.special(7)
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly
AssertPathExists=/etc/initrd-release
DefaultDependencies=no
Conflicts=shutdown.target

View File

@ -22,14 +22,12 @@ units = [
'multi-user.target.wants/'], 'multi-user.target.wants/'],
['getty-pre.target', ''], ['getty-pre.target', ''],
['graphical.target', '', ['graphical.target', '',
(with_runlevels ? 'runlevel5.target default.target' : 'default.target')], 'default.target' + (with_runlevels ? ' runlevel5.target' : '')],
['halt.target', ''], ['halt.target', ''],
['hibernate.target', 'ENABLE_HIBERNATE'], ['hibernate.target', 'ENABLE_HIBERNATE'],
['hybrid-sleep.target', 'ENABLE_HIBERNATE'], ['hybrid-sleep.target', 'ENABLE_HIBERNATE'],
['suspend-then-hibernate.target', 'ENABLE_HIBERNATE'], ['suspend-then-hibernate.target', 'ENABLE_HIBERNATE'],
['initrd-cleanup.service', 'ENABLE_INITRD'], ['initrd-cleanup.service', 'ENABLE_INITRD'],
['initrd-cryptsetup.target', 'HAVE_LIBCRYPTSETUP ENABLE_INITRD',
'sysinit.target.wants/'],
['initrd-fs.target', 'ENABLE_INITRD'], ['initrd-fs.target', 'ENABLE_INITRD'],
['initrd-parse-etc.service', 'ENABLE_INITRD'], ['initrd-parse-etc.service', 'ENABLE_INITRD'],
['initrd-root-device.target', 'ENABLE_INITRD'], ['initrd-root-device.target', 'ENABLE_INITRD'],
@ -61,8 +59,9 @@ units = [
'sysinit.target.wants/'], 'sysinit.target.wants/'],
['proc-sys-fs-binfmt_misc.mount', 'ENABLE_BINFMT'], ['proc-sys-fs-binfmt_misc.mount', 'ENABLE_BINFMT'],
['reboot.target', '', ['reboot.target', '',
(with_runlevels ? 'runlevel6.target ctrl-alt-del.target' : 'ctrl-alt-del.target')], 'ctrl-alt-del.target' + (with_runlevels ? ' runlevel6.target' : '')],
['remote-cryptsetup.target', 'HAVE_LIBCRYPTSETUP'], ['remote-cryptsetup.target', 'HAVE_LIBCRYPTSETUP',
'initrd-root-device.target.wants/'],
['remote-fs-pre.target', ''], ['remote-fs-pre.target', ''],
['remote-fs.target', ''], ['remote-fs.target', ''],
['rescue.target', '', ['rescue.target', '',