summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* su: reorder functionsKarel Zak2017-09-181-70/+70
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup PAM stuffKarel Zak2017-09-181-31/+27Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: cleanup usage()Karel Zak2017-09-181-60/+63
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>