]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup-generator: Add support for header device in crypttab 16444/head
authorOndrej Kozina <okozina@redhat.com>
Mon, 24 Aug 2020 10:54:14 +0000 (12:54 +0200)
committerOndrej Kozina <okozina@redhat.com>
Fri, 25 Sep 2020 15:01:36 +0000 (17:01 +0200)
man/crypttab.xml
src/cryptsetup/cryptsetup-generator.c

index ee54499bfe7a13c86869b3c7c4e355a0e7d511a5..2c0a8266a5988737f1f1e8fc7f86d1c930a430d9 100644 (file)
         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>
index ea9965d6c444cadbf480ce2b814c20cf4cb4dd4d..cd40cb4208471414415b71cc150c458d50f6c6d6 100644 (file)
@@ -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;