at master 1.0 kB view raw
1{ ... }: 2 3{ 4 name = "pam-lastlog"; 5 6 nodes.machine = 7 { ... }: 8 { 9 # we abuse run0 for a quick login as root as to not require setting up accounts and passwords 10 security.pam.services.systemd-run0 = { 11 updateWtmp = true; # enable lastlog 12 }; 13 }; 14 15 testScript = '' 16 with subtest("Test legacy lastlog import"): 17 # create old lastlog file to test import 18 # empty = nothing will actually be imported, but the service will run 19 machine.succeed("touch /var/log/lastlog") 20 machine.wait_for_unit("lastlog2-import.service") 21 machine.succeed("journalctl -b --grep 'Starting Import lastlog data into lastlog2 database'") 22 machine.succeed("stat /var/log/lastlog.migrated") 23 24 with subtest("Test lastlog entries are created by logins"): 25 machine.wait_for_unit("multi-user.target") 26 machine.succeed("run0 --pty true") # perform full login 27 print(machine.succeed("lastlog2 --active --user root")) 28 machine.succeed("stat /var/lib/lastlog/lastlog2.db") 29 ''; 30}