1 import ./make-test-python.nix ({ ... }:
5 nodes.machine = { pkgs, ... }: {
6 imports = [ ./common/user-account.nix ];
7 security.pam.enableFscrypt = true;
12 machine.wait_until_tty_matches("1", "login: ")
13 machine.send_chars("alice\n")
14 machine.wait_until_tty_matches("1", "Password: ")
15 machine.send_chars("foobar\n")
16 machine.wait_until_tty_matches("1", "alice\@machine")
20 machine.send_chars("logout\n")
21 machine.wait_until_tty_matches("1", "login: ")
24 machine.wait_for_unit("default.target")
26 with subtest("Enable fscrypt on filesystem"):
27 machine.succeed("tune2fs -O encrypt /dev/vda")
28 machine.succeed("fscrypt setup --quiet --force --time=1ms")
30 with subtest("Set up alice with an fscrypt-enabled home directory"):
31 machine.succeed("(echo foobar; echo foobar) | passwd alice")
32 machine.succeed("chown -R alice.users ~alice")
33 machine.succeed("echo foobar | fscrypt encrypt --skip-unlock --source=pam_passphrase --user=alice /home/alice")
35 with subtest("Create file as alice"):
37 machine.succeed("echo hello > /home/alice/world")
39 # Wait for logout to be processed
42 with subtest("File should not be readable without being logged in as alice"):
43 machine.fail("cat /home/alice/world")
45 with subtest("File should be readable again as alice"):
47 machine.succeed("cat /home/alice/world")