History log of /openbsd-current/usr.bin/last/last.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.54 24-Oct-2021 deraadt

For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef.
ok millert


Revision tags: OPENBSD_7_0_BASE
# 1.53 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 03-Aug-2018 deraadt

pledge() a little later, after getopt operation, in case -f option changes
the filename. We can then unveil that file, pledge() as before, and proceed
to parsing.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 29-Oct-2015 deraadt

pledge "stdio rpath".


# 1.49 20-Aug-2015 deraadt

Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.48 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


# 1.47 14-Mar-2015 deraadt

use ctime_r to avoid a re-entrancy signal race
ok millert


Revision tags: OPENBSD_5_7_BASE
# 1.46 08-Feb-2015 deraadt

in getopt() blocks, stop incrementing flag variable which are supposed
to just be 0/1
ok miod florian


# 1.45 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.44 09-Dec-2014 tedu

init crmsg to something so it doesn't crash on invalid wtmp files.
from david higgs


# 1.43 26-Nov-2014 millert

Prefer setvbuf() to setlinebuf() for portability; ok deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.42 22-Apr-2014 okan

Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and
'tty') from pid stripping, then strip the rest.

idea, feedback and ok millert@


# 1.41 17-Apr-2014 okan

remove special case for uucp entries.

ok guenther


# 1.40 17-Apr-2014 guenther

Correct some time_t printing; factor out a grotty block while here

Based on a diff from Arto Jonsson (ajonsson (at) kapsi.fi)
ok deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.39 22-Aug-2013 guenther

Correct format string mismatches turned up by -Wformat=2

suggestions and ok millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.38 18-Feb-2013 fgsch

Fix after last commit: add missing header.
sthen@ ok.


# 1.37 12-Feb-2013 lum

Reflect the -f option in last's output. Original diff from Jacob L. Leifman.
Other feedback from Callum Davies and sthen@
ok mpi@ ian@ kettenis@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.36 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.35 01-May-2009 chl

add missing header needed by isdigit()

ok otto@ millert@ gilles@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.34 27-Oct-2006 jmc

- simplify and sort synopsis
- sort options
- some minor text tweaks
- sync usage()


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.33 14-Nov-2005 deraadt

fix fd leak; then i got a bit carried away making the code prettier


Revision tags: OPENBSD_3_8_BASE
# 1.32 01-Jul-2005 millert

Replace numeric argument handling (e.g. last -30) with something that
can deal with mixer number and normal arguments, adapted from my code
in diff(1). OK deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.31 16-Jun-2004 millert

Add a new -n option that replaces the old -number option (which now
only exists for backwards compat).
Based on a diff from robert@; OK robert@ and deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.30 08-Jan-2004 otto

Fix uninitialized variable. From Ilya Voronin <ivoronin at trancom dot ru>


# 1.29 09-Nov-2003 otto

Typos in comments from Jared Yanovich <jjy2+ at pitt dot edu>


Revision tags: OPENBSD_3_4_BASE
# 1.28 14-Aug-2003 deraadt

make 9-char login names not stretch the line; millert ok


# 1.27 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.25 29-May-2003 deraadt

avoid more signal races


# 1.24 25-Apr-2003 tedu

minor tweak to error message, from Eric in pr3235


# 1.23 14-Apr-2003 deraadt

fix time spec even better; emmf26@umr.edu


# 1.22 06-Apr-2003 deraadt

make usage exactly like in the man page; andrushock@korovino.net


# 1.21 05-Apr-2003 deraadt

simple snprintf and strlcpy; henning ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 23-Sep-2002 millert

Add missing includes, breaks and semicolons to appease gcc3; David Krause
deraadt@ OK


Revision tags: OPENBSD_3_1_BASE
# 1.19 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.18 04-Feb-2002 mickey

fix a typo; from Sam Smith <S@mSmith.net>


# 1.17 05-Nov-2001 deraadt

mark a zone of signal races


Revision tags: OPENBSD_3_0_BASE
# 1.16 18-Jul-2001 pvalchev

-Wall cleanup


# 1.15 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_9_BASE
# 1.14 06-Feb-2001 fgsch

Change host width to 24 so last produces one line per user; deraadt ok.


# 1.13 31-Jan-2001 deraadt

move utmp to large format, usernames to 32 chars; downsj


# 1.12 12-Dec-2000 deraadt

incorrect time specification; noted by sigh@kuzirabekon.econ.nagasaki-u.ac.jp


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.11 13-Jul-1998 millert

