Todd C. Miller [Wed, 25 Jan 2012 21:29:08 +0000 (16:29 -0500)]
The change in 818e82ecbbfc that caused to exit when the monitor
dies created a race condition between the monitor exiting and the
status being read. All we really want to do is make sure that
select() notifies us that there is a status change when the monitor
dies unexpectedly so shutdown the socketpair connected to the monitor
for writing when it dies. That way we can still read the status
that is pending on the socket and select() on Linux will tell us
that the fd is ready.
Todd C. Miller [Wed, 25 Jan 2012 19:58:02 +0000 (14:58 -0500)]
Refactor disable_execute() and my_execve() into exec_common.c for
use by sesh.c. This fixes NOEXEC when SELinux is used. Instead
of disabling exec in exec_setup(), disable it immediately before
executing the command. Adapted from a diff by Arno Schuring.
Todd C. Miller [Fri, 20 Jan 2012 15:28:56 +0000 (10:28 -0500)]
Add custom version of AC_CHECK_LIB that uses the extra libs in the
cache value name. With this we no longer need to rely on a modified
version of autoconf.
Todd C. Miller [Thu, 19 Jan 2012 16:03:22 +0000 (11:03 -0500)]
For "sudo -g" prepend the specified group ID to the beginning of
the groups list. This matches BSD convention where the effective
gid is the first entry in the group list. This is required on newer
FreeBSD where the effective gid is not tracked separately and thus
setgroups() changes the egid if this convention is not followed.
Fixes bug #532
Todd C. Miller [Tue, 17 Jan 2012 15:27:33 +0000 (10:27 -0500)]
When not logging I/O, use a signal handler that only forwards SIGINT,
SIGQUIT and SIGHUP when they are user-generated signals. Fixes a
race in the non-I/O logging path where the command may receive two
keyboard-generated signals; one from the kernel and one from the
sudo process.
Todd C. Miller [Mon, 16 Jan 2012 15:40:11 +0000 (10:40 -0500)]
Only run compat regress tests on compat objects we actually build.
Fixes "make check" in the compat dir for systems that don't implement
character classes in fnmatch() or glob(). Bug #531
Todd C. Miller [Fri, 13 Jan 2012 14:49:20 +0000 (09:49 -0500)]
Include parent directories in case they don't already exist. This
fixes a directory permissions problem with the AIX package when the
/usr/local directories don't already exist.
Todd C. Miller [Thu, 12 Jan 2012 12:50:40 +0000 (07:50 -0500)]
Add a check for devname() returning a fully-qualified pathname.
None of the devname() implementations do this today but you never
know when this might change.
Todd C. Miller [Thu, 5 Jan 2012 20:54:00 +0000 (15:54 -0500)]
Do not include GLOB_MARK in the flags we pass to glob(3). Fixes a
bug where a pattern like "/usr/*" include /usr/bin/ in the results,
which would be incorrectly be interpreted as if the sudoers file
had specified a directory. From Vitezslav Cizek.
Todd C. Miller [Thu, 5 Jan 2012 20:39:05 +0000 (15:39 -0500)]
Add --enable-kerb5-instance configure option to allow people using
Kerberos V authentication to use a custom instance. Adapted from
a diff by Michael E Burr.
Todd C. Miller [Tue, 3 Jan 2012 15:47:33 +0000 (10:47 -0500)]
When trying to determine the tty, fall back on /proc/ppid/fd/{0,1,2}
if the main process's fds 0-2 are not hooked up to a tty. Adapted
from a diff by Zdenek Behan.
Todd C. Miller [Tue, 3 Jan 2012 15:06:07 +0000 (10:06 -0500)]
When not logging I/O, put command in its own pgrp and make that the
controlling pgrp if the command is in the foreground. Fixes a race
in the non-I/O logging path where the command may receive two
keyboard-generated signals; one from the kernel and one from the
sudo process.
Todd C. Miller [Thu, 8 Dec 2011 22:17:25 +0000 (17:17 -0500)]
When running a login shell with a login_class specified, use
LOGIN_SETENV instead of rolling our own login.conf setenv support
since FreeBSD's login.conf has more than just setenv capabilities.
This requires us to swap the plugin-provided envp for the global
environ before calling setusercontext() and then stash the resulting
environ pointer back into the command details, which is kind of a
hack.
Todd C. Miller [Thu, 8 Dec 2011 16:18:38 +0000 (11:18 -0500)]
Handle different Unix domain socket (actually socketpair) semantics
in BSD vs. Linux. In BSD if one end of the socketpair goes away
select() returns the fd as readable and the read will fail with
ECONNRESET. This doesn't appear to happen on Linux so if we notice
that the monitor process has died when I/O logging is enabled,
behave like the command has exited. This means we log the wait
status of the monitor, not the command, but there is nothing else
we can do at that point. This should only be an issue if SIGKILL
is sent to the monitor process.
Todd C. Miller [Thu, 8 Dec 2011 16:15:53 +0000 (11:15 -0500)]
Catch common signals in the monitor process so they get passed to
the command. Fixes a problem when the entire login session is
killed when ssh is disconnected or the terminal window is closed.
Previously, the monitor would exit and plugin's close method would
not be called.
Todd C. Miller [Mon, 5 Dec 2011 15:43:44 +0000 (10:43 -0500)]
Add support for setenv entries in login.conf. We can't use LOGIN_SETENV
since the plugin sets up the envp the command is executed with.
Also regen the Makefile.in files while here. Fixes bug #527
Todd C. Miller [Fri, 2 Dec 2011 19:29:54 +0000 (14:29 -0500)]
Fetch the login class for the user we authenticate specifically when
using BSD authentication. That user may have a different login class
than what we will use to run the command. When setting the login
class for the command, use the target user's struct passwd, not
the invoking user's. Fixes bug 526
Todd C. Miller [Thu, 1 Dec 2011 16:27:57 +0000 (11:27 -0500)]
No longer need SUDO_CHECK_TYPE and SUDO_TYPE_* now that the default
includes have unistd.h in them. Add check for socklen_t for upcoming
getaddrinfo compat.