Todd C. Miller [Mon, 11 Jan 2016 18:15:42 +0000 (11:15 -0700)]
No need to check whether the fd we opened is really a directory in
sudo_edit_open_nonwritable() since if not, the openat() will fail
with ENOTDIR anyway.
Todd C. Miller [Mon, 11 Jan 2016 01:31:29 +0000 (18:31 -0700)]
Rewritten sudoedit_checkdir support that checks all the dirs in the
path and refuses to follow symlinks in writable directories.
This is a better fix for CVE-2015-5602.
Adapted from a diff by Ben Hutchings. Bug #707
Todd C. Miller [Wed, 16 Dec 2015 22:08:01 +0000 (15:08 -0700)]
Refactor code to set LD_PRELOAD (or the equivalent) in the environment
into a preload_dso() function. Also avoid allocating a new copy
of the environment array if the size of the array does not change.
Todd C. Miller [Wed, 2 Dec 2015 21:06:37 +0000 (14:06 -0700)]
When checking the query results, don't set user_matches in the
netgroup pass unless sudo_ldap_check_non_unix_group() returns true.
This was preventing the mail_no_user sudoOption from being effective.
Todd C. Miller [Wed, 2 Dec 2015 17:43:41 +0000 (10:43 -0700)]
In list mode, we always want to clear FLAG_NO_USER and FLAG_NO_HOST
regardless of whether or not there was an actual match. Otherwise,
warning mail may be sent which is not what we want in list mode.
This is consistent with what the sudoers file backend does.
Todd C. Miller [Sun, 22 Nov 2015 16:19:12 +0000 (09:19 -0700)]
Use yy_size_t for digest_len since newer flex uses yy_size_t for
yyleng. Old flex uses int for yyleng so we need to use a cast to
avoid a sign compare warning.
Todd C. Miller [Fri, 30 Oct 2015 16:11:55 +0000 (10:11 -0600)]
Don't use CPPFLAGS for the -fstack-protector check. Otherwise on
systems with _FORTIFY_SOURCE support we'll get an error due to the
lack of optimization flags. Bug #725
Todd C. Miller [Thu, 29 Oct 2015 20:06:21 +0000 (14:06 -0600)]
Preserve LDFLAGS when checking for stack protector as they may include
rpath settings to allow the stack protector lib to be found. Avoid
using existing CFLAGS since we don't want the compiler to optimize
away the stack variable.
Todd C. Miller [Sun, 25 Oct 2015 20:28:38 +0000 (14:28 -0600)]
Set errno to EISDIR instead of ENOTDIR if directory is writable
since ENOTDIR can be a legitimate errno. This avoids a bogus
"directory is writable" error in that case.
Todd C. Miller [Tue, 6 Oct 2015 21:21:41 +0000 (15:21 -0600)]
Ignore the SUDO_CONV_PROMPT_ECHO_OK flag when echo is enabled.
This was preventing a match of SUDO_CONV_PROMPT_ECHO_ON which
resulted in a masked password instead of an echoed one.
Todd C. Miller [Fri, 2 Oct 2015 17:24:01 +0000 (11:24 -0600)]
It is possible for WIFSTOPPED to be true even if waitpid() is not
given WUNTRACED if the child is ptraced. Don't exit the waitpid()
loop if WIFSTOPPED is true, just in case.
Todd C. Miller [Tue, 29 Sep 2015 03:20:37 +0000 (21:20 -0600)]
There's no point in trying to interpose protected versions of the
exec family of functions. Many modern C libraries use hidden symbols
for the functions and syscalls defined in libc such that they cannot
be overridden inside libc itself. We have to just wrap all the exec
variants plus system and popen.
Todd C. Miller [Sat, 26 Sep 2015 16:53:16 +0000 (10:53 -0600)]
When the command sudo is running is killed by a signal, sudo will
now send itself the same signal with the default signal handler
instead of exiting. The bash shell appears to ignore some signals,
e.g. SIGINT, unless the command is killed by that signal. This
makes the behavior of commands run under sudo the same as without
sudo when bash is the shell. Bug #722
Todd C. Miller [Fri, 25 Sep 2015 17:15:22 +0000 (11:15 -0600)]
If some, but not all, of the LOGNAME, USER or USERNAME environment
variables have been preserved from the invoking user's environment,
sudo will now use the preserved value to set the remaining variables
instead of using the runas user. This ensures that if, for example,
only LOGNAME is present in the env_keep list, that sudo will not
set USER and USERNAME to the runas user.
Todd C. Miller [Thu, 24 Sep 2015 19:43:17 +0000 (13:43 -0600)]
Fix passing of the callback pointer to the conversation function.
This was preventing the on_suspend and on_resume functions from
being called on PAM systems.
Todd C. Miller [Tue, 15 Sep 2015 16:30:36 +0000 (10:30 -0600)]
When a terminal device is closed, SIGHUP is sent to the controlling
process associated with that terminal. It is not sent to the entire
process group so sudo needs to relay SIGHUP to the command when it
is not being run in a new pty. Bug #719
Todd C. Miller [Tue, 15 Sep 2015 15:29:40 +0000 (09:29 -0600)]
We reserved two slots at the end of the editor argv for the line
number and the file name. However, resolve_editor() adds "--"
before the file names so the +line_number is interpreted as a file
name, not a line number so we need to overwrite the "--" as well.
Todd C. Miller [Thu, 10 Sep 2015 22:44:57 +0000 (16:44 -0600)]
Remove checks for __sys_siglist and __sys_signame. They are internal
to libc and there are no known systems that export those symbols
that do not already export the single underbar or no-underbar versions.
Todd C. Miller [Wed, 9 Sep 2015 20:56:52 +0000 (14:56 -0600)]
No need to have version macros for hooks, callbacks and the sudoers
group plugin. We can just use the main sudo API macros. The sudoers
group plugin macros are preserved for source compatibility but are
not documented.
Todd C. Miller [Wed, 9 Sep 2015 16:50:21 +0000 (10:50 -0600)]
Fill in cstat if exec_setup() fails. Previously it was only filled
in for an execve() failure. Fixes an unkillable sudo process when
exec_setup() fails and I/O logging is enabled.