ftpd: sleep for an indeterminate amount for non-existant logins
to simulate a crypt, like login does.
Use SEEK_* not L_* and kill some 0L's used in lseek while we're there.


# 1.10 25-Apr-1998 deraadt

print year; mason@primenet.com.au


Revision tags: OPENBSD_2_3_BASE
# 1.9 10-Mar-1998 downsj

Add -c (for humans) and -s (for machines).


Revision tags: OPENBSD_2_2_BASE
# 1.8 25-Aug-1997 deraadt

incorrect type for variable; enami@but-b.or.jp


# 1.7 21-Aug-1997 deraadt

correct [yy]yy stuff in manpages and usage


# 1.6 25-Jul-1997 mickey

-T to display seconds, from jhawk netbsd-pr#1548


# 1.5 20-Jul-1997 jdm

minor cleanup on the -d flag code


# 1.4 20-Jul-1997 jdm

add -d flag for reporting active sessions at a specified point in time.


Revision tags: OPENBSD_2_1_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.53 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 03-Aug-2018 deraadt

pledge() a little later, after getopt operation, in case -f option changes
the filename. We can then unveil that file, pledge() as before, and proceed
to parsing.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 29-Oct-2015 deraadt

pledge "stdio rpath".


# 1.49 20-Aug-2015 deraadt

Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.48 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


# 1.47 14-Mar-2015 deraadt

use ctime_r to avoid a re-entrancy signal race
ok millert


Revision tags: OPENBSD_5_7_BASE
# 1.46 08-Feb-2015 deraadt

in getopt() blocks, stop incrementing flag variable which are supposed
to just be 0/1
ok miod florian


# 1.45 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.44 09-Dec-2014 tedu

init crmsg to something so it doesn't crash on invalid wtmp files.
from david higgs


# 1.43 26-Nov-2014 millert

Prefer setvbuf() to setlinebuf() for portability; ok deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.42 22-Apr-2014 okan

Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and
'tty') from pid stripping, then strip the rest.

idea, feedback and ok millert@


# 1.41 17-Apr-2014 okan

remove special case for uucp entries.

ok guenther


# 1.40 17-Apr-2014 guenther

Correct some time_t printing; factor out a grotty block while here

Based on a diff from Arto Jonsson (ajonsson (at) kapsi.fi)
ok deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.39 22-Aug-2013 guenther

Correct format string mismatches turned up by -Wformat=2

suggestions and ok millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.38 18-Feb-2013 fgsch

Fix after last commit: add missing header.
sthen@ ok.


# 1.37 12-Feb-2013 lum

Reflect the -f option in last's output. Original diff from Jacob L. Leifman.
Other feedback from Callum Davies and sthen@
ok mpi@ ian@ kettenis@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.36 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.35 01-May-2009 chl

add missing header needed by isdigit()

ok otto@ millert@ gilles@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.34 27-Oct-2006 jmc

- simplify and sort synopsis
- sort options
- some minor text tweaks
- sync usage()


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.33 14-Nov-2005 deraadt

fix fd leak; then i got a bit carried away making the code prettier


Revision tags: OPENBSD_3_8_BASE
# 1.32 01-Jul-2005 millert

Replace numeric argument handling (e.g. last -30) with something that
can deal with mixer number and normal arguments, adapted from my code
in diff(1). OK deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.31 16-Jun-2004 millert

Add a new -n option that replaces the old -number option (which now
only exists for backwards compat).
Based on a diff from robert@; OK robert@ and deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.30 08-Jan-2004 otto

Fix uninitialized variable. From Ilya Voronin <ivoronin at trancom dot ru>


# 1.29 09-Nov-2003 otto

Typos in comments from Jared Yanovich <jjy2+ at pitt dot edu>


Revision tags: OPENBSD_3_4_BASE
# 1.28 14-Aug-2003 deraadt

make 9-char login names not stretch the line; millert ok


# 1.27 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.25 29-May-2003 deraadt

avoid more signal races


# 1.24 25-Apr-2003 tedu

minor tweak to error message, from Eric in pr3235


# 1.23 14-Apr-2003 deraadt

fix time spec even better; emmf26@umr.edu


# 1.22 06-Apr-2003 deraadt

make usage exactly like in the man page; andrushock@korovino.net


# 1.21 05-Apr-2003 deraadt

simple snprintf and strlcpy; henning ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 23-Sep-2002 millert

Add missing includes, breaks and semicolons to appease gcc3; David Krause
deraadt@ OK


