diff mbox series

[bug#72457,07/15] gnu: system: Fix bootloader crypto device recognition.

Message ID 5e2268ba496538cd8cb619f4e1e03f94ae17f980.1722741997.git.lilah@lunabee.space
State New
Headers show
Series Rewrite bootloader subsystem. | expand

Commit Message

Lilah Tascheter Aug. 4, 2024, 3:55 a.m. UTC
* gnu/system.scm (operating-system-bootloader-crypto-devices): Check for
  luks-device-mapping-with-options in addition to luks-device-mapping.

Change-Id: Iafc9afe608640b97083c4d559c9240846330472a
---
 gnu/system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Tomas Volf Aug. 4, 2024, 9:22 a.m. UTC | #1
On 2024-08-03 22:55:27 -0500, Lilah Tascheter wrote:
> * gnu/system.scm (operating-system-bootloader-crypto-devices): Check for
>   luks-device-mapping-with-options in addition to luks-device-mapping.
>
> Change-Id: Iafc9afe608640b97083c4d559c9240846330472a
> ---
>  gnu/system.scm | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/gnu/system.scm b/gnu/system.scm
> index 66c1a80733..8926e1b065 100644
> --- a/gnu/system.scm
> +++ b/gnu/system.scm
> @@ -400,10 +400,11 @@ (define operating-system-bootloader-crypto-devices
>    (mlambdaq (os)                        ;to avoid duplicated output
>      "Return the sources of the LUKS mapped devices specified by UUID."
>      ;; XXX: Device ordering is important, we trust the returned one.
> -    (let* ((luks-devices (filter (lambda (m)
> -                                   (eq? luks-device-mapping
> -                                        (mapped-device-type m)))
> -                                 (operating-system-boot-mapped-devices os)))
> +    (let* ((luks? (lambda (m) (let ((t (mapped-device-type m)))
> +                                (or (eq? luks-device-mapping t)
> +                                    (eq? luks-device-mapping-with-options t)))))

I think this will not work as expected.  luks-device-mapping-with-options is a
procedure to be called, not an object you can eq? against.

Typical use case:

          (mapped-device
           (source "/dev/sdb1)
           (target "data)
           (type (luks-device-mapping-with-options
                  #:key-file "/crypto.key")))

> +           (luks-devices (filter luks?
> +                           (operating-system-boot-mapped-devices os)))
>             (uuid-crypto-devices non-uuid-crypto-devices
>                                  (partition (compose uuid? mapped-device-source)
>                                             luks-devices)))
> --
> 2.45.2
>
>

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
diff mbox series

Patch

diff --git a/gnu/system.scm b/gnu/system.scm
index 66c1a80733..8926e1b065 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -400,10 +400,11 @@  (define operating-system-bootloader-crypto-devices
   (mlambdaq (os)                        ;to avoid duplicated output
     "Return the sources of the LUKS mapped devices specified by UUID."
     ;; XXX: Device ordering is important, we trust the returned one.
-    (let* ((luks-devices (filter (lambda (m)
-                                   (eq? luks-device-mapping
-                                        (mapped-device-type m)))
-                                 (operating-system-boot-mapped-devices os)))
+    (let* ((luks? (lambda (m) (let ((t (mapped-device-type m)))
+                                (or (eq? luks-device-mapping t)
+                                    (eq? luks-device-mapping-with-options t)))))
+           (luks-devices (filter luks?
+                           (operating-system-boot-mapped-devices os)))
            (uuid-crypto-devices non-uuid-crypto-devices
                                 (partition (compose uuid? mapped-device-source)
                                            luks-devices)))