summaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-02-08 21:50:42 +0100
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-04-09 19:55:05 +0200
commitb90597b98d46767207a0e92a84fb39c344472b69 (patch)
tree9278f56f2a91341f67cf203c826f729364b04d44 /gnu/tests
parent338f665b97afdb0928002aa538c21be56d1585a3 (diff)
guix: Ask LUKS password only once on boot when using GRUB.
* gnu/bootloader/grub.scm (make-grub-configuration): Modify. * gnu/system/mapped-devices.scm (open-luks-device): Modify. * gnu/tests/install.scm (%encrypted-root-installation-script): Modify. (%encrypted-root-os): Make debugging possible. * doc/guix.texi (Mapped Devices): Cross-reference automatic LUKS master key passing. (BootloaderConfiguration): Document automatic LUKS master key passing via GRUB's (proc)/luks_script. Update extra-initrd documentation. Change-Id: I5be74a524de04232d156e750109707fe7e50c28a
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/install.scm33
1 files changed, 7 insertions, 26 deletions
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index 0bcf1458986..fd583e15a19 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -729,8 +729,10 @@ by 'mdadm'.")
729 (bootloader grub-bootloader) 729 (bootloader grub-bootloader)
730 (targets '("/dev/vdb")))) 730 (targets '("/dev/vdb"))))
731 731
732 ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt 732 ;; Pass "console=ttyS0" so initrd messages (including luks-master-key
733 ;; detection logic in 'enter-luks-passphrase'. 733 ;; diagnostics) are visible on serial. The GRUB passphrase prompt
734 ;; appears on VGA regardless and is detected via OCR.
735 (kernel-arguments '("console=ttyS0"))
734 736
735 (mapped-devices (list (mapped-device 737 (mapped-devices (list (mapped-device
736 (source (uuid "12345678-1234-1234-1234-123456789abc")) 738 (source (uuid "12345678-1234-1234-1234-123456789abc"))
@@ -786,17 +788,13 @@ reboot\n"))
786 788
787(define (enter-luks-passphrase marionette) 789(define (enter-luks-passphrase marionette)
788 "Return a gexp to be inserted in the basic system test running on MARIONETTE 790 "Return a gexp to be inserted in the basic system test running on MARIONETTE
789to enter the LUKS passphrase." 791to enter the LUKS passphrase. Only the GRUB passphrase prompt is expected;
792the initrd reuses the master key passed by GRUB via (proc)/luks_script."
790 (let ((ocrad (file-append ocrad "/bin/ocrad"))) 793 (let ((ocrad (file-append ocrad "/bin/ocrad")))
791 #~(begin 794 #~(begin
792 (define (passphrase-prompt? text) 795 (define (passphrase-prompt? text)
793 (string-contains (pk 'screen-text text) "Enter pass")) 796 (string-contains (pk 'screen-text text) "Enter pass"))
794 797
795 (define (bios-boot-screen? text)
796 ;; Return true if TEXT corresponds to the boot screen, before GRUB's
797 ;; menu.
798 (string-prefix? "SeaBIOS" text))
799
800 (test-assert "enter LUKS passphrase for GRUB" 798 (test-assert "enter LUKS passphrase for GRUB"
801 (begin 799 (begin
802 ;; At this point we have no choice but to use OCR to determine 800 ;; At this point we have no choice but to use OCR to determine
@@ -806,26 +804,9 @@ to enter the LUKS passphrase."
806 (marionette-type #$(string-append %luks-passphrase "\n") 804 (marionette-type #$(string-append %luks-passphrase "\n")
807 #$marionette) 805 #$marionette)
808 806
809 ;; Now wait until we leave the boot screen. This is necessary so
810 ;; we can then be sure we match the "Enter passphrase" prompt from
811 ;; 'cryptsetup', in the initrd.
812 (wait-for-screen-text #$marionette (negate bios-boot-screen?)
813 #:ocr #$ocrad
814 #:timeout 20)))
815
816 (test-assert "enter LUKS passphrase for the initrd"
817 (begin
818 ;; XXX: Here we use OCR as well but we could instead use QEMU
819 ;; '-serial stdio' and run it in an input pipe,
820 (wait-for-screen-text #$marionette passphrase-prompt?
821 #:ocr #$ocrad
822 #:timeout 60)
823 (marionette-type #$(string-append %luks-passphrase "\n")
824 #$marionette)
825
826 ;; Take a screenshot for debugging purposes. 807 ;; Take a screenshot for debugging purposes.
827 (marionette-control (string-append "screendump " #$output 808 (marionette-control (string-append "screendump " #$output
828 "/post-initrd-passphrase.ppm") 809 "/post-grub-passphrase.ppm")
829 #$marionette)))))) 810 #$marionette))))))
830 811
831(define %test-encrypted-root-os 812(define %test-encrypted-root-os