Revision tags: OPENBSD_3_1_BASE
# 1.19 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.18 04-Feb-2002 mickey

fix a typo; from Sam Smith <S@mSmith.net>


# 1.17 05-Nov-2001 deraadt

mark a zone of signal races


Revision tags: OPENBSD_3_0_BASE
# 1.16 18-Jul-2001 pvalchev

-Wall cleanup


# 1.15 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_9_BASE
# 1.14 06-Feb-2001 fgsch

Change host width to 24 so last produces one line per user; deraadt ok.


# 1.13 31-Jan-2001 deraadt

move utmp to large format, usernames to 32 chars; downsj


# 1.12 12-Dec-2000 deraadt

incorrect time specification; noted by sigh@kuzirabekon.econ.nagasaki-u.ac.jp


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.11 13-Jul-1998 millert

ftpd: sleep for an indeterminate amount for non-existant logins
to simulate a crypt, like login does.
Use SEEK_* not L_* and kill some 0L's used in lseek while we're there.


# 1.10 25-Apr-1998 deraadt

print year; mason@primenet.com.au


Revision tags: OPENBSD_2_3_BASE
# 1.9 10-Mar-1998 downsj

Add -c (for humans) and -s (for machines).


Revision tags: OPENBSD_2_2_BASE
# 1.8 25-Aug-1997 deraadt

incorrect type for variable; enami@but-b.or.jp


# 1.7 21-Aug-1997 deraadt

correct [yy]yy stuff in manpages and usage


# 1.6 25-Jul-1997 mickey

-T to display seconds, from jhawk netbsd-pr#1548


# 1.5 20-Jul-1997 jdm

minor cleanup on the -d flag code


# 1.4 20-Jul-1997 jdm

add -d flag for reporting active sessions at a specified point in time.


Revision tags: OPENBSD_2_1_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.52 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.51 03-Aug-2018 deraadt

pledge() a little later, after getopt operation, in case -f option changes
the filename. We can then unveil that file, pledge() as before, and proceed
to parsing.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 29-Oct-2015 deraadt

pledge "stdio rpath".


# 1.49 20-Aug-2015 deraadt

Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.48 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


# 1.47 14-Mar-2015 deraadt

use ctime_r to avoid a re-entrancy signal race
ok millert


Revision tags: OPENBSD_5_7_BASE
# 1.46 08-Feb-2015 deraadt

in getopt() blocks, stop incrementing flag variable which are supposed
to just be 0/1
ok miod florian


# 1.45 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.44 09-Dec-2014 tedu

init crmsg to something so it doesn't crash on invalid wtmp files.
from david higgs


# 1.43 26-Nov-2014 millert

Prefer setvbuf() to setlinebuf() for portability; ok deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.42 22-Apr-2014 okan

Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and
'tty') from pid stripping, then strip the rest.

idea, feedback and ok millert@


# 1.41 17-Apr-2014 okan

remove special case for uucp entries.

ok guenther


# 1.40 17-Apr-2014 guenther

Correct some time_t printing; factor out a grotty block while here

Based on a diff from Arto Jonsson (ajonsson (at) kapsi.fi)
ok deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.39 22-Aug-2013 guenther

Correct format string mismatches turned up by -Wformat=2

suggestions and ok millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.38 18-Feb-2013 fgsch

Fix after last commit: add missing header.
sthen@ ok.


# 1.37 12-Feb-2013 lum

Reflect the -f option in last's output. Original diff from Jacob L. Leifman.
Other feedback from Callum Davies and sthen@
ok mpi@ ian@ kettenis@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.36 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.35 01-May-2009 chl

add missing header needed by isdigit()

ok otto@ millert@ gilles@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.34 27-Oct-2006 jmc

- simplify and sort synopsis
- sort options
- some minor text tweaks
- sync usage()


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.33 14-Nov-2005 deraadt

fix fd leak; then i got a bit carried away making the code prettier


Revision tags: OPENBSD_3_8_BASE
# 1.32 01-Jul-2005 millert

Replace numeric argument handling (e.g. last -30) with something that
can deal with mixer number and normal arguments, adapted from my code
in diff(1). OK deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.31 16-Jun-2004 millert

Add a new -n option that replaces the old -number option (which now
only exists for backwards compat).
Based on a diff from robert@; OK robert@ and deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.30 08-Jan-2004 otto

Fix uninitialized variable. From Ilya Voronin <ivoronin at trancom dot ru>


# 1.29 09-Nov-2003 otto

