1 diff -ruNp sysvinit-2.96.orig/src/last.c sysvinit-2.96/src/last.c
2 --- sysvinit-2.96.orig/src/last.c 2019-09-11 19:43:12.000000000 +0200
3 +++ sysvinit-2.96/src/last.c 2019-12-01 05:14:37.344902512 +0100
9 + * Try to be smart about the location of the BTMP file
12 +#define _PATH_BTMP "/var/log/btmp"
13 +#define BTMP_FILE _PATH_BTMP
16 +#define TRANSFORM_UTMP_FILE_NAME(file_name) \
17 + ((strcmp (file_name, _PATH_WTMP) == 0 \
18 + && access ( _PATH_WTMP "x", F_OK) == 0) ? (_PATH_WTMP "x") : \
19 + ((strcmp (file_name, _PATH_BTMP) == 0 \
20 + && access ( _PATH_BTMP "x", F_OK) == 0) ? (_PATH_BTMP "x") : \
21 + ((strcmp (file_name, _PATH_WTMP "x") == 0 \
22 + && access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \
23 + ((strcmp (file_name, _PATH_BTMP "x") == 0 \
24 + && access (_PATH_BTMP "x", F_OK) != 0) ? _PATH_BTMP : \
28 # define SHUTDOWN_TIME 254
30 @@ -251,28 +270,6 @@ int uread(FILE *fp, struct utmp *u, int
34 - * Try to be smart about the location of the BTMP file
37 -#define BTMP_FILE getbtmp()
40 - static char btmp[PATH_MAX + 5]; /* max path + btmp + null terminator */
43 - memset(btmp, '\0', PATH_MAX + 5);
44 - strncpy(btmp, WTMP_FILE, PATH_MAX);
45 - if ((p = strrchr(btmp, '/')) == NULL)
50 - strcat(btmp, "btmp");
59 @@ -381,6 +378,8 @@ int list(struct utmp *p, time_t t, int w
60 strncat(utline, p->ut_line, UT_LINESIZE);
61 if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
63 + if (strncmp(utline, "ftpd", 4) == 0 && isdigit(utline[4]))
65 if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))
68 @@ -708,10 +707,10 @@ int main(int argc, char **argv)
69 * Which file do we want to read?
71 if (strcmp(progname, "lastb") == 0) {
73 + ufile = TRANSFORM_UTMP_FILE_NAME(BTMP_FILE);
77 + ufile = TRANSFORM_UTMP_FILE_NAME(WTMP_FILE);
81 diff -ruNp sysvinit-2.96.orig/src/utmp.c sysvinit-2.96/src/utmp.c
82 --- sysvinit-2.96.orig/src/utmp.c 2019-09-11 19:43:12.000000000 +0200
83 +++ sysvinit-2.96/src/utmp.c 2019-12-01 05:15:12.143729210 +0100
84 @@ -80,7 +80,9 @@ char *line) /* Which line is this */
85 * this if we have updwtmp() so we can see if the
86 * wtmp file is accessible.
89 if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return;
94 @@ -140,8 +142,8 @@ char *line) /* Which line is this */
95 updwtmp(WTMP_FILE, &utmp);
97 write(fd, (char *)&utmp, sizeof(utmp));
104 @@ -164,8 +166,10 @@ char *oldline) /* Line of old utmp ent
106 * Can't do much if UTMP_FILE is not present or not writable.
109 if (access(UTMP_FILE, W_OK) < 0)