diff options
author | Ondrej Kozina <okozina@redhat.com> | 2020-08-24 12:54:14 +0200 |
---|---|---|
committer | Ondrej Kozina <okozina@redhat.com> | 2020-09-25 17:01:36 +0200 |
commit | 13445d9775614367d521204d677c5775b5e53bea (patch) | |
tree | 1d457f553462b8efb8dbef633231c81512e2cfa9 | |
parent | a8574d00552dc9f3012a3f84ab2bcac5fb6d7e7b (diff) | |
download | systemd-13445d9775614367d521204d677c5775b5e53bea.tar.gz |
cryptsetup-generator: Add support for header device in crypttab
-rw-r--r-- | man/crypttab.xml | 7 | ||||
-rw-r--r-- | src/cryptsetup/cryptsetup-generator.c | 18 |
2 files changed, 22 insertions, 3 deletions
diff --git a/man/crypttab.xml b/man/crypttab.xml index ee54499bfe..2c0a8266a5 100644 --- a/man/crypttab.xml +++ b/man/crypttab.xml @@ -112,7 +112,12 @@ relevant for LUKS devices. See <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> for possible values and the default value of this - option.</para></listitem> + option.</para> + + <para>Optionally, the path may be followed by <literal>:</literal> and an fstab device specification + (e.g. starting with <literal>UUID=</literal> or similar); in which case, the path is relative to the + device file system root. The device gets mounted automatically for LUKS device activation duration only. + </para></listitem> </varlistentry> <varlistentry> diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index ea9965d6c4..cd40cb4208 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -789,7 +789,8 @@ static int add_crypttab_devices(void) { } for (;;) { - _cleanup_free_ char *line = NULL, *name = NULL, *device = NULL, *keyspec = NULL, *options = NULL, *keyfile = NULL, *keydev = NULL; + _cleanup_free_ char *line = NULL, *name = NULL, *device = NULL, *keyspec = NULL, *options = NULL, + *keyfile = NULL, *keydev = NULL, *headerdev = NULL, *filtered_header = NULL; crypto_device *d = NULL; char *l, *uuid; int k; @@ -829,7 +830,20 @@ static int add_crypttab_devices(void) { if (r < 0) return r; - r = create_disk(name, device, keyfile, keydev, d ? d->headerdev : NULL, (d && d->options) ? d->options : options, arg_crypttab); + if (options && (!d || !d->options)) { + r = filter_header_device(options, &headerdev, &filtered_header); + if (r < 0) + return r; + free_and_replace(options, filtered_header); + } + + r = create_disk(name, + device, + keyfile, + keydev, + (d && d->options) ? d->headerdev : headerdev, + (d && d->options) ? d->options : options, + arg_crypttab); if (r < 0) return r; |