History log of /freebsd-11-stable/usr.bin/last/last.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 351925 06-Sep-2019 eugen

MFC r351413,351459,351467: unbreak last(1) for 8-bit locales

Ouput format of last's broken for non UTF-8 locales
since it got libxo(3) support. It uses strftime(3) that produces
non UTF-8 strings passed to xo_emit(3) with wrong %s format -
it should be %hs in this case, so xo_emit(3) produces empty output.

This change is basically no-op when locale is of UTF-8 type,
f.e. en_GB.UTF-8 or ru_RU.UTF-8 or sr_RS.UTF-8@latin.
Also it is no-op for C/POSIX locale that's a subset of UTF-8.

It fixes output for other locales.


# 338451 04-Sep-2018 philip

MFC r319508:
Fix a memory leak with last
free memory allocated to 'buf'

Submitted by: Thomas Rix <trix@juniper.net>

MFC r338352:
Add libxo(3) support to last(1).


# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 285742 21-Jul-2015 ed

Unbreak "last reboot".

According to the last(1) man page, the "reboot" pseudo-user should print
all system reboot entries. This got broken by the utmpx import, as
records are typed.

Re-add support for "last reboot" by specifically matching against
SHUTDOWN_TIME and BOOT_TIME records.

PR: 168844
Submitted by: matthew@
MFC after: 1 month


# 240425 12-Sep-2012 ed

Switch batch to an SLIST.

This code requires none of the features of LIST.


# 230458 22-Jan-2012 hrs

- Replace "wtmp" with "utx.log" because last(1) no longer reads wtmp.
- A real filename is now shown in an output report when "-f file" is specified.
- Add Xr lastlogin into last(1) manual page.

Reviewed by: ed
MFC after: 1 week


# 227168 06-Nov-2011 ed

Add missing static keywords to last(1)


# 216370 11-Dec-2010 joel

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# 202643 19-Jan-2010 ed

Make last(1) display the full log file.

I must have misread when I ported the original last(1) source code.
Instead of only processing the last 1024 entries, it reads them in in
chucks of 1024 entries at a time.

Unfortunately we cannot walk through the log file in reverse order,
which means we have to allocate a piece of memory to hold all the
entries. Call realloc() for each 128 entries we read.

Reported by: Andrzej Tobola <ato iem pw edu pl>


# 202197 13-Jan-2010 ed

Port last(1) to use utmpx.

Basically there are three major things I changed about last(1):

- It should use ut_type instead of determining by hand what type of
record was given.
- It should now keep track of ut_id's instead of TTYs. This means the
ttylist has been renamed to the idlist, storing all the ut_id's it has
processed until the next reboot.
- I've removed the signal handler. Because our wtmp is rotated so often,
it makes little sense. Even on a simple piece of hardware it should be
capable of grinding through megabytes of logs in a second.


# 133332 08-Aug-2004 dwmalone

s/FALLTHOUGH/FALLTHROUGH/

Submitted by: Xin LI <delphij@frontfree.net>


# 125856 15-Feb-2004 dwmalone

Include timeconv.h for _int_to_time and _time_to_int.


# 119023 17-Aug-2003 tjr

Tidy up usage message.


# 118077 27-Jul-2003 tjr

Add the -n maxrec option as an alias for -maxrec for compatibility with
System V and consistency with other utilities. Document the new form
instead of the old form in the manual page.

PR: 54661


# 106215 30-Oct-2002 mux

Fix core dumps when invoking with something like ``last -w1''.

PR: bin/44583
Reported by: Amit Chakradeo <sdbug@spam.chakradeo.net>
MFC after: 3 days


# 102944 04-Sep-2002 dwmalone

ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by: md5


# 99112 30-Jun-2002 obrien

Consistently use FBSDID


# 96785 17-May-2002 jmallett

Clean up malloc(3)'s argument. Remove casts which do nothing when we're
using sizeof() anyway. Use slightly more consistent (per-file) error
reporting for malloc(3) returning NULL. If "malloc failed" was being printed,
don't use err(3). If a NULL format is being used, use err(3). In one case
errx(3) was being used with strerror(3), so just use err(3).


# 92920 21-Mar-2002 imp

remove __P


# 91541 01-Mar-2002 iedowse

