summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2013-09-10lib: rename time-util.c to timeutils.c, fix headersKarel Zak6-4/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10hexdump: revert global exitval variable changeSami Kerola3-5/+6
The change f2a037fb7b153954d5d34cca48182b6d8832fcfa had unfavorable effect of making hexdump to return non-zero exit value always. This happen because oversight when 'exitval' gets to be set. By clance, one might expect main() to call next() which will return value for 'exitval'. That assessment misses later call chain main() -> display() -> get() -> next(), which in reverse should return correct value for 'exitval'. It was mentioned in util-linux maillist that Ondrej Oprala is working on major renewal of the hexdump . That in mind it seems best to simply to revert the global 'exitval' and avoid conflict with Ondrej's work. Reference: http://markmail.org/message/sbnvuhkboreujj5p Reported-by: Dave Reisner <d@falconindy.com> CC: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-10tools: generate autotools files if missingSami Kerola1-0/+4
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-10last: fix memory leakSami Kerola1-0/+4
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-10lib/strutils: optimalize {starts,ends}with()Karel Zak2-69/+40
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-09su: fix lastlog and btmp loggingKarel Zak1-4/+1
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>
2013-09-09agetty: cleanup debug ifdefsKarel Zak1-5/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02last: --fulltime and --time-format are mutually exclusiveKarel Zak1-1/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02last: consolidate time formatting to one structKarel Zak1-23/+22
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02last: use bit arrayKarel Zak1-16/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-29tests: check last(1) and utmpdump(1) IPv6 functionalitySami Kerola9-0/+115
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29utmpdump: make IPv6 addresses workSami Kerola1-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>
2013-08-29last, utmpdump, agetty, wall, write: avoid compatibility hacksSami Kerola5-27/+44
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>
2013-08-29last: tell verbally system is still runningSami Kerola2-7/+16
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>
2013-08-29last: trim trailing white spacesSami Kerola2-2/+20
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29tests: add last(1) testSami Kerola4-0/+184
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29last: never restrict session timeSami Kerola1-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>
2013-08-29docs: add --time-format to last(1) manual pageSami Kerola1-0/+22
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29last: add --time-format with iso-8601 formatSami Kerola1-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>
2013-08-29last: use configuration structSami Kerola1-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>
2013-08-29last: fix --present option logic errorSami Kerola1-1/+1
Printing of sessions 'still logged in' was skipped because an error in logic. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29docs: add --since and time option formats to last(1) manualSami Kerola1-8/+31
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29last: add --since time spec optionSami Kerola1-6/+20
The --since and --until options are companions often needed together. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29lib/time-util: move YYYYMMDDHHMMSS to common parserSami Kerola2-45/+7
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>
2013-08-29last: parse easy to use time formatsSami Kerola2-2/+11
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29lib/strutils: move *swith() functions to private librarySami Kerola7-94/+73
Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29lib/time-util: copy time parsing functions from systemdSami Kerola4-0/+445
The functions are copied nearly as-is. Coding style has been modified to match with util-linux project, while the functionality remains untouched. CC: Lennart Poettering <lennart@poettering.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29write: change determination can user write to a terminalSami Kerola1-4/+5
Earlier test failed when user had write permission, but was not in special group that owns terminal devices, usually tty. This made write(1) to fail for root, if the root did not happen to be in tty group. In this commit root is granted ot write to anyone, even if they have mesg(1) turned off. For an user who is trying to write to own other session the group write bit is significant only for whether mesg(1) are enabled. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29docs: add note to wall(1) about sessions which will not get messageSami Kerola1-0/+6
Sessions that has in utmp data ut_line begining with ':' are skipped. This is done to avoid write errors to devices such as '/dev/:0'. For example wdm is reported to to generate such utmp line. Perhaps in future this code should be revalidated. If an utmp data contains broken device lines it might be best inform user with a error message, rather than skipping silently suspicious device entries. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29docs: add --present to last(1) manual pageSami Kerola1-0/+6
I forgot to update manual after writing this functionality. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29wall: line wrap at column 79 also when line has tab charsSami Kerola1-0/+2
Earlier tabs caused random ragged right indentation, because the tab length was assumed to be 1 char which is not the case most of the time. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29mesg: sync usage() with howto-usage-function.txtSami Kerola1-8/+7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29wall: sync usage() with howto-usage-function.txtSami Kerola1-11/+10
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29last: fix typoSami Kerola1-1/+1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29wall: send message also to sessions opened by user 'sleeper'Sami Kerola1-4/+1
Ignoring an user by name, and not telling about it in manual page, is unexpected. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29build-sys: pylibmount will not work when python3 is presentSami Kerola1-0/+6
While compiling with up to date Archlinux I notice the recently added pylibmount does not link correctly. Failures inform fundamental types such as PyFileObject and PyFile_Type being missing. It seems automake AM_PATH_PYTHON will prefer the python in path, which for this distribution right now is python3. As some sort of go-around one can install older python, and symlink it to earlier in PATH lookup. $ ln -s /usr/bin/python2 $HOME/bin/python $ export PATH=$HOME/bin:$PATH Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-27su: suppress PAM info messages for -c or non-login sessionsKarel Zak1-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>
2013-08-27build-sys: add CFLAGS and LDFLAGS for daemons and shared libsKarel Zak6-7/+27
This is necessary for paranoid security guys who believe that things like "-Wl,-z,relro" or "-Wl,-z,bind_now" is a way how to make the world a safer place... Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-26tests: minor changes to make tests more portableKarel Zak4-2/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-23swapon: cleanup man pageKarel Zak1-33/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-23swapon: allow a more flexible swap discard policyRafael Aquini2-28/+89
Introduce the necessary changes to swapon(8) allowing a sysadmin to leverage the new changes introduced to sys_swapon by "swap: discard while swapping only if SWAP_FLAG_DISCARD_PAGES", therefore allowing a more flexible set of choices when selection the discard policy for mounted swap areas. This patch introduces the following optional arguments to the already existent swapon(8) "--discard" option, in order to allow a discard type to be selected at swapon time: * once : only single-time area discards are issued. (swapon) * pages : discard freed pages before they are reused. If no policy is selected both discard types are enabled. (default) [kzak@redhat.com: - support <policy> argument for short -d option too, - add errx() on unsupported policy name] Signed-off-by: Rafael Aquini <aquini@redhat.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-23last: mention optional arguments in usageKarel Zak2-3/+3
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-23last: add --present optionSami Kerola1-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>
2013-08-23last: allow --file to be defined multiple timesSami Kerola2-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>
2013-08-23last: global variables are initialize automatically to zeroSami Kerola1-6/+6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23last: use as narrow variable scoping as possibleSami Kerola1-1/+2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23last: remove broken codeSami Kerola1-36/+0
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>
2013-08-23last: prefer enum rather than #definition listSami Kerola1-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>
2013-08-23last: make switch cases complete, and inform if impossible occursSami Kerola1-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>
2013-08-23last: check expected numeric user input is numberSami Kerola2-4/+5
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>