summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
Commit message (Collapse)AuthorAgeFilesLines
* lslogins: Fix discrepancies of SYS_UID_MINStanislav Brabec2019-04-241-1/+1
| | | | | | | | | | | | | | | | | | | | util-linux does not contain useradd. Its most popular implementation comes from shadow. SYS_UID_MIN is one of common parameters. Its hardcoded fallback value is equal to 101 in shadow useradd (see shadow-4.6/libmisc/find_new_uid.c: get_ranges()), but 201 in login-utils/lslogins.c. Let lslogins use the same fallback as useradd from shadow. Hopefully most distros define its custom value of SYS_UID_MIN in /etc/login.defs, so this problem is not visible. login-utils/lslogins.1 does not mention its default at all. Add a reference and improve text of lslogins(1) to prevent off-by-one interpretation. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix typos [codespell]Sami Kerola2019-02-181-1/+1
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: make valid_pwd() more robustKarel Zak2018-12-111-2/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: remove duplicate NULL checkSami Kerola2018-12-101-1/+1
| | | | | | | | | | | Having this excess NULL check in place causes small performance penalty, and makes compiler to guess wrong if a null should be checked. To me getting rid of false positive warning is more useful. login-utils/lslogins.c:634:7: warning: potential null pointer dereference [-Wnull-dereference] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: return 1 on "lslogins nonexisting"Karel Zak2018-08-131-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The default behavior for -l and -g is to silently ignore unknown login names, but this is very confusing when you explicitly specify just one login name. Note that the current implementation also prints empty "Last log" for nonexisting user. It seems ugly. # lslogins nonexisting Last logs: new version: # lslogins nonexisting lt-lslogins: cannot found 'nonexisting' # echo $? 1 The -l and -g behaviour has not been changed. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614967 Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: add info about single-user output modeKarel Zak2018-08-131-1/+1
| | | | | | | | | | | | The supported command line synopsis is also lslogins foo and it provides different output than lslogins -l foo Signed-off-by: Karel Zak <kzak@redhat.com>
* setterm: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: remove redundant conditionKarel Zak2018-07-181-1/+1
| | | | | | | [util-linux-2.32.1/login-utils/lslogins.c:601]: (style) Redundant condition: If '!EXPR', the comparison 'EXPR != '$'' is always true. Reported-by: David Binderman <dcb314@hotmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: add -o+<COLNAME> supportKarel Zak2018-05-231-16/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: add PWD-METHOD columnKarel Zak2018-05-231-1/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: fix password verificationKarel Zak2018-05-231-4/+74
| | | | | | | | | | | Let's follow the standard $id$salt$encrypted password format in verification code. The current code is useless and for example PWD-LOCK column is always FALSE. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1581611 Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: add --output-all optionSami Kerola2018-05-031-0/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-101-3/+2Star
| | | | | | | | | | | | | | | | | | | | | | * 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>
* lslogins: fix possible memory leak [coverity scan]Karel Zak2017-10-111-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: ignore non-existing usersKarel Zak2017-08-181-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.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>
* Merge branch '170622' of github.com:jwpi/util-linuxKarel Zak2017-06-261-4/+2Star
|\ | | | | | | | | | | | | | | * '170622' of github.com:jwpi/util-linux: Docs: move option naming to howto-contribute.txt Docs: update howto-usage-function.txt Docs: add a comment for constants to boilerplate.c include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
| * include/c.h: add USAGE_COMMANDS and USAGE_COLUMNSJ William Piggott2017-06-241-4/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | * login-utils/lslogins.c: all uses changed * misc-utils/findmnt.c: likewise * sys-utils/blkzone.c: likewise * disk-utils/sfdisk.c: likewise * sys-utils/lscpu.c: likewise * sys-utils/lsmem.c: likewise * sys-utils/wdctl.c: likewise Signed-off-by: J William Piggott <elseifthen@gmx.com>
* | misc: remove superfluous null pointer checks for optargRuediger Meier2017-06-221-9/+6Star
|/ | | | | | This is only needed for optional arguments. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-3/+6
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* 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-13/+13
| | | | | | | | 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>
* lslogins: remove useless strlen()Ruediger Meier2016-12-071-6/+2Star
| | | | | | | | | | strlen() is not smarter than strncpy(). Bytes that follow a null byte are not compared anyway. BTW avoid using the defined sizes. CC: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix unsigned int usage for ctype.h functionsKarel Zak2016-10-261-1/+1
| | | | | Reported-by: "Yuriy M. Kaminskiy" <yumkam@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix declarations shadowing variables in the global scope [oclint]Sami Kerola2016-07-211-3/+3
| | | | | | Fixes multiple occurences of 'optarg' overwrites. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: simplify if clause and move definition and comments [oclint]Sami Kerola2016-07-211-11/+9Star
| | | | | | | | The if clause change is pretty trivial. Moving the macro near to where it is used makes sense to people who want to read the code. And finally the comment about user list was at wrong spot. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* lslogins: use strtime_short()Karel Zak2016-05-241-31/+19Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: use strtm_iso()Karel Zak2016-05-241-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-071-1/+1
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: fix getgrouplist() usage for 64BEKarel Zak2015-12-211-4/+8
| | | | | | | | | | | | | | on ppc64: $ lslogins kzak $ lslogins: cannot allocate 85899345920 bytes: Cannot allocate memory because (int *) len where len is pointer to size_t is bad idea... Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: remove duplicate [make checkincludes]Karel Zak2015-07-291-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: merge read_utmp() codeKarel Zak2015-07-161-2/+32
| | | | | | | The code is used only in lslogins, so it does not make sense to maintain it in libcommon. Signed-off-by: Karel Zak <kzak@redhat.com>
* maint: fix shadow declarationSami Kerola2015-01-071-16/+16
| | | | | | | | | | | | | | | | This change fixes all shadow declarations. The worth while to mention fix is with libfdisk sun geometry. It comes from bitops.h cpu_to_be16 macro that further expands from include/bits/byteswap.h that has the shadowing. libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow] libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow] That could have caused earlier some unexpected results. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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>
* lslogins: use hardcoded paths from pathnames.hSami Kerola2014-12-191-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: add space to systemd journal header and messageSami Kerola2014-12-191-10/+7Star
| | | | | | | | | | This commit changes journal messages in individual user printout the following way. Dec 13 16:02:05 systemd[324]:Time has been changed (old) Dec 13 16:02:05 systemd[324]: Time has been changed (new) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: reject unknown time format argumentsSami Kerola2014-12-191-21/+19Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: fix short optionsSami Kerola2014-12-191-3/+2Star
| | | | | | | | | | Usage is promising -e is an option alias of --export, so make it work. And get rid of -x that was accepted, but not in use. Long only enum member OPT_VER was probably a development time idea, that never got to be used. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: tell why command failedSami Kerola2014-12-191-1/+1
| | | | | | Printing usage() without hint what is wrong does not help an user. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: make journald last logs time stamps to honor --time-formatSami Kerola2014-12-191-4/+3Star
| | | | | | This makes by default the last logs to have year in output when necessary. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: allow changing password changed and expiration time formatsSami Kerola2014-12-191-2/+8
| | | | | | | | | | The password change and expiry has are marked with resolution of a day, so add a new short iso-8601 format. With this system admins can easily find users has not updated their password lately $ lslogins --time-format=iso --user --output=pwd-change,user | sort -n Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: fix -l -g logicKarel Zak2014-12-121-30/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: align usage() and manual with struct option longoptsSami Kerola2014-12-091-2/+1Star
| | | | | | | | Short option -G goes together with long option --supp-groups, while neither of -m or --groups-info has worked in a release so remove them from usage() and manual. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: fix assertion failure for none existing loginsSami Kerola2014-12-091-1/+1
| | | | | | | | | | | This cange makes the following to retun none-zero value instead of a core dump. $ lslogins qwertyuiopasdfghjklzxcvbnm1234567 lslogins: libsmartcols/src/line.c:362: scols_line_get_cell: Assertion `ln' failed. Aborted (core dumped) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use manual tail usage() macroSami Kerola2014-10-011-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: cleanup after error [coverity scan]Karel Zak2014-09-261-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>