History log of /freebsd-current/usr.bin/last/last.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 1190b82c 17-Apr-2023 Gordon Bergling <gbe@FreeBSD.org>

last(1): Remove double words in source code comments

- s/on on/on/
- s/we we/we/

MFC after: 5 days


# 8da27052 10-Oct-2021 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

last: improve non-UTF8 locale output after libxo support was added

Some strftime(3) conversion specifications will generate strings encoded
with the current locale, not necessarily UTF8. As per xo_format.5, use
the h string modifier so that libxo interprets it appropriately.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437


# 902cde5d 10-Oct-2021 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

Revert "last(1): unbreak for 8-bit locales"

This reverts commits 8e67c427b5 (unbreak for 8-bit locales), 0ca58ca151
(correction after r351413), and f424ec1b80 (fix style after r351459).

A simpler fix can be done by using the h modifier for strings that are
encoded with the current locale.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437


# f424ec1b 24-Aug-2019 Eugene Grosbein <eugen@FreeBSD.org>

last(1): fix style after r351459

Reported by: cem
MFC after: 2 weeks
X-MFC-With: 351459


# 0ca58ca1 24-Aug-2019 Eugene Grosbein <eugen@FreeBSD.org>

last(1): correction after r351413

Make that change no-op for C/POSIX locale just like for UTF-8
that it superset of US-ASCII.

MFC after: 2 weeks
X-MFC-With: r351413


# 8e67c427 22-Aug-2019 Eugene Grosbein <eugen@FreeBSD.org>

last(1): unbreak for 8-bit locales

Ouput format of last(1) is 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.
It fixes output for other locales.

MFC after: 2 weeks


# c7c5d8e3 28-Aug-2018 Philip Paeps <philip@FreeBSD.org>

Add libxo(3) support to last(1).

Reviewed by: kp
Approved by: re (gjb)
MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D16922


# 7672a014 19-Jun-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.

No functional change intended.


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# e2005cef 02-Jun-2017 Stephen J. Kiernan <stevek@FreeBSD.org>

Fix a memory leak with last
free memory allocated to 'buf'

Submitted by: Thomas Rix <trix@juniper.net>
Reviewed by: ed
Approved by: sjg (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D9850


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 941e22d1 15-Dec-2016 Conrad Meyer <cem@FreeBSD.org>

Capsicumify last(1)

Reviewed by: ed (earlier version), emaste (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8001


# 46e834d7 21-Jul-2015 Ed Schouten <ed@FreeBSD.org>

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


# 8f8f4763 12-Sep-2012 Ed Schouten <ed@FreeBSD.org>

Switch batch to an SLIST.

This code requires none of the features of LIST.


# 9549f742 22-Jan-2012 Hiroki Sato <hrs@FreeBSD.org>

- 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


# 7f3271b6 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Add missing static keywords to last(1)


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 6628ca0a 19-Jan-2010 Ed Schouten <ed@FreeBSD.org>

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>


# 561f61e2 13-Jan-2010 Ed Schouten <ed@FreeBSD.org>

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.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 7e699048 08-Aug-2004 David Malone <dwmalone@FreeBSD.org>

s/FALLTHOUGH/FALLTHROUGH/

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


# baa8d917 15-Feb-2004 David Malone <dwmalone@FreeBSD.org>

Include timeconv.h for _int_to_time and _time_to_int.


# 32933324 17-Aug-2003 Tim J. Robbins <tjr@FreeBSD.org>

Tidy up usage message.


# b28e0896 27-Jul-2003 Tim J. Robbins <tjr@FreeBSD.org>

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


# 4fd036fd 30-Oct-2002 Maxime Henrion <mux@FreeBSD.org>

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


# f4ac32de 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

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


# e026a48c 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use FBSDID


# 47bca8b0 16-May-2002 Juli Mallett <jmallett@FreeBSD.org>

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).


# f1bb2cd2 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# 139db33f 01-Mar-2002 Ian Dowse <iedowse@FreeBSD.org>

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


# 2e7a4024 01-Mar-2002 Ian Dowse <iedowse@FreeBSD.org>

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.


# 6e3a7c4b 01-Mar-2002 Ian Dowse <iedowse@FreeBSD.org>

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


# 170ac683 19-Jan-2002 Matthew Dillon <dillon@FreeBSD.org>

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.


# 5fb4dbe1 28-Oct-2001 Matthew Dillon <dillon@FreeBSD.org>

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


# e632521c 05-Aug-2001 Dima Dorfman <dd@FreeBSD.org>

Document -d in usage.

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


# 92b401e8 13-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

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


# f8207886 28-May-2001 Ruslan Ermilov <ru@FreeBSD.org>

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


# 8a242856 27-May-2001 Dima Dorfman <dd@FreeBSD.org>

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


# a99768c6 21-Mar-2001 Andrey A. Chernov <ache@FreeBSD.org>

Don't attempt to parse %c


# 4ea7b32b 29-Dec-2000 Poul-Henning Kamp <phk@FreeBSD.org>

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

Submitted by: ben


# 62f882d6 04-Sep-2000 Warner Losh <imp@FreeBSD.org>

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


# 612740bd 10-Jul-2000 Kris Kennaway <kris@FreeBSD.org>

Don't call printf with no format string.


# e3975643 25-May-2000 Jake Burkholder <jake@FreeBSD.org>

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

Requested by: msmith and others


# 740a1973 23-May-2000 Jake Burkholder <jake@FreeBSD.org>

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


# e72acbba 27-May-1998 Daniel O'Callaghan <danny@FreeBSD.org>

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


# 17ce1248 14-May-1998 John Birrell <jb@FreeBSD.org>

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


# 7c50fe7b 03-May-1998 Steve Price <steve@FreeBSD.org>

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

PR: 6421
Submitted by: phk


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

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


# eb7456fc 05-Dec-1996 Andrey A. Chernov <ache@FreeBSD.org>

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


# 19bb5783 28-Oct-1996 Joerg Wunsch <joerg@FreeBSD.org>

Don't dereference a free()ed pointer.

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


# 3905c66a 17-Jun-1996 Andrey A. Chernov <ache@FreeBSD.org>

Localize time


# c83d3f45 17-Oct-1995 David Greenman <dg@FreeBSD.org>

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).


# 656dcd43 07-Aug-1995 Garrett Wollman <wollman@FreeBSD.org>

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


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources