Skip to contentSkip to conversation

tests/util/grub-shell-luks-tester: Fix detached header test getting wrong header path

PATCH In review Glenn Washburn 2 participants 2 messages Jun 9, 2024 – Jun 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/util/grub-shell-luks-tester: Fix detached header test getting wrong header path

When $detached_header was set 1, $luksdiskfile was set to the luks header file path with "${detached_header:-$luksfile}" appended, which evaluates to "1". Fix this by using two statements to set $luksdiskfile. The first sets it to the header file if $detached_header is set, otherwise leave it unset. The second statement sets it to itself if it is already set, otherwise it is set to $luksfile.

Fixes a7b540e6e (tests: Add cryptomount functional test)
---
 tests/util/grub-shell-luks-tester.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/util/grub-shell-luks-tester.in +3 -1
index 8926cbc96efa..b2a8a91b41f2 100644
@@ -162,6 +162,8 @@ get_random_bytes() {
 lukstestdir="`mktemp -d "${TMPDIR:-/tmp}/$(basename "$0").XXXXXXXXXX"`" || exit 20
 luksfile=$lukstestdir/luks.disk
 lukshdrfile=$lukstestdir/luks.header
+luksdiskfile=${detached_header:+$lukshdrfile}
+luksdiskfile=${luksdiskfile:-$luksfile}
 lukskeyfile=$lukstestdir/luks.key
 vfile=$lukstestdir/mnt/test.verify
 vtext="TEST VERIFIED"
@@ -193,7 +195,7 @@ truncate -s $disksize $luksfile || exit 21
 cryptsetup luksFormat -q $csopts $luksfile $lukskeyfile || exit 22
 
 # Run any cryptsetup scripts
-export luksdiskfile=${detached_header:+$lukshdrfile}${detached_header:-$luksfile}
+export luksdiskfile
 export lukskeyfile
 for csscript in $csscripts; do
     [ -f "$csscript" ] && . $csscript
Signature · 7 lines
2.34.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Glenn Washburn

When $detached_header was set 1, $luksdiskfile was set to the luks header file path with "${detached_header:-$luksfile}" appended, which evaluates to "1". Fix this by using two statements to set $luksdiskfile. The first sets it to the header file if $detached_header is set, otherwise leave it unset. The second statement sets it to itself if it is already set, otherwise it is set to $luksfile.

Fixes a7b540e6e (tests: Add cryptomount functional test)

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel