summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* su: add note about ECHO on --ptyKarel Zak2019-03-062-0/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: be sensitive to another SIGCHLD ssi_codesKarel Zak2019-03-061-1/+4
| | | | | | See the same issue for script: 27afe5016842c22d256ea9f88b598d637ca0df84 Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix --pty terminal initializationKarel Zak2019-03-061-13/+12Star
| | | | | | | | | | | | * use proper winsize rather than uninitialized variable (Oops...) * set the current terminal to the raw mode * disable ECHO for non-terminal execution to be compatible with non-pty output Addresses: https://github.com/karelzak/util-linux/issues/767 Signed-off-by: Karel Zak <kzak@redhat.com>
* su/runuser: don't mark --pty as experimental, add it to runuser.1 tooKarel Zak2019-03-042-3/+9
| | | | | | | | | * let's assume that --pty is stable enough that we do not have to remove it ;-) * add --pty to the runuser.1 man page Addresses: https://github.com/karelzak/util-linux/issues/760 Signed-off-by: Karel Zak <kzak@redhat.com>
* last: do not use non-standard __UT_NAMESIZEPatrick Steinhardt2019-03-041-1/+1
| | | | | | | | | | | | | | | In commit b22332dd4 (last: fix wtmp user name buffer overflow [asan], 2019-01-13), we started to make sure that the `ut_user` field of the `utmpx` struct is always NUL-terminated. The implementation makes use of the `__UT_NAMESIZE` define to determine the position of the last character in that array. The problem is that this is a non-standard define that is not necessarily available on non-glibc platforms. As there is no standardized define, we should just use `sizeof`. This fixes compilation on musl libc based systems. Signed-off-by: Patrick Steinhardt <ps@pks.im>
* 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>
* last: fix wtmp user name buffer overflow [asan]Sami Kerola2019-01-131-0/+1
| | | | | | | | Ensure utmp user name field is null terminated. Without that getpwnam() can buffer overflow, when wtmp file is malformed. Addresses: https://github.com/karelzak/util-linux/issues/715 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* login: add support for login.defs(5) LASTLOG_UID_MAXKarel Zak2019-01-112-0/+14
| | | | | | | | | | This new variable allows to keep lastlog file small and filter out things like huge nfsnobody UIDs. The variable is also supported by shadow-utils (adduser, etc.). Addresses: https://github.com/shadow-maint/shadow/pull/142/ Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils/logindefs: clenaup APIKarel Zak2019-01-112-2/+2
| | | | | | The default value should be unsigned if the result is also unsigned... Signed-off-by: Karel Zak <kzak@redhat.com>
* su-common.c: prefer ENV_SUPATH over ENV_ROOTPATHStanislav Brabec2019-01-104-5/+5
| | | | | | | | ENV_SUPATH and ENV_ROOTPATH are equivalent and ENV_ROOTPATH takes precedence in both login and su. It makes no sense. More logical would be precedence of ENV_SUPATH in su and ENV_ROOTPATH in login. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* su-common.c: prefer /etc/default/su over login.defsStanislav Brabec2019-01-101-1/+1
| | | | | | | | | | | | | | | | su(1) documentation says: /etc/default/su command specific logindef config file /etc/login.defs global logindef config file It indirectly indicates that /etc/default/su should take precedence over /etc/login.defs. But the reverse is true. It is not possible to define ENV_PATH in /etc/login.defs and then make su specific customization in /etc/default/su. We need to change read order to match the documented behavior. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* utmpdump: fix word swapping in manual pageCarlos Santos2019-01-081-1/+1
| | | | | | | | | | From The only binary version of the utmp(5) is standardised. To Only the binary version of the utmp(5) is standardised. Change-Id: I0033f6cf055d569c7dfca5e05e918f735ea72582 Signed-off-by: Carlos Santos <casantos@datacom.com.br>
* 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>
* su: cleanup code to copy to log stringsKarel Zak2018-10-031-3/+3
| | | | | | | | man utmp: String fields are terminated by a null byte ('\0') if they are shorter than the size of the field. Signed-off-by: Karel Zak <kzak@redhat.com>
* login: cleanup code to copy to log stringsKarel Zak2018-10-031-12/+12
| | | | | | | | man utmp: String fields are terminated by a null byte ('\0') if they are shorter than the size of the field. Signed-off-by: Karel Zak <kzak@redhat.com>
* last: make sure domain is zero terminatedKarel Zak2018-10-031-9/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add note about merged /usrKarel Zak2018-08-222-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: restore signals after failed exec() onlyKarel Zak2018-08-161-7/+5Star
| | | | | | | | | | | * removes unnecessary variable * the current code restores signals always when shell has not been executed -- this is correct as function sushell() modify signal mask, but in all another cases we do not need touch the mask. Especially when we ask for the password in endless while() loop... Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: do not use plain 0 as NULLKarel Zak2018-08-161-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix man page typosJakub Wilk2018-08-161-1/+1
| | | | Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
* su: add --whitelist-environmentKarel Zak2018-08-153-16/+120
| | | | | | | | | | | | | | | | | | | * usable with --login to whitelist specified environment variables * the list is ignored for the core variables like HOME, SHELL, USER, LOGNAME and PATH (su --login always resets these variables) Note that su(1) requires password and after successful authentication user has full control over the session, so he can set arbitrary environment variables. The whitelist makes things more user friendly only. The patch removes unnecessary optimization when allocate environ[]. It seems better to keep all in glibc hands and just reset the environment array only. Addresses: https://github.com/karelzak/util-linux/issues/221 Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: return 1 on "lslogins nonexisting"Karel Zak2018-08-132-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | 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-132-2/+11
| | | | | | | | | | | | 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>
* man pages: Remove "left" (or change to "l") in the column formats of tablesBjarni Ingi Gislason2018-08-061-1/+1
| | | | | | | | | A developmental version of "groff" issued a warning, for example with "test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z": troff: <logger.1>:299: warning: can't find font 't' Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* su: add note about SIGKILL to the man pageKarel Zak2018-08-031-2/+3
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/443 Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use const qualifier for username from PAM or struct passwd [-Wcast-qual]Karel Zak2018-07-231-6/+11
| | | | | | | | | It seems more robust to use 'const' qualifier for username if this variable points to external resources like PAM or struct passwd. The patch introduces new variable cmd_username for username specified on login(1) command line. 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-232-17/+20
| | | | 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>
* man: Change the only argument to two for the two-fonts macrosBjarni Ingi Gislason2018-05-232-3/+3
| | | | | | | Punctuation marks have been left in the only argument of two-fonts macros, instead of being separated from it to make the second one. Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* man: Use the correct macro for a font change of one argumentBjarni Ingi Gislason2018-05-233-12/+12
| | | | | | | | Use the correct macro (I, B) for the font change of one argument, not those that are used for alternating two fonts, like "BR", "IR", "RB", or "RI". Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* Merge branch 'output-all' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak2018-05-102-0/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'output-all' of https://github.com/kerolasa/lelux-utiliteetit: zramctl: add --output-all option swapon: add --output-all option rfkill: add --output-all option partx: add --output-all option lsns: add --output-all option lsmem: add --output-all option lslogins: add --output-all option lslocks: add --output-all option lscpu: add --output-all option losetup: add --output-all option findmnt: add --output-all option
| * lslogins: add --output-all optionSami Kerola2018-05-032-0/+10
| | | | | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | last: fix false positive compiler warningSami Kerola2018-05-101-1/+1
|/ | | | | | | | | | | | | login-utils/last.c: In function ‘list’: login-utils/last.c:398:36: warning: argument to ‘sizeof’ in ‘strncat’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess] strncat(utline, p->ut_line, sizeof(p->ut_line)); The sizeof(utline) is defined as sizeof(p->ut_line) + 1, so the compiler got that wrong. Lets truncate strncat() otherway around to keep gcc 8.1 happy. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* su: build fix for the case where USE_PTY is not definedSamuel Thibault2018-02-121-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: use errexec()Karel Zak2018-02-011-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* newgrp: use errexec()Karel Zak2018-02-011-4/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: use errexec()Karel Zak2018-02-011-9/+1Star
| | | | | | The new macro is fully compatible with original (coreutils) code. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak2018-01-171-1/+1
| | | | | | | Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: do not let editor to inherit open file descriptorsSami Kerola2017-12-041-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* login: add LOGIN_PLAIN_PROMPT to login.defsKarel Zak2017-12-042-3/+21
| | | | | | | | | | | We have command line option -H to disable hostname in login prompt. Unfortunately, in same cases (e.g. telnetd) it's impossible to specify login(1) command line options due to hardcoded execl()... This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs to suppress hostname in the prompt. Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils: use free_getlogindefs_data()Karel Zak2017-11-282-0/+4
| | | | | | | It seems better to deallocate logindefs.conf stuff in long time running (=waiting) processes like login(1) and su(1). Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typosSami Kerola2017-11-281-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-103-7/+4Star
| | | | | | | | | | | | | | | | | | | | | | * 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>
* lib/timeutils: add get_gmtoff()J William Piggott2017-11-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new function returns the GMT offset relative to its argument. It is used in this patch to fix two bugs: 1) On platforms that the tm struct excludes tm_gmtoff, hwclock assumes a one hour DST offset. This can cause an incorrect kernel timezone setting. For example: Master branch tested with tm_gmtoff illustrates the correct offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494204.192398, -660) Master branch tested without tm_gmtoff has an incorrect offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494249.193852, -690) Patched tested without tm_gmtoff has the correct offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494260.194208, -660) 2) ISO 8601 'extended' format requires all time elements to use a colon (:). Current invalid ISO 8601: $ hwclock 2017-10-08 16:25:17.895462-0400 Patched: $ hwclock 2017-10-08 16:25:34.141895-04:00 Also required by this change: login-utils/last.c: increase ISO out_len and in_len by one to accommodate the addition of the timezone colon. 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>