Todd C. Miller [Mon, 26 Mar 2012 14:59:14 +0000 (10:59 -0400)]
Remove the NO_EXIT flag to log_error() and add a log_fatal() function
that exits and is marked no_return. Fixes false positives from
static analyzers and is easier for humans to read too.
Todd C. Miller [Thu, 15 Mar 2012 13:18:36 +0000 (09:18 -0400)]
Pass a pointer to user_env in to the init_session policy plugin
function so session setup can modify the user environment as needed.
For PAM authentication, merge the PAM environment with the user
environment at init_session time. We no longer need to swap in the
user_env for environ during session init, nor do we need to disable
the env hooks at init_session time.
Todd C. Miller [Fri, 9 Mar 2012 22:07:41 +0000 (17:07 -0500)]
Better error messages, and added debugging throughout.
Fixed seteuid() version of set_perms()/restore_perms().
Fixed logic bug in AIX version of restore_perms().
Added checks to avoid changing uid/gid when we don't have to.
Never set gid/uid state to -1, use the old value instead.
Todd C. Miller [Thu, 8 Mar 2012 16:30:21 +0000 (11:30 -0500)]
Disable environment hooks after we get user_env back to make sure
a plugin can't to modify user_env after we "own" it. This is kind
of a hack but we don't want the init_session plugin function to
modify user_env.
Todd C. Miller [Wed, 7 Mar 2012 21:35:42 +0000 (16:35 -0500)]
Initial cut at a hooks implementation. The plugin can register
hooks for getenv, putenv, setenv and unsetenv. This makes it
possible for the plugin to trap changes to the environment made by
authentication methods such as PAM or BSD auth so that such changes
are reflected in the environment passed back to sudo for execve().
Todd C. Miller [Fri, 2 Mar 2012 16:04:09 +0000 (11:04 -0500)]
Add support for plugin args at the end of a Plugin line in sudo.conf.
Bump the minor number accordingly and update the documentation. A
plugin must check the sudo front end's version before using the
plugin_args parameter since it is only supported for API version
1.2 and higher.
Todd C. Miller [Tue, 28 Feb 2012 19:16:39 +0000 (14:16 -0500)]
Check the owner and mode in -c (check) mode unless the -f option
is specified. Previously, the owner and mode were checked on the
main sudoers file when the -s (strict) option was given, but this
was not documented.
Todd C. Miller [Mon, 27 Feb 2012 18:28:15 +0000 (13:28 -0500)]
We need sysconfdir in compat/Makfile to get the proper sudo.conf
path. Add standard prefix and foodir expansion in all Makefiles
to avoid this problem in the future.
Todd C. Miller [Wed, 22 Feb 2012 18:04:03 +0000 (13:04 -0500)]
Relax the user/group/mode checks on sudoers files. As long as the
file is owned by the right user, not world-writable and not writable
by a group other than the one specified at configure time (gid 0
by default), the file is considered OK. Note that visudo will still
set the mode to the value specified at configure time.
Todd C. Miller [Tue, 21 Feb 2012 18:26:02 +0000 (13:26 -0500)]
Check for LD_PRELOAD variants in configure instead of checkign cpp
symbols. In disable_execute(), compute the length of the new envp
and allocate it once instead of reallocating on demand. Also append
old value of LD_PRELOAD (if any) to the new value.
Todd C. Miller [Thu, 9 Feb 2012 16:11:58 +0000 (11:11 -0500)]
Use -m not -M for install-sh for everything except setuid.
Install locale .mo files mode 0444, not 0644.
If timedir parent doesn't exist, use default dir mode, not 0700.
Todd C. Miller [Mon, 6 Feb 2012 20:46:17 +0000 (15:46 -0500)]
More complete fix for LDR_PRELOAD on AIX. The addition of
set_perm(PERM_ROOT) before calling the nss open functions (needed
to avoid a GNU TLS bug) also broke LDR_PRELOAD. Setting the effective
and then real uid to 0 for PERM_ROOT works around the issue.
Todd C. Miller [Mon, 6 Feb 2012 18:33:46 +0000 (13:33 -0500)]
Set real uid to root before calling sudo_edit() or run_command()
so that the monitor process is owned by root and not by the user.
Otherwise, on AIX at least, the monitor process shows up in ps as
belonging to the user (and can be killed by the user).
Todd C. Miller [Mon, 6 Feb 2012 18:29:19 +0000 (13:29 -0500)]
For PERM_ROOT when using setreuid(), only set the euid to 0 prior
to the call to setuid(0) if the current euid is non-zero. This
effectively restores the state of things prior to rev 7bfeb629fccb.
Fixes a problem on AIX where LDR_PRELOAD was not being honored for
the command being executed.