nixosTests.pam-zfs-key: fix dataset mounting

The test created ZFS datasets with canmount=noauto, but pam_zfs_key's
mount_dataset() now checks canmount == ZFS_CANMOUNT_ON and skips
mounting otherwise (added in
https://github.com/openzfs/zfs/commit/387ed5ca41). Use the default
canmount=on and unmount before unloading the key to compensate for
the auto-mount that happens when the key is loaded during creation.
This also silences the warning for forceImportRoot.

Assisted-by: opencode with DeepSeek V4 Flash Free
This commit is contained in:
Shogo Takata
2026-05-19 04:18:08 +09:00
parent 8595720644
commit 3fdfb983c7

View File

@@ -11,6 +11,7 @@ in
{ ... }:
{
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.forceImportRoot = false;
networking.hostId = "12345678";
@@ -42,10 +43,10 @@ in
machine.succeed("truncate -s 64M /testpool.img")
machine.succeed("zpool create -O canmount=off '${pool}' /testpool.img")
machine.succeed("zfs create -o canmount=off -p '${homes}'")
machine.succeed("echo ${userPassword} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/alice'")
machine.succeed("zfs unload-key '${homes}/alice'")
machine.succeed("echo ${mismatchPass} | zfs create -o canmount=noauto -o encryption=on -o keyformat=passphrase '${homes}/bob'")
machine.succeed("zfs unload-key '${homes}/bob'")
machine.succeed("echo ${userPassword} | zfs create -o encryption=on -o keyformat=passphrase '${homes}/alice'")
machine.succeed("zfs unmount '${homes}/alice' && zfs unload-key '${homes}/alice'")
machine.succeed("echo ${mismatchPass} | zfs create -o encryption=on -o keyformat=passphrase '${homes}/bob'")
machine.succeed("zfs unmount '${homes}/bob' && zfs unload-key '${homes}/bob'")
with subtest("Switch to tty2"):
machine.fail("pgrep -f 'agetty.*tty2'")