Typos in comments from Jared Yanovich <jjy2+ at pitt dot edu>


Revision tags: OPENBSD_3_4_BASE
# 1.28 14-Aug-2003 deraadt

make 9-char login names not stretch the line; millert ok


# 1.27 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.25 29-May-2003 deraadt

avoid more signal races


# 1.24 25-Apr-2003 tedu

minor tweak to error message, from Eric in pr3235


# 1.23 14-Apr-2003 deraadt

fix time spec even better; emmf26@umr.edu


# 1.22 06-Apr-2003 deraadt

make usage exactly like in the man page; andrushock@korovino.net


# 1.21 05-Apr-2003 deraadt

simple snprintf and strlcpy; henning ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 23-Sep-2002 millert

Add missing includes, breaks and semicolons to appease gcc3; David Krause
deraadt@ OK


Revision tags: OPENBSD_3_1_BASE
# 1.19 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.18 04-Feb-2002 mickey

fix a typo; from Sam Smith <S@mSmith.net>


# 1.17 05-Nov-2001 deraadt

mark a zone of signal races


Revision tags: OPENBSD_3_0_BASE
# 1.16 18-Jul-2001 pvalchev

-Wall cleanup


# 1.15 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_9_BASE
# 1.14 06-Feb-2001 fgsch

Change host width to 24 so last produces one line per user; deraadt ok.


# 1.13 31-Jan-2001 deraadt

move utmp to large format, usernames to 32 chars; downsj


# 1.12 12-Dec-2000 deraadt

incorrect time specification; noted by sigh@kuzirabekon.econ.nagasaki-u.ac.jp


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.11 13-Jul-1998 millert

ftpd: sleep for an indeterminate amount for non-existant logins
to simulate a crypt, like login does.
Use SEEK_* not L_* and kill some 0L's used in lseek while we're there.


# 1.10 25-Apr-1998 deraadt

print year; mason@primenet.com.au


Revision tags: OPENBSD_2_3_BASE
# 1.9 10-Mar-1998 downsj

Add -c (for humans) and -s (for machines).


Revision tags: OPENBSD_2_2_BASE
# 1.8 25-Aug-1997 deraadt

incorrect type for variable; enami@but-b.or.jp


# 1.7 21-Aug-1997 deraadt

correct [yy]yy stuff in manpages and usage


# 1.6 25-Jul-1997 mickey

-T to display seconds, from jhawk netbsd-pr#1548


# 1.5 20-Jul-1997 jdm

minor cleanup on the -d flag code


# 1.4 20-Jul-1997 jdm

add -d flag for reporting active sessions at a specified point in time.


Revision tags: OPENBSD_2_1_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.51 03-Aug-2018 deraadt

pledge() a little later, after getopt operation, in case -f option changes
the filename. We can then unveil that file, pledge() as before, and proceed
to parsing.


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.50 29-Oct-2015 deraadt

pledge "stdio rpath".


# 1.49 20-Aug-2015 deraadt

Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.48 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


# 1.47 14-Mar-2015 deraadt

use ctime_r to avoid a re-entrancy signal race
ok millert


Revision tags: OPENBSD_5_7_BASE
# 1.46 08-Feb-2015 deraadt

in getopt() blocks, stop incrementing flag variable which are supposed
to just be 0/1
ok miod florian


# 1.45 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.44 09-Dec-2014 tedu

init crmsg to something so it doesn't crash on invalid wtmp files.
from david higgs


# 1.43 26-Nov-2014 millert

Prefer setvbuf() to setlinebuf() for portability; ok deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.42 22-Apr-2014 okan

Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and
'tty') from pid stripping, then strip the rest.

idea, feedback and ok millert@


# 1.41 17-Apr-2014 okan

remove special case for uucp entries.

ok guenther


# 1.40 17-Apr-2014 guenther

Correct some time_t printing; factor out a grotty block while here

Based on a diff from Arto Jonsson (ajonsson (at) kapsi.fi)
ok deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.39 22-Aug-2013 guenther

Correct format string mismatches turned up by -Wformat=2

suggestions and ok millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.38 18-Feb-2013 fgsch

Fix after last commit: add missing header.
sthen@ ok.


# 1.37 12-Feb-2013 lum

Reflect the -f option in last's output. Original diff from Jacob L. Leifman.
Other feedback from Callum Davies and sthen@
ok mpi@ ian@ kettenis@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.36 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.35 01-May-2009 chl

add missing header needed by isdigit()

