]> git.ipfire.org Git - thirdparty/util-linux.git/blob - liblastlog2/README.md
lastlog2 - Y2038 safe version of lastlog
[thirdparty/util-linux.git] / liblastlog2 / README.md
1 # lastlog2
2
3 **Y2038 safe version of lastlog**
4
5 ## Background
6
7 `lastlog` reports the last login of a given user or of all users who did ever login on a system.
8
9 The standard `/var/log/lastlog` implementation using `lastlog.h` from glibc uses a **32bit** **time_t** in `struct lastlog` on bi-arch systems like x86-64 (so which can execute 64bit and 32bit binaries). So even if you have a pure 64bit system, on many architectures using glibc you have a Y2038 problem.
10
11 For background on the Y2038 problem (32bit time_t counter will overflow) I suggest to start with the wikipedia [Year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) article.
12
13 There is also a more [technical document](https://github.com/thkukuk/utmpx/blob/main/Y2038.md), describing the problem in more detail, which also contains a list of affected packages. And a more highlevel blog "[Y2038, glibc and /var/log/lastlog on 64bit architectures](https://www.thkukuk.de/blog/Y2038_glibc_lastlog_64bit/)"
14
15 Additional, `/var/log/lastlog` can become really huge if there are big UIDs in use on the system. Since it is a sparse file, this is normally not a problem, but depending on the filesystem or the tools used for backup, this can become a real problem.
16
17 Since there are only few applications which really support `lastlog`, the data is also not always correct.
18
19 ## lastlog2
20
21 `lastlog2` tries to solve this problems:
22
23 * It's using sqlite3 as database backend.
24 * Data is only collected via a PAM module, so that every tools can make use of it, without modifying existing packages.
25 * The output is as compatible as possible with the old lastlog implementation.
26 * The old `/var/log/lastlog` file can be imported into the new database.
27 * The size of the database depends on the amount of users, not how big the biggest UID is.
28
29 **IMPORTANT** To be Y2038 safe on 32bit architectures, the binaries needs to be build with a **64bit time_t**. This should be the standard on 64bit architectures.
30
31 Besides the lastlog2 library in this directory there are additional parts like service definition, PAM module and applications:
32
33 * `liblastlog2.so.0` contains all high level functions to manage the data (util-linux/liblastlog2).
34 * `pam_lastlog2.so` shows the last login of a user and stores the new login into the database (util-linux/pam_lastlog2).
35 * `lastlog2` will display the last logins for all users, who did ever login (util-linux/misc-utils).
36 * `lastlog2-import.service` a service which imports lastlog data into lastlog2 database (util-linux/misc-utils).
37 * `lastlog2.conf` configuration for tmpfiles.d. See tmpfiles.d(5) for details (util-linux/misc-utils).
38
39 By default the database will be written as `/var/lib/lastlog/lastlog2.db`.
40