summaryrefslogtreecommitdiffstats
path: root/login-utils/su-common.c
Commit message (Collapse)AuthorAgeFilesLines
* su: More descriptive error message on malformed user entryJakub Hrozek2019-05-311-1/+3
| | | | | | | | | | | With users coming from LDAP, it is often the case that the entry in LDAP does not contain one or more attributes required by su or, because of misconfigured access control rights, the attribute might not be readable by the LDAP client. In that case, su just tells the user that the user does not exist. It might be more user-friendly to tell the user to check the user entry for all required fields.
* su: make comment more friedly to 'make checkxalloc'Karel Zak2019-04-241-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-4/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: change error messageKarel Zak2019-03-251-1/+1
| | | | | | | | | We use PAM and if pam_strerror() returns nothing we have no clue why authentication failed. It's mistake to blame incorrect password if there are many possible reason... Addresses: https://github.com/karelzak/util-linux/issues/778 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-common.c: prefer ENV_SUPATH over ENV_ROOTPATHStanislav Brabec2019-01-101-2/+2
| | | | | | | | 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>
* 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>
* su: add --whitelist-environmentKarel Zak2018-08-151-16/+100
| | | | | | | | | | | | | | | | | | | * 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>
* 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>
* 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>
* login-utils: use free_getlogindefs_data()Karel Zak2017-11-281-0/+2
| | | | | | | 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>
* 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>
* 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 PTY supportKarel Zak2017-09-181-45/+426
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: add --pty optionKarel Zak2017-09-181-1/+8
| | | | 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>
* 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>