summaryrefslogtreecommitdiffstats
path: root/login-utils/utmpdump.c
Commit message (Collapse)AuthorAgeFilesLines
* utmpdump: check ftello() return valueKarel Zak2019-05-161-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-4/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-101-3/+1Star
| | | | | | | | | | | | | | | | | | | | | | * Start the ISO format flags at bit 0 instead of bit 1. * Remove unnecessary _8601 from ISO format flag names to avoid line wrapping and to ease readability. * ISO timestamps have date-time-timzone in common, so move the TIMEZONE flag to bit 2 causing all timestamp masks to have the first three bits set and the last four bits as timestamp 'options'. * Change the 'SPACE' flag to a 'T' flag, because it makes the code and comments more concise. * Add common ISO timestamp masks. * Implement the ISO timestamp masks in all applicable code using the strxxx_iso() functions. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-261-3/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: remove duplicate includesKarel Zak2017-05-121-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: remove unnecessary variableSami Kerola2017-03-311-3/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-6/+6
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: add timegm() portability function to lib/timeutils.cSami Kerola2017-02-031-0/+1
| | | | | | | | | Local timegm() is a replacement function in cases it is missing from libc implementation. Hopefully the replacement is never, or very rarely, used. CC: Ruediger Meier <ruediger.meier@ga-group.nl> Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils: switch to utmpx.hRuediger Meier2016-12-071-5/+5
| | | | | | | | Now the build will fail on many non-Linux systems because utmpx.h is available everywhere but we still use non-POSIX features. We'll fix this next commit. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* utmpdump: code formatting for readabilityRuediger Meier2016-12-071-3/+5
| | | | | | BTW avoid using the defined sizes. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* login-utils: remove _HAVE_UT_TV fallbackRuediger Meier2016-12-071-6/+2Star
| | | | | | | | | | _HAVE_UT_TV is glibc only. Moreover we want to move to utmpx where timeval is standard. Now utmp/subsecond (1173d0a6) should work on all supported systems. CC: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-3/+2Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use iso-8601 timestamp format with subsecond accuracySami Kerola2016-06-261-26/+37
| | | | | | | | | | Newer 'struct utmp' is using 'struct timeval' to represent login and logout times, so include the maximum accuracy to textual utmp format. Notice that this change does not remove support of converting earlier textual formats back to binary. But conversions from binary to former format will no longer be available. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use always UTC-0 timezone in textual outputSami Kerola2016-06-261-3/+3
| | | | | | | | | | | | | | | Converting a time structure from text format that has timezone markup is practically impossible. See reference links for more information. This leads to situation where multiple utmpdump(1) conversions from binary to text and back make timestamps to shift amount of timezone offset to UTC-0. The easiest way to make multiple conversions to work without timeshifts is to always use UTC-0 timezone. Downside of this approach is that the textual format is less human readable than local timestamps would be. Reference: http://www.catb.org/esr/time-programming/#_strptime_3_and_getdate_3 Reference: http://man7.org/linux/man-pages/man3/strptime.3.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | The message "stat failed %s" seems to say that stat() failed to do something, or failed to pass a test, but of course it means that the statting of something failed. So say so. Also make two very similar messages equal to this one. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* utmpdump: don't pass parameter of type "struct utmp" by value [coverity scan]Karel Zak2015-01-291-15/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>
* utmpdump: fix localtime() error handlingRuediger Meier2014-06-111-2/+3
| | | | | | | | | | | If current TZ has no representation of a given time_t then localtime() would return NULL and break the next strftime(). In practice this happens very likely on systems with 64bit time_t when parsing broken binary data. Seen on aarch64 (and probably s390) using our (incompatible) test wtmp data. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* utmpdump: make analyzers happyKarel Zak2013-10-011-1/+1
| | | | 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-291-2/+9
| | | | | | | | 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>
* utmpdump: assigned values are never read [clang-analyzer]Sami Kerola2013-07-091-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: add option to write to a fileSami Kerola2013-04-261-38/+54
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: fix compiler warning [-Wunused-result]Karel Zak2012-07-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use help and version output macrosSami Kerola2012-07-161-4/+4
| | | | | | Done to reduce translation project work. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: remove unused variableSami Kerola2012-07-161-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: cleanup file descriptor usageKarel Zak2012-07-101-14/+18
| | | | | | | | - don't support --follow for stdin at all - inotify based implementation closes the file, so don't close it in main() again Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: encourage users not to follow stdinSami Kerola2012-07-101-1/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use inotify to when following fileSami Kerola2012-07-101-7/+107
| | | | | | Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: fixes based on static analysis [cppcheck]Sami Kerola2012-07-101-10/+1Star
| | | | | | | | | | | [utmpdump.c:82]: (style) The function 'unspace' is never used [utmpdump.c:131]: (style) The scope of the variable 't' can be reduced [utmpdump.c:167]: (warning) scanf without field width limits can crash with huge input data [kzak@redhat.com: - don't use scanf field width limits for integers] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: white space fixSami Kerola2012-07-091-20/+19Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: document optional filename argumentBernhard Voelker2012-07-091-1/+1
| | | | Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* utmpdump: use xalloc.h, minor coding style changesKarel Zak2012-06-291-12/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: cleanup usage()Karel Zak2012-06-291-7/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: add long optionsKarel Zak2012-06-291-3/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: use err.h stuffKarel Zak2012-06-291-25/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: add NLS and closestream supportKarel Zak2012-06-291-6/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: remove dead codeKarel Zak2012-06-291-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: remove libc5 supportKarel Zak2012-06-291-73/+10Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: cleanup comments, funcs definition linesKarel Zak2012-06-291-45/+29Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* utmpdump: new command, merge from sysvinitKarel Zak2012-06-291-0/+316
Signed-off-by: Karel Zak <kzak@redhat.com>