summaryrefslogtreecommitdiffstats
path: root/login-utils/last.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* last: stop usig MAXHOSTNAMELENKarel Zak2012-10-191-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: use min() from c.hKarel Zak2012-05-231-12/+8Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: add deprecation commentsSami Kerola2012-03-181-0/+9
| | | | | | | Markup deprecation to command header to avoid people wasting time in fixing these utilities. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix few compiler warningsSami Kerola2011-11-291-3/+3
| | | | | | | | | | | | | | Calling abort() as default seems appropriate as the default should be impossible to reach. last.c:355:3: warning: switch missing default case [-Wswitch-default] And simple line removals. last.c:110:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls] last.c:111:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: possible buffer overflow fixed [smatch scan]Sami Kerola2011-11-291-1/+1
| | | | | | last.c +447 ttyconv(11) error: buffer overflow '(arg)' 3 <= 3 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix smatch warningSami Kerola2011-09-101-1/+1
| | | | | | login-utils/last.c +447 ttyconv(11) error: buffer overflow '(arg)' 3 <= 3 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* last: Use EXIT_* and err()Marek Polacek2010-12-101-19/+23
| | | | Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
* last: use xalloc libDavidlohr Bueso2010-11-301-12/+4Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* use _exit() instead of exit() in sighandlersMarek Polacek2010-10-291-1/+1
| | | | Signed-off-by: Marek Polacek <mmpolacek@gmail.com>