]> git.ipfire.org Git - thirdparty/systemd.git/commit
cryptsetup: generate the unit to umount keydev filesystem
authorMichal Sekletár <msekleta@redhat.com>
Wed, 9 Sep 2020 12:00:42 +0000 (14:00 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Sep 2020 17:20:28 +0000 (19:20 +0200)
commit882f5f429ee14c7c39196f1b40bbbe133eaf9b2f
tree57ac53f54b3304e037ae8a12a37cb7b9c954e529
parent5501da15ba34284e50c10ccd6b3ffa8838bb431b
cryptsetup: generate the unit to umount keydev filesystem

Previously we would call umount from ExecStartPost= of
systemd-cryptsetup instance in order to get rid of the keydev
mount (i.e. filesystem containing keyfile). Let's generate unit to
handle umount. Making this symmetrical (both mount and umount of keydev
are handled by units) fixes the problem with lingering keydev mounts.

Motivation for the change is the issue where keydev mount would stay
around even if device was successfully unlocked and mount is no longer
needed. That could happen previously because when generator options are
not prefixed with "rd." we run generators twice (e.g. rd.luks.key=...).

In such case disk is unlocked in initramfs phase of boot (assuming the
initrd image contains the generator and is able to handle unlocking of
LUKS devices). After switchroot we however enqueue start job for
systemd-cryptsetup instance (because units are regenerated second time)
and that pulls in its dependencies into transaction. Later the main
systemd-cryptsetup unit not actually started since it is already active
and has RemainaAfterExit=yes. Nevertheless, dependencies get activated
and keydev mount is attached again. Because previously we called umount
from ExecStartPost= of systemd-cryptsetup instance the umount is not
called second time and keydev filesystem stays lingering.
src/cryptsetup/cryptsetup-generator.c