summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* su: don't use kill(0, ...) when propagate signalKarel Zak2014-02-171-1/+1
| | | | | | | | | | | The current code uses kill(0, caught_signal) after regular signal cleanup and before exit (all just to make shells happy). Unfortunately, kill(0, ...) is a bad idea. It seems better to use kill(getpid(), ...) otherwise we kill our parent process too. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1063887 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>
* include/c.h: prefer nanosleep() over usleep()Karel Zak2014-01-241-2/+2
| | | | | | | | | | | | | | Let's use nanosleep() although if usleep() exists. The nanosleep function does no interact with signals and other timers. The patch introduces xusleep() as replacement to libc (or our fallback) usleep(). Yes, we don't want to use struct timespec + nanosleep() everywhere in code as nano-time resolution is useless for us. The patch also enlarges delays in some busy wait loops. It seems enough to try read/write 4x per second. Signed-off-by: Karel Zak <kzak@redhat.com>
* man: Syntax and spelling fixes.Ville Skyttä2014-01-061-1/+1
| | | | Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
* sulogin: use dirent->d_type when scans /devKarel Zak2013-11-121-0/+5
| | | | | | ... it's more effective than call fstatat() for all device. Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh, chfn: add info about non-local support to the man pagesKarel Zak2013-11-112-4/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add info about pam_lastlog to su.1Karel Zak2013-10-211-0/+14
| | | | | References: https://bugzilla.redhat.com/show_bug.cgi?id=1021108 Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: standardize the phrases for --help and --version in all man pagesBenno Schulenberg2013-10-156-11/+11
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* docs: improve grammar, wording and formatting of su man pageBenno Schulenberg2013-10-141-24/+25
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* docs: sort options in last man page alphabeticallyBenno Schulenberg2013-10-141-45/+45
| | | | | | And use the option formatting with macros. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* docs: tweak wording and formatting of last man pageBenno Schulenberg2013-10-141-21/+17Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* last: remove mistaken -F, --fullnames entry from the man pageBenno Schulenberg2013-10-141-3/+0Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: standardize some "cannot read" and "seek failed" error messagesBenno Schulenberg2013-10-092-5/+5
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* su-common: pluralize one messageBenno Schulenberg2013-10-081-1/+3
| | | | | Reported-by: Petr Písař <petr.pisar@atlas.cz> Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* su: fix caught_signal logic and initialize oldact [coverity scan]Karel Zak2013-10-021-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: make analyzers happyKarel Zak2013-10-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: check fstat() return [coverity scan]Karel Zak2013-10-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* nologin: add new commandKarel Zak2013-09-303-0/+135
| | | | | | | Currently it's maintained as distro specific (or people use impolite /bin/false way). Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix lastb symlinkKarel Zak2013-09-271-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: fix man page groff warningKarel Zak2013-09-261-1/+1
| | | | | | tbl:<standard input>:166: column separation specified for last column 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>
* su: fix lastlog and btmp loggingKarel Zak2013-09-091-4/+1Star
| | | | | | | | | | | | | | | | The su(1) logging code mix ups "old" and "new" passwd structs. The result is things like Sep 9 11:50:45 x2 su: (to kzak) kzak on none in /var/log/messages. The right log entry is Sep 9 11:50:45 x2 su: (to root) kzak on pts/3 The bug has been introduced by commit c74a7af17c7a176c358dfaa8e1814786c89ebc14. References: https://bugzilla.redhat.com/show_bug.cgi?id=1005194 Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>
* utmpdump: make IPv6 addresses workSami Kerola2013-08-291-9/+13
| | | | | | | | | | | | (unless bug[s]) This change is backwards compatibile. Earlier binary to text dumps can be converted back to binary, or otherway around. The only thing that will not work are IPv6 addresses that possible earlier conversion had broke. Such conversions resulted with random IPv4 in place of IPv6 address in text format, and original information is gone forever. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last, utmpdump, agetty, wall, write: avoid compatibility hacksSami Kerola2013-08-292-24/+37
| | | | | | | | 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>
* docs: add --time-format to last(1) manual pageSami Kerola2013-08-291-0/+22
| | | | 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>
* docs: add --since and time option formats to last(1) manualSami Kerola2013-08-291-8/+31
| | | | 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-292-2/+11
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: add --present to last(1) manual pageSami Kerola2013-08-291-0/+6
| | | | | | I forgot to update manual after writing this functionality. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: fix typoSami Kerola2013-08-291-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* su: suppress PAM info messages for -c or non-login sessionsKarel Zak2013-08-271-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | The 'Last login:' messages from PAM lastlogin module is unexpected for non-login sessions or when -c <command> executed. For example: $ su - -c id Last login: Wed Jul 24 08:36:28 CEST 2013 from dhcp-25-161.brq.redhat.com on pts/18 uid=0(root) gid=0(root) skupiny=0(root) this makes 'su' useless in scripts. This patch suppress all PAM_TEXT_INFO messages for -c and for non-login session ('-' is not specified) after pam_authenticate() and pam_acct_mgmt(). Note that the new PAM conversation function checks the first message in the msg[] array only. It seems good enough as PAM internally uses pam_info() function that does not use multiple messages for one conv call. References: https://bugzilla.redhat.com/show_bug.cgi?id=987787 Signed-off-by: Karel Zak <kzak@redhat.com>
* last: mention optional arguments in usageKarel Zak2013-08-232-3/+3
| | | | | 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-232-91/+115
| | | | | | | 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>