diff --git a/nixos/tests/pam/pam-lastlog.nix b/nixos/tests/pam/pam-lastlog.nix index 70bb74a055c5..4d1dab8e7150 100644 --- a/nixos/tests/pam/pam-lastlog.nix +++ b/nixos/tests/pam/pam-lastlog.nix @@ -6,10 +6,7 @@ nodes.machine = { ... }: { - # we abuse run0 for a quick login as root as to not require setting up accounts and passwords - security.pam.services.systemd-run0 = { - lastlog.enable = true; - }; + imports = [ ../common/user-account.nix ]; }; testScript = '' @@ -23,8 +20,13 @@ with subtest("Test lastlog entries are created by logins"): machine.wait_for_unit("multi-user.target") - machine.succeed("run0 --pty true") # perform full login - print(machine.succeed("lastlog2 --active --user root")) + machine.wait_until_tty_matches("1", "login: ") + machine.send_chars("alice\n") + machine.wait_until_tty_matches("1", "Password: ") + machine.send_chars("foobar\n") + machine.wait_until_succeeds("pgrep -u alice bash") + print(machine.succeed("lastlog2 --active --user alice")) machine.succeed("stat /var/lib/lastlog/lastlog2.db") + machine.send_chars("exit\n") ''; }