ok otto@ millert@ gilles@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.34 27-Oct-2006 jmc

- simplify and sort synopsis
- sort options
- some minor text tweaks
- sync usage()


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.33 14-Nov-2005 deraadt

fix fd leak; then i got a bit carried away making the code prettier


Revision tags: OPENBSD_3_8_BASE
# 1.32 01-Jul-2005 millert

Replace numeric argument handling (e.g. last -30) with something that
can deal with mixer number and normal arguments, adapted from my code
in diff(1). OK deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.31 16-Jun-2004 millert

Add a new -n option that replaces the old -number option (which now
only exists for backwards compat).
Based on a diff from robert@; OK robert@ and deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.30 08-Jan-2004 otto

Fix uninitialized variable. From Ilya Voronin <ivoronin at trancom dot ru>


# 1.29 09-Nov-2003 otto

Typos in comments from Jared Yanovich <jjy2+ at pitt dot edu>


Revision tags: OPENBSD_3_4_BASE
# 1.28 14-Aug-2003 deraadt

make 9-char login names not stretch the line; millert ok


# 1.27 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.25 29-May-2003 deraadt

avoid more signal races


# 1.24 25-Apr-2003 tedu

minor tweak to error message, from Eric in pr3235


# 1.23 14-Apr-2003 deraadt

fix time spec even better; emmf26@umr.edu


# 1.22 06-Apr-2003 deraadt

make usage exactly like in the man page; andrushock@korovino.net


# 1.21 05-Apr-2003 deraadt

simple snprintf and strlcpy; henning ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 23-Sep-2002 millert

Add missing includes, breaks and semicolons to appease gcc3; David Krause
deraadt@ OK


Revision tags: OPENBSD_3_1_BASE
# 1.19 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.18 04-Feb-2002 mickey

fix a typo; from Sam Smith <S@mSmith.net>


# 1.17 05-Nov-2001 deraadt

mark a zone of signal races


Revision tags: OPENBSD_3_0_BASE
# 1.16 18-Jul-2001 pvalchev

-Wall cleanup


# 1.15 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_9_BASE
# 1.14 06-Feb-2001 fgsch

Change host width to 24 so last produces one line per user; deraadt ok.


# 1.13 31-Jan-2001 deraadt

move utmp to large format, usernames to 32 chars; downsj


# 1.12 12-Dec-2000 deraadt

incorrect time specification; noted by sigh@kuzirabekon.econ.nagasaki-u.ac.jp


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.11 13-Jul-1998 millert

ftpd: sleep for an indeterminate amount for non-existant logins
to simulate a crypt, like login does.
Use SEEK_* not L_* and kill some 0L's used in lseek while we're there.


# 1.10 25-Apr-1998 deraadt

print year; mason@primenet.com.au


Revision tags: OPENBSD_2_3_BASE
# 1.9 10-Mar-1998 downsj

Add -c (for humans) and -s (for machines).


Revision tags: OPENBSD_2_2_BASE
# 1.8 25-Aug-1997 deraadt

incorrect type for variable; enami@but-b.or.jp


# 1.7 21-Aug-1997 deraadt

correct [yy]yy stuff in manpages and usage


# 1.6 25-Jul-1997 mickey

-T to display seconds, from jhawk netbsd-pr#1548


# 1.5 20-Jul-1997 jdm

minor cleanup on the -d flag code


# 1.4 20-Jul-1997 jdm

add -d flag for reporting active sessions at a specified point in time.


Revision tags: OPENBSD_2_1_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.50 29-Oct-2015 deraadt

pledge "stdio rpath".


# 1.49 20-Aug-2015 deraadt

Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert


Revision tags: OPENBSD_5_8_BASE
# 1.48 15-Mar-2015 millert

tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time. This makes the
tree safe for /usr/include/tzfile.h removal. The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree. Actual removal of tzfile.h is pending
a ports build. Based on a diff from deraadt@


# 1.47 14-Mar-2015 deraadt

use ctime_r to avoid a re-entrancy signal race
ok millert


Revision tags: OPENBSD_5_7_BASE
# 1.46 08-Feb-2015 deraadt

in getopt() blocks, stop incrementing flag variable which are supposed
to just be 0/1
ok miod florian


# 1.45 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.44 09-Dec-2014 tedu

init crmsg to something so it doesn't crash on invalid wtmp files.
from david higgs


# 1.43 26-Nov-2014 millert

