Todd C. Miller [Thu, 5 May 2016 21:12:37 +0000 (15:12 -0600)]
In fill_args(), check for "arg_size == 0" instead of
"sudoerslval.command.args == NULL" since the latter leads Coverity
to imply that sudoerslval.command.args could be NULL later on.
Coverity CID 104093.
Todd C. Miller [Wed, 4 May 2016 22:48:02 +0000 (16:48 -0600)]
In parse_expr(), move the "bad" label after the "default" case in
the switch(), not before it. This seemed to confuse Covertity,
resulting in a false positive, CID 104095.
Todd C. Miller [Wed, 4 May 2016 20:13:44 +0000 (14:13 -0600)]
In dispatch_signal() for stopped processes check for tcgetpgrp()
returning -1. Also change checks from "saved_pgrp != -1" to
"fd != -1". Coverity CID 104098.
Todd C. Miller [Wed, 4 May 2016 19:48:44 +0000 (13:48 -0600)]
In relabel_tty() always jump to bad: on error, regardless of the
value of se_state.enforcing. On error, return -1 if enforcing,
else 0. Coverity CID 104099.
Todd C. Miller [Wed, 4 May 2016 18:53:20 +0000 (12:53 -0600)]
In io_callback() if we write the complete buffer and find that there
is no associated reader just return as there is nothing else to be
done. In practice is it not possible for SUDO_EV_READ to be set
if revent is NULL but an early return is harmless and possibly
easier to understand. Coverity CID 104124.
Todd C. Miller [Wed, 4 May 2016 14:55:21 +0000 (08:55 -0600)]
Sync the "cache hit" debug messages with the "cached" debug messages.
This fixes a bug where we could dereference a NULL pointer when we
look up a negative cached entry which is stored as a NULL passwd
or group struct pointer. Bug #743.
Todd C. Miller [Thu, 28 Apr 2016 21:27:53 +0000 (15:27 -0600)]
Remove the check for __sprintf_chk when checking for _FORTIFY_SOURCE,
Some implementations are purely header-file based. As long as we
can link a test program using sprintf() when _FORTIFY_SOURCE=2 it
should be safe to use.
Todd C. Miller [Thu, 28 Apr 2016 21:09:46 +0000 (15:09 -0600)]
Remove configure checks for dev_t, id_t, ino_t, ptrdiff_t, size_t
and ssize_t. These have been specified by either ANSI C or POSIX
for long enough that if the system doesn't support them, it is
unlikely to be able to compile sudo anyway.
Todd C. Miller [Thu, 28 Apr 2016 17:01:58 +0000 (11:01 -0600)]
Do group setup in policy_init_session() before calling out to the
plugin. This makes it possible for the pam_group module to change
the group in pam_setcred(). It's a bit bogus since pam_setcred()
is documented as not changing the group or user ID, but pam_group
is shipped with stock Linux-PAM so we need to support it.
Todd C. Miller [Fri, 22 Apr 2016 22:36:36 +0000 (16:36 -0600)]
Ignore SIGPIPE for the duration of sudo and not just in a few select
places. We have no control over what nss, PAM modules or sudo
plugins might do so ignoring SIGPIPE is safest.
Todd C. Miller [Tue, 19 Apr 2016 16:08:51 +0000 (10:08 -0600)]
When determining whether or not "sudo -l" or "sudo -b" should prompt
for a password, take all sudoers sources into account. In other
words, if both file and ldap sudoers sources are in use, "sudo -v"
will now require that all entries in both sources be have NOPASSWD
(file) or !authenticate (ldap) in the entries.
Todd C. Miller [Tue, 22 Mar 2016 22:31:28 +0000 (16:31 -0600)]
If the auth_type setting in /etc/security/login.cfg is set to
PAM_AUTH but pam_start() fails, fall back to use AIX authentication.
Skip the auth_type check if sudo is not compiled with PAM support.
Todd C. Miller [Wed, 9 Mar 2016 16:39:46 +0000 (09:39 -0700)]
Work around an ambiguity in the PAM spec with respect to the conversation
function. It is not clear whether the "struct pam_message **msg" is an
array of pointers or a pointer to an array. Linux-PAM and OpenPAM use
an array of pointers while Solaris/HP-UX/AIX uses a pointer to an array.
Bug #726.
Todd C. Miller [Fri, 26 Feb 2016 16:32:08 +0000 (09:32 -0700)]
Fix the check for whether a user is allowed to lists another user's
privileges. The "matched" variable is not boolean, it can also
have the value UNSPEC so we need to check explicitly for true.
Bug #738
Todd C. Miller [Wed, 24 Feb 2016 23:00:08 +0000 (16:00 -0700)]
Don't check for posix_spawn() or posix_spawnp() if we were unable
to find spawn.h. This should only be a problem on systems with
broken headers. Bug #730
Todd C. Miller [Mon, 1 Feb 2016 18:08:58 +0000 (11:08 -0700)]
Add an administrative domain to the passwd/group cache key for
AIX which can have different name <-> ID mappings depending
on whether the database is local, LDAP, etc.
Todd C. Miller [Mon, 1 Feb 2016 18:07:10 +0000 (11:07 -0700)]
Fedora dropped "core" from the name some time ago so just match on
f[0-9] for the rpm distro name provided by pp. Since the version
numbers of Fedora and RHEL are so different switch to defining
variables to indicate which features should be enabled. Works for
Fedora 23.
Todd C. Miller [Fri, 29 Jan 2016 17:31:54 +0000 (10:31 -0700)]
When freeing the iobs after pty tear-down, also free the associated
event structures. Quiets a memory leak warnings from address
sanitizer and valgrind.
Todd C. Miller [Thu, 28 Jan 2016 21:53:48 +0000 (14:53 -0700)]
Simple garbage collection (really a to-be-freed list) for the sudoers
plugin. Almost identical to what sudo.c uses. Currenly only the
environment strings are collected at exit time which is enough to
quiet address sanitizer's leak detector.
Todd C. Miller [Wed, 27 Jan 2016 22:37:15 +0000 (15:37 -0700)]
Add support for garbage collecting info passed to the plugin before
exit to appease address sanitizer's leak detector (and valgrind's
leak checker). We can't free these sooner since the plugin may be
using the memory. For plugin API 2.0 it should be make clear that
the plugin must make a copy of the data in the arrays passed in to
the plugin's open() function. Only enabled if NO_LEAKS is defined.
Todd C. Miller [Wed, 27 Jan 2016 16:28:08 +0000 (09:28 -0700)]
fn_free_result() (aka sss_sudo_free_result() in sss_sudo.c) handles
a NULL poiner so there's no need to check before calling it. Add
missing initialization of sss_sudo_result to NULL in sudo_sss_setdefs().
Todd C. Miller [Wed, 27 Jan 2016 16:20:04 +0000 (09:20 -0700)]
Add missing return when user is not found in sudo_sss_result_get().
Previously we fell through to the default case which just logged a
debug message and returned so this just avoids the extra (generic)
debug message.
Todd C. Miller [Sat, 23 Jan 2016 00:04:58 +0000 (17:04 -0700)]
When calling setauthdb(), save the old registry value so we can
restore it properly. Previously we were setting the registry to
unrestricted instead of actually restoring it.
Todd C. Miller [Thu, 21 Jan 2016 14:43:25 +0000 (07:43 -0700)]
When parsing debug entries, don't make a lower value override a
higher one. For example, for "pcomm@debug,all@warn" the "all@warn"
should not set pcomm to "warn" when it is already at "debug".
Todd C. Miller [Wed, 20 Jan 2016 22:36:20 +0000 (15:36 -0700)]
If the user runs "sudoedit /" we will receive ENOENT from openat(2)
and sudoedit will try to create a file with the null string. If
path is empty, open the cwd instead so sudoedit can give a sensible
error message.
Todd C. Miller [Tue, 19 Jan 2016 17:32:33 +0000 (10:32 -0700)]
Add a SET_FLAG macro to simplify parsing command details boolean
flags. Previously, flags were only set and never cleared even if
the boolean value was false. This was not a problem as there were
no default flags for the plugin to enable. That will change in the
future.
Todd C. Miller [Mon, 18 Jan 2016 17:45:47 +0000 (10:45 -0700)]
Use faccessat(2) for directory writability instead of doing the
checks manually where possible. This also allows us to remove the
#ifdef __linux__ bits since we no longer use fstat(2) on Linux with
an O_PATH fd.