The first login entry is ignored if a log file contains more than one entries. For example:
$ utmpdump wtmp.two Utmp dump of wtmp.two [7] [07810] [ts/2] [username] [pts/2 ] [192.168.255.114 ] ... [8] [07810] [ts/2] [ ] [pts/2 ] [ ] ... $ ln -sf $(realpath wtmp.two) /var/log/wtmp $ busybox last USER TTY HOST LOGIN TIME $ utmpdump wtmp.one Utmp dump of wtmp.one [7] [07810] [ts/2] [username] [pts/2 ] [192.168.255.114 ] ... $ ln -sf $(realpath wtmp.one) /var/log/wtmp $ busybox last USER TTY HOST LOGIN TIME username pts/2 192.168.255.114 May 14 11:12 To fix it, do not break the while loop if the offset is zero. --- util-linux/last.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/last.c b/util-linux/last.c index 7530d013d..aafd01bb9 100644 --- a/util-linux/last.c +++ b/util-linux/last.c @@ -157,7 +157,7 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); next: pos -= sizeof(ut); - if (pos <= 0) + if (pos < 0) break; /* done. */ xlseek(file, pos, SEEK_SET); } -- 2.49.0 _______________________________________________ busybox mailing list busybox@busybox.net https://lists.busybox.net/mailman/listinfo/busybox