Prefer setvbuf() to setlinebuf() for portability; ok deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.42 22-Apr-2014 okan

Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and
'tty') from pid stripping, then strip the rest.

idea, feedback and ok millert@


# 1.41 17-Apr-2014 okan

remove special case for uucp entries.

ok guenther


# 1.40 17-Apr-2014 guenther

Correct some time_t printing; factor out a grotty block while here

Based on a diff from Arto Jonsson (ajonsson (at) kapsi.fi)
ok deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.39 22-Aug-2013 guenther

Correct format string mismatches turned up by -Wformat=2

suggestions and ok millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.38 18-Feb-2013 fgsch

Fix after last commit: add missing header.
sthen@ ok.


# 1.37 12-Feb-2013 lum

Reflect the -f option in last's output. Original diff from Jacob L. Leifman.
Other feedback from Callum Davies and sthen@
ok mpi@ ian@ kettenis@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.36 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.35 01-May-2009 chl

add missing header needed by isdigit()

ok otto@ millert@ gilles@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.34 27-Oct-2006 jmc

- simplify and sort synopsis
- sort options
- some minor text tweaks
- sync usage()


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.33 14-Nov-2005 deraadt

fix fd leak; then i got a bit carried away making the code prettier


Revision tags: OPENBSD_3_8_BASE
# 1.32 01-Jul-2005 millert

Replace numeric argument handling (e.g. last -30) with something that
can deal with mixer number and normal arguments, adapted from my code
in diff(1). OK deraadt@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.31 16-Jun-2004 millert

Add a new -n option that replaces the old -number option (which now
only exists for backwards compat).
Based on a diff from robert@; OK robert@ and deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.30 08-Jan-2004 otto

Fix uninitialized variable. From Ilya Voronin <ivoronin at trancom dot ru>


# 1.29 09-Nov-2003 otto

Typos in comments from Jared Yanovich <jjy2+ at pitt dot edu>


Revision tags: OPENBSD_3_4_BASE
# 1.28 14-Aug-2003 deraadt

make 9-char login names not stretch the line; millert ok


# 1.27 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.26 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.25 29-May-2003 deraadt

avoid more signal races


# 1.24 25-Apr-2003 tedu

minor tweak to error message, from Eric in pr3235


# 1.23 14-Apr-2003 deraadt

fix time spec even better; emmf26@umr.edu


# 1.22 06-Apr-2003 deraadt

make usage exactly like in the man page; andrushock@korovino.net


# 1.21 05-Apr-2003 deraadt

simple snprintf and strlcpy; henning ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.20 23-Sep-2002 millert

Add missing includes, breaks and semicolons to appease gcc3; David Krause
deraadt@ OK


Revision tags: OPENBSD_3_1_BASE
# 1.19 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.18 04-Feb-2002 mickey

fix a typo; from Sam Smith <S@mSmith.net>


# 1.17 05-Nov-2001 deraadt

mark a zone of signal races


Revision tags: OPENBSD_3_0_BASE
# 1.16 18-Jul-2001 pvalchev

-Wall cleanup


# 1.15 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_9_BASE
# 1.14 06-Feb-2001 fgsch

Change host width to 24 so last produces one line per user; deraadt ok.


# 1.13 31-Jan-2001 deraadt

move utmp to large format, usernames to 32 chars; downsj


# 1.12 12-Dec-2000 deraadt

incorrect time specification; noted by sigh@kuzirabekon.econ.nagasaki-u.ac.jp


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.11 13-Jul-1998 millert

ftpd: sleep for an indeterminate amount for non-existant logins
to simulate a crypt, like login does.
Use SEEK_* not L_* and kill some 0L's used in lseek while we're there.


# 1.10 25-Apr-1998 deraadt

print year; mason@primenet.com.au


Revision tags: OPENBSD_2_3_BASE
# 1.9 10-Mar-1998 downsj

Add -c (for humans) and -s (for machines).


Revision tags: OPENBSD_2_2_BASE
# 1.8 25-Aug-1997 deraadt

incorrect type for variable; enami@but-b.or.jp


# 1.7 21-Aug-1997 deraadt

correct [yy]yy stuff in manpages and usage


# 1.6 25-Jul-1997 mickey

-T to display seconds, from jhawk netbsd-pr#1548


# 1.5 20-Jul-1997 jdm

minor cleanup on the -d flag code


# 1.4 20-Jul-1997 jdm

add -d flag for reporting active sessions at a specified point in time.


Revision tags: OPENBSD_2_1_BASE
# 1.3 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision