summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* login: fix signal raceTobias Stoeckmann2017-09-261-7/+12
| | | | | | | | | | | The functions warnx(3) and gettext(3) are not safe to use within signal handlers and should be avoided. Preparing the message beforehand and calling write(2) as well as calling _exit(2) solves the problem. [kzak@redhat.com: - use program_invocation_short_name rather than argv[0], - use ignore_result() to keep compiler happy] Signed-off-by: Karel Zak <kzak@redhat.com>
* su: (pty) improve SIGSTOP/SIGCONT semanticKarel Zak2017-09-181-2/+24
| | | | | | | | | | | | | We want to use waitpid() only when child is terminated or stopped to pick up child status, otherwise PTY proxy has to be active. This is difference between "su" and "su --pty". For "su" we keep parent all time in waitpid(). It would be possible to use separate code based on signalfd_siginfo, but it seems better to keep all this stuff on one place -- it means wait_for_child(). Signed-off-by: Karel Zak <kzak@redhat.com>
* su: (pty) save child statusKarel Zak2017-09-181-1/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: (pty) simplify stdin usage in poll()Karel Zak2017-09-181-7/+4Star
| | | | | | | | Not sure why I have problem with this years ago for script(1), but it seems .fd=-1 is really enough to the ignore the FD. Reported-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* su: (pty) fix slave terminal attributes initializationKarel Zak2017-09-181-1/+1
| | | | | Reported-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* su: (pty) fix child signal mask usageKarel Zak2017-09-181-3/+6
| | | | | | | | | | | The signal mask is used by pty_init_slave(), but it has never been uninitialized before fork(), so child gets 0 as a mask :-( Note that script(1) has no this issue because it opens signal-fd before fork(). Reported-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* runuser: fix linkingSami Kerola2017-09-181-0/+3
| | | | | | | | | | Add conditional -lutil to runuser when needed to avoid linking error. login-utils/su-common.o: In function `pty_create': login-utils/su-common.c:269: undefined reference to `openpty' login-utils/su-common.c:273: undefined reference to `openpty' Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* su: fix non-pty compilationKarel Zak2017-09-181-10/+9Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: enable TIOCSCTTY and minor changesKarel Zak2017-09-181-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add more informartion to man pageKarel Zak2017-09-181-2/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add PTY supportKarel Zak2017-09-182-45/+429
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add --pty optionKarel Zak2017-09-182-1/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: move parent signals setup to separate functionKarel Zak2017-09-181-26/+33
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: make wait_for_child() usable in arbitrary situationKarel Zak2017-09-181-12/+14
| | | | | | | For example if called more than once; to keep PTY code simple and robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* su: keep old sigactions in control structKarel Zak2017-09-181-15/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix refactoring bug in child PID usageKarel Zak2017-09-181-3/+4
| | | | | | Fix child pid cleanup according to commit 0076012563ff34e294a6166d605118bcdd35f7e1. Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add child to control structKarel Zak2017-09-181-17/+16Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix compiler warnings [-Wimplicit-fallthrough=]Karel Zak2017-09-181-10/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add wait_for_child()Karel Zak2017-09-181-34/+42
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: unblock signals is all initializedKarel Zak2017-09-181-10/+26
| | | | | | | | | | | This patch a little bit reorders signals initialization. The original code unblocks SIGINT SIGQUIT before signal handler is set for the signals. It means there is a small possible race. It seems better to compose wanted mask, setup handlers and then unblock all the wanted signals. Signed-off-by: Karel Zak <kzak@redhat.com>
* su: clean up signals usageKarel Zak2017-09-181-20/+43
| | | | | | | | - don't use magic numbers to index old actions - don't use if () if () - make if() conditions more readable Signed-off-by: Karel Zak <kzak@redhat.com>
* su: clean up const usageKarel Zak2017-09-181-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix debug messageKarel Zak2017-09-181-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: properly clear child PIDKarel Zak2017-09-181-6/+9
| | | | | | | | The patch from master branch, somehow lost during su refactoring rebase. Reported-by: Tobias Stöckmann <tobias@stoeckmann.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* su: improve some debug messagesKarel Zak2017-09-181-2/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add debug.h stuffKarel Zak2017-09-181-2/+71
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: use switch() to split after forkKarel Zak2017-09-181-7/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: move PAM session initialization to separate functionKarel Zak2017-09-181-8/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: rename evaluate_uid()Karel Zak2017-09-181-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cosmetic code changesKarel Zak2017-09-181-43/+35Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup setuid/gid related codeKarel Zak2017-09-181-17/+12Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup setenv related codeKarel Zak2017-09-181-24/+23Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup shell related codeKarel Zak2017-09-181-28/+26Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup usernames usageKarel Zak2017-09-181-58/+23Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup pwd struct usageKarel Zak2017-09-181-46/+40Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: add xgetpwnam()Karel Zak2017-09-181-24/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: consolidate tty name usageKarel Zak2017-09-181-25/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>