aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/last/last.c
Commit message (Collapse)AuthorAgeFilesLines
* last(1): fix style after r351459Eugene Grosbein2019-08-251-1/+1
| | | | | | | | | Reported by: cem MFC after: 2 weeks X-MFC-With: 351459 Notes: svn path=/head/; revision=351467
* last(1): correction after r351413Eugene Grosbein2019-08-241-3/+5
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=351459
* last(1): unbreak for 8-bit localesEugene Grosbein2019-08-231-5/+35
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=351413
* Add libxo(3) support to last(1).Philip Paeps2018-08-281-28/+51
| | | | | | | | | | | Reviewed by: kp Approved by: re (gjb) MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16922 Notes: svn path=/head/; revision=338352
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-1/+1
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Fix a memory leak with lastStephen J. Kiernan2017-06-021-1/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=319508
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* Capsicumify last(1)Conrad Meyer2016-12-161-3/+16
| | | | | | | | | Reviewed by: ed (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8001 Notes: svn path=/head/; revision=310139
* Unbreak "last reboot".Ed Schouten2015-07-211-0/+8
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=285742
* Switch batch to an SLIST.Ed Schouten2012-09-121-11/+9
| | | | | | | This code requires none of the features of LIST. Notes: svn path=/head/; revision=240425
* - Replace "wtmp" with "utx.log" because last(1) no longer reads wtmp.Hiroki Sato2012-01-221-5/+5
| | | | | | | | | | | - 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 Notes: svn path=/head/; revision=230458
* Add missing static keywords to last(1)Ed Schouten2011-11-061-20/+20
| | | | Notes: svn path=/head/; revision=227168
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-111-4/+0
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=216370
* Make last(1) display the full log file.Ed Schouten2010-01-191-10/+9
| | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=202643
* Port last(1) to use utmpx.Ed Schouten2010-01-131-101/+82
| | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=202197
* s/FALLTHOUGH/FALLTHROUGH/David Malone2004-08-081-1/+1
| | | | | | | Submitted by: Xin LI <delphij@frontfree.net> Notes: svn path=/head/; revision=133332
* Include timeconv.h for _int_to_time and _time_to_int.David Malone2004-02-151-0/+1
| | | | Notes: svn path=/head/; revision=125856
* Tidy up usage message.Tim J. Robbins2003-08-171-2/+2
| | | | Notes: svn path=/head/; revision=119023
* Add the -n maxrec option as an alias for -maxrec for compatibility withTim J. Robbins2003-07-271-3/+11
| | | | | | | | | | System V and consistency with other utilities. Document the new form instead of the old form in the manual page. PR: 54661 Notes: svn path=/head/; revision=118077
* Fix core dumps when invoking with something like ``last -w1''.Maxime Henrion2002-10-301-5/+4
| | | | | | | | | PR: bin/44583 Reported by: Amit Chakradeo <sdbug@spam.chakradeo.net> MFC after: 3 days Notes: svn path=/head/; revision=106215
* ANSIify function definitions.David Malone2002-09-041-22/+10
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=102944
* Consistently use FBSDIDDavid E. O'Brien2002-06-301-2/+2
| | | | Notes: svn path=/head/; revision=99112
* Clean up malloc(3)'s argument. Remove casts which do nothing when we'reJuli Mallett2002-05-171-5/+5
| | | | | | | | | | 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). Notes: svn path=/head/; revision=96785
* remove __PWarner Losh2002-03-221-10/+10
| | | | Notes: svn path=/head/; revision=92920
* Add a new "-y" flag which causes the year to be included in theIan Dowse2002-03-011-4/+9
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=91541
* Oops, unbreak the -d and -<n> options. The `snapfound' variableIan Dowse2002-03-011-11/+5
| | | | | | | | | 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. Notes: svn path=/head/; revision=91538
* Split up the big wtmp() function to avoid long lines and codeIan Dowse2002-03-011-151/+153
| | | | | | | duplication. Notes: svn path=/head/; revision=91536
* I've been meaning to do this for a while. Add an underscore to theMatthew Dillon2002-01-191-6/+6
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=89572
* localtime() was being called on an int pointer (due to recentMatthew Dillon2001-10-291-6/+13
| | | | | | | utmp-related commits). fixed. Notes: svn path=/head/; revision=85648
* Document -d in usage.Dima Dorfman2001-08-051-1/+2
| | | | | | | Submitted by: Martin Kammerhofer <mkamm@sbox.tu-graz.ac.at> Notes: svn path=/head/; revision=81161
* Silence warnings and minor style fixes. Mostly constify and don'tDima Dorfman2001-06-141-9/+11
| | | | | | | | | assume that time_t is a long. Clamp down with WARNS=2. Not objected to by: -audit Notes: svn path=/head/; revision=78201
* The last(1) choked if there were two successive "login" marksRuslan Ermilov2001-05-281-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=77328
* Implement snapshots. The new -d option allows the user to find outDima Dorfman2001-05-281-68/+173
| | | | | | | | | who was logged in at a certain time and date. Obtained from: OpenBSD Notes: svn path=/head/; revision=77291
* Don't attempt to parse %cAndrey A. Chernov2001-03-211-17/+33
| | | | Notes: svn path=/head/; revision=74588
* Used macro-API to <sys/queue.h>.Poul-Henning Kamp2000-12-291-13/+13
| | | | | | | Submitted by: ben Notes: svn path=/head/; revision=70467
* getopt and friends are declared in <unistd.h>Warner Losh2000-09-041-2/+0
| | | | | | | getopt returns -1 not EOF. Notes: svn path=/head/; revision=65428
* Don't call printf with no format string.Kris Kennaway2000-07-101-1/+1
| | | | Notes: svn path=/head/; revision=62871
* Back out the previous change to the queue(3) interface.Jake Burkholder2000-05-261-2/+2
| | | | | | | | | It was not discussed and should probably not happen. Requested by: msmith and others Notes: svn path=/head/; revision=60938
* Change the way that the queue(3) structures are declared; don't assume thatJake Burkholder2000-05-231-2/+4
| | | | | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd Notes: svn path=/head/; revision=60833
* Reviewed by: Peter Hawkins <thepish@FreeBSD.org>Daniel O'Callaghan1998-05-281-11/+32
| | | | | | | Add s and w flags to show duration in or with seconds. Notes: svn path=/head/; revision=36434
* Change variable from long to time_t where they are passed by referenceJohn Birrell1998-05-151-2/+3
| | | | | | | to time(). Notes: svn path=/head/; revision=36062
* Add the year to the 'wtmp begins...' line.Steve Price1998-05-031-2/+2
| | | | | | | | PR: 6421 Submitted by: phk Notes: svn path=/head/; revision=35658
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-291-1/+1
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24360
* Remove one space to produce the same output alignmentAndrey A. Chernov1996-12-051-3/+3
| | | | | | | like in who, rwho, w, etc. Notes: svn path=/head/; revision=20158
* Don't dereference a free()ed pointer.Joerg Wunsch1996-10-281-3/+5
| | | | | | | Closes PR bin/1909: 'last' coredumps if MALLOC_OPTIONS... Notes: svn path=/head/; revision=19223
* Localize timeAndrey A. Chernov1996-06-171-14/+27
| | | | Notes: svn path=/head/; revision=16438
* Fixed a bug that caused last(1) to be extremely slow in some cases, andDavid Greenman1995-10-171-83/+78
| | | | | | | | | | | | 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). Notes: svn path=/head/; revision=11547
* Delete bogus referneces to timezone code internal header file `tzfile.h',Garrett Wollman1995-08-071-3/+2
| | | | | | | which is no longer bogusly installed in /usr/include. Notes: svn path=/head/; revision=9987
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+420
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590