Add a new "-y" flag which causes the year to be included in the
session start time. This is useful when looking at old or long-running
wtmp files.

PR: bin/12982
Obtained from: KOJIMA Hajime <kjm@rins.ryukoku.ac.jp>, keramida
Reviewed by: keramida
MFC after: 1 week


# 91538 01-Mar-2002 iedowse

Oops, unbreak the -d and -<n> options. The `snapfound' variable
needs to be retained across entries, and we need to exit(), not
return from doentry() when `maxrec' reaches 0. Move the code for
processing `maxrec' into printentry() for simplicity.


# 91536 01-Mar-2002 iedowse

Split up the big wtmp() function to avoid long lines and code
duplication.


# 89572 19-Jan-2002 dillon

I've been meaning to do this for a while. Add an underscore to the
time_to_xxx() and xxx_to_time() functions. e.g. _time_to_xxx()
instead of time_to_xxx(), to make it more obvious that these are
stopgap functions & placemarkers and not meant to create a defacto
standard. They will eventually be replaced when a real standard
comes out of committee.


# 85648 28-Oct-2001 dillon

localtime() was being called on an int pointer (due to recent
utmp-related commits). fixed.


# 81161 05-Aug-2001 dd

Document -d in usage.

Submitted by: Martin Kammerhofer <mkamm@sbox.tu-graz.ac.at>


# 78201 14-Jun-2001 dd

Silence warnings and minor style fixes. Mostly constify and don't
assume that time_t is a long. Clamp down with WARNS=2.

Not objected to by: -audit


# 77328 28-May-2001 ru

The last(1) choked if there were two successive "login" marks
found in wtmp(5) for the same TTY without in-between "logout"
mark.

This may be demonstrated by executing login(1), logging in and
out, and watching the last(1) output on this TTY:

: # last -tv7 -w
: ru ttyv7 Mon May 28 12:46 - 12:46 (00:00:01)
: ru ttyv7 Mon May 28 12:45 still logged in

The fix merely takes the second "login" mark as the "logout" for
the first "login" mark, if there were no "logout" mark in-between.
This restores the behavior of last.c,v 1.2:

: # last -tv7 -w
: ru ttyv7 Mon May 28 12:46 - 12:46 (00:00:01)
: ru ttyv7 Mon May 28 12:45 - 12:46 (00:00:25)

Silence from: -arch, dg


# 77291 27-May-2001 dd

Implement snapshots. The new -d option allows the user to find out
who was logged in at a certain time and date.

Obtained from: OpenBSD


# 74588 21-Mar-2001 ache

Don't attempt to parse %c


# 70467 29-Dec-2000 phk

Used macro-API to <sys/queue.h>.

Submitted by: ben


# 65428 04-Sep-2000 imp

getopt and friends are declared in <unistd.h>
getopt returns -1 not EOF.


# 62871 10-Jul-2000 kris

Don't call printf with no format string.


# 60938 26-May-2000 jake

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


# 60833 23-May-2000 jake

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


# 36434 27-May-1998 danny

Reviewed by: Peter Hawkins <thepish@FreeBSD.org>
Add s and w flags to show duration in or with seconds.


# 36062 15-May-1998 jb

Change variable from long to time_t where they are passed by reference
to time().


# 35658 03-May-1998 steve

Add the year to the 'wtmp begins...' line.

PR: 6421
Submitted by: phk


# 24360 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 20158 05-Dec-1996 ache

Remove one space to produce the same output alignment
like in who, rwho, w, etc.


# 19223 28-Oct-1996 joerg

Don't dereference a free()ed pointer.

Closes PR bin/1909: 'last' coredumps if MALLOC_OPTIONS...


# 16438 17-Jun-1996 ache

Localize time


# 11547 17-Oct-1995 dg

Fixed a bug that caused last(1) to be extremely slow in some cases, and
made other performance improving changes. This improves the performance
of last(1) by as much as 32 times in some cases, and in more typical cases
is about twice as fast.
Added a BUGS section to the manual page to describe the behavior of last(1)
when a login shell terminates abnormally (and thus doesn't write a logout
record to the wtmp file).


# 9987 07-Aug-1995 wollman

Delete bogus referneces to timezone code internal header file `tzfile.h',
which is no longer bogusly installed in /usr/include.


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources