summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
...
* su: add control structKarel Zak2017-09-183-141/+125Star
| | | | | | | | * setup logindefs loader by function rather than by global pointer * move basic booleans to the su_context struct Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cosmetic changes after indentKarel Zak2017-09-181-50/+34Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix indentionKarel Zak2017-09-181-714/+692Star
| | | | | | | | Yes, I know... this patch is horrible. We all hate this in git history, but the original indention from coreutils has been so crazy... Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh: remove local /etc/shells parsing in favour of getusershell(3)Sami Kerola2017-08-301-80/+18Star
| | | | | | | Less code, less bugs. And if there are bugs at least share them with all other programs that use getusershell(3) from libc. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: be more explicit with -g in man pageKarel Zak2017-08-181-1/+6
| | | | 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>
* vipw: use explicit_bzero() to clear buffer after copySami Kerola2017-08-051-0/+3
| | | | | | | | | | This should make leaking end of /etc/shadow file more unlikely. Notice that there is now way to tell to editors they should ensure none it does not leak any buffers, drop cores, and so on, when editing sensitive data. In short this change is addressing the issue only partially. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: move pamfail.h to auth.cSami Kerola2017-08-051-1/+18
| | | | | | | This removes one small header file, and makes inline function to static to only file it is used in. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Merge branch 'help' of https://github.com/rudimeier/util-linuxKarel Zak2017-07-1010-17/+17
|\ | | | | | | | | | | | | * 'help' of https://github.com/rudimeier/util-linux: setpriv: silence compiler warning misc: consolidate macro style USAGE_HELP_OPTIONS blockdev: correct man page name in --help
| * misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-2910-17/+17
| | | | | | | | | | | | | | | | | | 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>
* | last: condition (secs == 0) - now handled correctlycoastal-hiker2017-07-101-1/+1
| | | | | | | | | | | | | | | | Changed comparison "if (secs > 0)" to "if (secs >= 0)" to handle condition (secs == 0) correctly. Suggestions to improve the less-than-elegant if-else chain are welcome. Signed-off-by: Karel Zak <kzak@redhat.com>
* | last: don't show negative timecoastal-hiker2017-07-101-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under strange circumstances, the output of command 'last reboot' showed the last time as a negative time, with both the hours and the mins value having a minus sign. Example, taken from my workstation: $last reboot [...] reboot system boot 4.4.0-79-generic Wed Jun 14 09:20 - 07:33 (-1:-47) [...] I am aware this should happen only infrequently. Nevertheless, I propose a more robust behaviour: show a minus sign only for the most significant value (days or hours) and show the rest always as positive. In the special case of ((secs < 0) && (secs >= -59)), print mins as "-00". Signed-off-by: Karel Zak <kzak@redhat.com>
* | login: use IPv4 on IPv4-mapping-to-IPv6Karel Zak2017-07-041-1/+8
|/ | | | | | | | | | | | | | | | | | | | | It seems that on some systems (e.g. RHEL7) the libc function getaddrinfo() is not able to translate ::ffff: address to IPv4. The result is 0.0.0.0 host address in the last(1) and utmpdump(1) output. /sbin/login -h "::ffff:192.168.1.7" utmpdump: [7] [03926] [1 ] [user1 ] [pts/1 ] [::ffff:192.168.1.7 ] [0.0.0.0 ] [Thu May 12 17:49:50 2016 ] Not sure if this is about order of the getaddrinfo() results, system configuration or libc version. It's irrelevant for login(1). We have to be robust enough to write usable address to log files everywhere. The solution is to detect IPv4-mapping-to-IPv6 and use IPv4 for utmp. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1296233 Signed-off-by: Karel Zak <kzak@redhat.com>
* login: add --help textRuediger Meier2017-06-271-0/+8
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-272-4/+4
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-278-16/+8Star
| | | | | | | | | | | | 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-266-20/+26
| | | | | | | | | | | | | | 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>
* misc: never use usage(stderr)Ruediger Meier2017-06-262-10/+15
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(ERROR)Ruediger Meier2017-06-261-5/+7
| | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-261-4/+4
| | | | | | | | | | | | | | | | Fixed checkusage.sh warnings: rtcwake: --unknownopt, non-empty stdout rtcwake: --unknownopt, stderr too long: 21 blockdev: --unknownopt, stderr too long: 28 lsipc: --unknownopt, stderr too long: 77 pg: --unknownopt, stderr too long: 23 renice: --unknownopt, stderr too long: 18 sulogin: --unknownopt, stderr too long: 17 write: --unknownopt, stderr too long: 12 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>
* | login: add --help and --versionRuediger Meier2017-06-222-7/+26
| | | | | | | | | | | | | | | | | | | | Also we don't print the usage text on stderr anymore. Note, the usage text could be improved, currently it does not describe any options. I have only added a pointer to the man page. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | misc: remove superfluous null pointer checks for optargRuediger Meier2017-06-222-11/+6Star
|/ | | | | | This is only needed for optional arguments. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: make chown usage more robustKarel Zak2017-06-211-1/+3
| | | | | | | | * add --disable-makeinstall-chown to travis non-root mode * use "if MAKEINSTALL_DO_SETUID" for chown root:root Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: chown before chmod for SUIDsKarel Zak2017-06-201-0/+1
| | | | | | | Make sure SUIDs are really owned by root. Reported-by: L A Walsh <lkml@tlinx.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix ggc-7 fallthrough warningsSami Kerola2017-06-143-5/+5
| | | | | | | | | | | | | | | | | | | (Original patch and commit message edited by Rudi.) gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra. This warning can be silenced by using comment /* fallthrough */ which is also recognized by other tools like coverity. There are also other valid comments (see man gcc-7) but we consolidate this style now. We could have also used __attribute__((fallthrough)) but the comment looks nice and does not need to be ifdef'ed for compatibility. Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652 Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl> Suggested-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix gcc-7 sprintf warnings -Wformat-overflowRuediger Meier2017-06-141-1/+1
| | | | | | | | | | | | | | | | | | | ../login-utils/last.c: In function ‘main’: ../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=] sprintf(path, "/dev/%s", ut->ut_line); ^~ ~~ ../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32 sprintf(path, "/dev/%s", ut->ut_line); ../libblkid/src/devname.c: In function 'probe_one': ../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=] sprintf(path, "/sys/block/%s/slaves", de->d_name); ^~ ../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256 sprintf(path, "/sys/block/%s/slaves", de->d_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chsh: cleanup global_shells usageKarel Zak2017-06-051-26/+39
| | | | | | | | * global variables are always initialized by NULL * it seems we need it as global variable due to libreadline, then use it as global everywhere in the same .c file. Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh: split get_shell_list()Karel Zak2017-06-051-18/+25
| | | | | | | | Let's use two functions is_known_shell() and print_shells() to make the code more readable and to avoid complex semantic of the original get_shell_list(). Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh: make readline completion to propose valid shellsSami Kerola2017-06-051-27/+90
| | | | | | | This is better than default readline completion, that gives paths from current directory onwards. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix some warningsRuediger Meier2017-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sys-utils/prlimit.c: In function 'do_prlimit': sys-utils/prlimit.c:367:16: warning: format '%ju' expects argument of type 'uintmax_t', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Wformat=] printf("<%ju", new->rlim_cur); lib/plymouth-ctrl.c: In function 'open_un_socket_and_connect': lib/plymouth-ctrl.c:88:20: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types] ret = connect(fd, &su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1)); ^ In file included from lib/plymouth-ctrl.c:35:0: /usr/include/sys/socket.h:314:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *' int connect (int, const struct sockaddr *, socklen_t); login-utils/last.c: In function 'list': login-utils/last.c:506:54: warning: pointer targets in passing argument 4 of 'dns_lookup' differ in signedness [-Wpointer-sign] r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6); ^ login-utils/last.c:291:12: note: expected 'int32_t * {aka int *}' but argument is of type 'unsigned int *' static int dns_lookup(char *result, int size, int useip, int32_t *a) ^~~~~~~~~~ In file included from sys-utils/hwclock-cmos.c:92:0: sys-utils/hwclock.h:67:32: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration extern double time_diff(struct timeval subtrahend, struct timeval subtractor); misc-utils/test_uuidd.c: In function 'create_nthreads': misc-utils/test_uuidd.c:187:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] proc->pid, (int) th->tid, th->index)); Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chfn: disable tab completionSami Kerola2017-05-191-0/+1
| | | | | | | The default readline tab completion that offers file listing from current directory does not make any sense in this context. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-3/+6
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* nologin: don't call fstat() after failed open() [coverity scan]Karel Zak2017-05-171-4/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: remove duplicate const declarationSami Kerola2017-05-161-1/+1
| | | | | | | | | login-utils/su-common.c:619:14: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier] const char const **args = xcalloc (n_args, sizeof *args); Regression-from: 71f207a5f598623a539ba825b97a503072c4a1b4 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: remove duplicate includesKarel Zak2017-05-121-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: use getopt_long() to parse optionsSami Kerola2017-05-101-7/+16
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: add missing typeKarel Zak2017-05-091-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn, chsh: use readline(3) to receive user inputSami Kerola2017-05-033-14/+36
| | | | | | | The readline offers editing capabilities while the user is entering the line, unlike fgets(3) and getline(3) that were used earlier. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: reduce vulnerability surfaceSami Kerola2017-05-033-58/+54Star
| | | | | | | | | | | | | Hopefully these changes are unreachable code, but better safe than sorry when dealing with setuid root code that is installed everywhere. Quite obviously the introduced abort() calls protect from impossible inputs. Secondly set all possible data to be read-only in attempt to make it more difficult to alter anything at all. Reference: https://www.securecoding.cert.org/confluence/display/c/DCL00-C.+Const-qualify+immutable+objects Reviewed-by: Petr Vorel <petr.vorel@gmail.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: remove unnecessary variableSami Kerola2017-03-311-3/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: use domain string more carefullyKarel Zak2017-03-131-4/+6
| | | | | | | Use xstrcpy() to explicitly terminate the domain string. Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: prevent OOB read on illegal /etc/hushloginsTobias Stoeckmann2017-03-131-1/+2
| | | | | | | | | If the file /etc/hushlogins exists and a line starts with '\0', the login tools are prone to an off-by-one read. I see no reliability issue with this, as it would clearly need a hostile action from a system administrator. But for the sake of correctness, I've sent this patch nonetheless.
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-202-8/+8
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-206-30/+30
| | | | | | | | | | 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>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* 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>
* su: properly clear child PIDKarel Zak2017-02-011-4/+10
| | | | | Reported-by: Tobias Stöckmann <tobias@stoeckmann.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'shadow-man' of https://github.com/andhe/util-linuxKarel Zak2017-01-203-5/+9
|\ | | | | | | | | | | | | * 'shadow-man' of https://github.com/andhe/util-linux: chsh: use -h as shorthand for --help instead of -u man: chsh(1): add login.defs to SEE ALSO man: chfn(1): add chsh and login.defs to SEE ALSO