summaryrefslogtreecommitdiffstats
path: root/login-utils/last.c
Commit message (Collapse)AuthorAgeFilesLines
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* build-sys: move all around clock_gettime() to monotonic.cKarel Zak2014-11-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: improve code readability by renaming variable namesSami Kerola2014-09-191-11/+14
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: make is_phantom() when kernel config does not include audit supportSami Kerola2014-09-191-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | When kernel CONFIG_AUDIT is not set the /proc/<pid>/loginuid information is not present resulting live sessions to be marked 'gone - no logout' in last(1) print out. To go-around this change makes last(1) to look /dev/<tty> device ownership as a substitute of loginuid. The go-around seems to work fairly well, but it has it short comings. For example after closing a X window session the /dev/ttyN file seems to be owned by root, not the user who had it before entering to the X session. While that is suboptimal it is still better than an attmempt to determine uid_t by looking owner of the /proc/<struct utmp ut_pid>, that is a login(1) process running as root. The issue was found using Archlinux installation. $ pacman -Qi linux Name : linux Version : 3.16-2 [...] Build Date : Mon Aug 4 18:06:51 2014 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: fix some typos and inconsistencies in various messagesBenno Schulenberg2014-07-231-3/+3
| | | | | | | | Fixing plain typos, miswordings, inconsistent periods, some missing angular brackets, and a proper pluralization (even when it involves a constant, because for some languages the precise value matters). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* last: fix is_phantom() logic [coverity scan]Karel Zak2014-07-171-4/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: fix some typosSami Kerola2014-07-131-1/+1
| | | | | | | Found with misspell-check version 2.0d. Reference: https://github.com/lyda/misspell-check Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: avoid leading "-" before "no logout"Ruediger Meier2014-05-101-1/+4
| | | | | | This affects option --time-format=notime. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* last: minor cleanup if statementsRuediger Meier2014-05-081-6/+6
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* last: --time-format=full should do the same like -FRuediger Meier2014-05-081-8/+4Star
| | | | | | | | | | | | | | | | | | | | | | | | | For no reason "full" did something else than "iso" or -F as you see here: $ ./last -f ../tests/ts/last/wtmp.LE --time-format=full | grep -A2 "no logout" torvalds linux hobby Mon Aug 26 02:57:08 1991 gone - no logout reboot system boot system-name Wed Aug 28 20:00:00 2013 still running reboot system boot system-name Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013 (01:00) $ ./last -f ../tests/ts/last/wtmp.LE --time-format=iso | grep -A2 "no logout" torvalds linux hobby 1991-08-26T02:57:08+0200 gone - no logout reboot system boot system-name 2013-08-28T20:00:00+0200 still running reboot system boot system-name 2013-08-28T18:00:00+0200 - 2013-08-28T19:00:00+0200 (01:00) $ ./last -f ../tests/ts/last/wtmp.LE -F | grep -A2 "no logout" torvalds linux hobby Mon Aug 26 02:57:08 1991 gone - no logout reboot system boot system-name Wed Aug 28 20:00:00 2013 still running reboot system boot system-name Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013 (01:00) Also note the useless leading space before "gone" The only thing which matters is fmt->out width when printing these strings like "still running". Now ctl->fulltime flag is unsused and removed. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* last: fix uninitialized lengthRuediger Meier2014-05-071-2/+3
| | | | | | length was unset when using "last --time-format=iso" Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib/timeutils: remove get_boot_time from libcommonKarel Zak2014-05-061-0/+1
| | | | | | | | clock_gettime() needs -lrt, so let's keep this stuff outside libcommon.la Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* last: fix is_phantom() detectionSami Kerola2014-05-041-4/+11
| | | | | | | | | | | | | The /proc/<pid>/loginuid is not always available, and when so a running session should not be determined to be gone. This is a regression from commit mentioned in reference. Sessions that have started before previous system boot, and did not log out meanwhile, will be marked as gone. It is fair to say that these sessions are most likely result of a wtmp corruption. Reference: 404fa3f93c00c7e130f5a0ec963b2dc6a3743986 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include/carefulputc: cleanup and add fputs_{quoted,nonblank}()Karel Zak2014-04-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: make session gone determination more robustSami Kerola2014-02-101-3/+22
| | | | | | | | | | | | Earlier determination that used kill with signal zero to pid was prone to false positive reports, due reuse of pid space and unrelated processes. New function is_phantom() tries do a little bit better job, but fails to be perfect. It seems linking to gether utmp session start time or terminal id with /proc/<pid>/ information is not as simple as one might hope. Reported-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: standardize some "cannot read" and "seek failed" error messagesBenno Schulenberg2013-10-091-4/+4
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* last: check fstat() return [coverity scan]Karel Zak2013-10-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: rename time-util.c to timeutils.c, fix headersKarel Zak2013-09-101-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: fix memory leakSami Kerola2013-09-101-0/+4
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: --fulltime and --time-format are mutually exclusiveKarel Zak2013-09-021-1/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: consolidate time formatting to one structKarel Zak2013-09-021-23/+22Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: use bit arrayKarel Zak2013-09-021-16/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last, utmpdump, agetty, wall, write: avoid compatibility hacksSami Kerola2013-08-291-22/+28
| | | | | | | | In include/bits/utmp.h the ut_user and ut_time macros are marked with comment they are backwards compatibility hacks. It is probably best to avoid use of these macros where ever possible. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: tell verbally system is still runningSami Kerola2013-08-291-2/+11
| | | | | | | | | Use of uptime time stamp as previous boot login time makes the output not constant, which is rather difficult to test. Verbal message 'system is still running' makes testing easy, and noticing which boot is still running clear to a person. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: trim trailing white spacesSami Kerola2013-08-291-0/+18
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: never restrict session timeSami Kerola2013-08-291-2/+2
| | | | | | | When a session time will reach whopping 10000 days the last round bracket is unnecessarily removed from output. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: add --time-format with iso-8601 formatSami Kerola2013-08-291-23/+111
| | | | | | | | | The ISO-8601 format makes consuming time stamps easy with various parsers. The format includes time zone information which is crucial when an investigator is trying to make sense outputs collected from systems all a across planet. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: use configuration structSami Kerola2013-08-291-98/+113
| | | | | | | | This allows reducing global variables and will minimize number of arguments for functions making code a little bit easier to read, and maintain. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix --present option logic errorSami Kerola2013-08-291-1/+1
| | | | | | | Printing of sessions 'still logged in' was skipped because an error in logic. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: add --since time spec optionSami Kerola2013-08-291-6/+20
| | | | | | The --since and --until options are companions often needed together. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/time-util: move YYYYMMDDHHMMSS to common parserSami Kerola2013-08-291-45/+0Star
| | | | | | | | | Even while the YYYYMMDDHHMMSS time format it not magnificent it is best to make it to be part of the one, and only, time format parser. Proposed-by: Karel Zak <kzak@redhat.com> References: http://markmail.org/message/6baqt4ttkopu7ra6 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: parse easy to use time formatsSami Kerola2013-08-291-2/+10
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix typoSami Kerola2013-08-291-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: mention optional arguments in usageKarel Zak2013-08-231-1/+1
| | | | | Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* last: add --present optionSami Kerola2013-08-231-11/+24
| | | | | | | The --present option will allow user to easily determine who where logged in at a given time. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: allow --file to be defined multiple timesSami Kerola2013-08-231-91/+111
| | | | | | | This is useful when an admin is trying to find something, and has to process all available data. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: global variables are initialize automatically to zeroSami Kerola2013-08-231-6/+6
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: use as narrow variable scoping as possibleSami Kerola2013-08-231-1/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: remove broken codeSami Kerola2013-08-231-36/+0Star
| | | | | | | | | | | Comment in the deletion tells everything necessary. "This doesn't work on modern systems, where only a DNS lookup of the result from hostname() will get you the domainname. Remember that domainname() is the NIS domainname, not DNS. So basically this whole piece of code is bullshit." Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: prefer enum rather than #definition listSami Kerola2013-08-231-7/+9
| | | | | | | Incremental number lists are more hard to get wrong with enum, and they are nicer to debug as for example gdb is aware of these symbolic names. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: make switch cases complete, and inform if impossible occursSami Kerola2013-08-231-0/+11
| | | | | | | | | | Some of the ut_type numbers does not seem to be recognized by last(1) so they are, at least for now, silently ignored. See glibc documentation for information what the ignored EMPTY, INIT_PROCESS, LOGIN_PROCESS, and ACCOUNTING mean. Reference: FIXME Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: check expected numeric user input is numberSami Kerola2013-08-231-3/+4
| | | | | | | This commit also changes the line count to use unsigned integers, as negative numbers in this context does not make sense. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: use carefulput() for printable character outputSami Kerola2013-08-231-6/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: coding style clean upKarel Zak2013-08-131-247/+255
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: use xalloc.h, err.h, nls.h and EXIT_ macrosKarel Zak2013-08-121-63/+21Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: consolidate btmp/wtmp file pathsKarel Zak2013-08-121-24/+4Star
| | | | | | .. so share the paths with another utils. Signed-off-by: Karel Zak <kzak@redhat.com>
* last: add long options, improve usage()Karel Zak2013-08-121-12/+60
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: clean up the begin of the fileKarel Zak2013-08-121-31/+21Star
| | | | | | .. and improve last(1) stuff in configure script. Signed-off-by: Karel Zak <kzak@redhat.com>
* last: merge sysvinit last/lastbOndrej Oprala2013-08-121-415/+783
| | | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>