apparmor/utils/test/wtmp-examples
Christian Boltz 45e4c27cf0
Add support for lastlog2 to get last login
lastlog2 is the 2038-safe replacement for wtmp, and in the meantime
became part of util-linux.

This commit switches from trying to parse the lastlog2 output to
directly reading lastlog2.db with sqlite3.

Adjust get_last_login_timestamp() to use the lastlog2 database
(/var/lib/lastlog/lastlog2.db) if it exists, and adjust
get_last_login_timestamp_lastlog2() to actually do that.

(If lastlog2.db doesn't exist, aa-notify will read wtmp as usual.)

Unfortunately lastlog2 doesn't have a way to get machine-readable output
(for example json), therefore - after trying and failing to parse the
lastlog2 output - directly read from lastlog2.db. Let's hope the format
never changes ;-)

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1228378

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1216660

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/372
2025-01-14 19:36:43 +01:00
..
lastlog2.db Add support for lastlog2 to get last login 2025-01-14 19:36:43 +01:00
wtmp-aarch64 Add support for reading s390x and aarch64 wtmp file 2021-10-24 17:24:43 +02:00
wtmp-aarch64-expected-output Add support for reading s390x and aarch64 wtmp file 2021-10-24 17:24:43 +02:00
wtmp-s390x Add support for reading s390x and aarch64 wtmp file 2021-10-24 17:24:43 +02:00
wtmp-s390x-expected-output Add support for reading s390x and aarch64 wtmp file 2021-10-24 17:24:43 +02:00
wtmp-truncated Add truncated and ancient wtmp example to tests 2021-10-24 17:24:43 +02:00
wtmp-x86_64 Add unittest for get_last_login_timestamp 2021-10-24 14:23:53 +02:00
wtmp-x86_64-expected Add unittest for get_last_login_timestamp 2021-10-24 14:23:53 +02:00
wtmp-x86_64-past Add truncated and ancient wtmp example to tests 2021-10-24 17:24:43 +02:00
wtmp-x86_64-past-expected Add truncated and ancient wtmp example to tests 2021-10-24 17:24:43 +02:00