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.
Todd C. Miller [Tue, 8 Nov 2011 13:24:45 +0000 (08:24 -0500)]
Change Debug sudo.conf setting to take a program name as the first
argument. In the future, this will allow visudo and sudoreplay to
use their own Debug entries.
Todd C. Miller [Sun, 6 Nov 2011 22:04:55 +0000 (17:04 -0500)]
Tests for empty sudoers (should parse OK) and syntax errors within
a line (should report correct line number) both with and without
the trailing newline.
Todd C. Miller [Sat, 5 Nov 2011 11:37:14 +0000 (07:37 -0400)]
Keep track of the last token returned. On error, if the last token was
COMMENT, decrement sudolineno since the error most likely occurred on
the preceding line. Previously we always uses sudolineno-1 which will
give the wrong line number for errors within a line.
Todd C. Miller [Tue, 25 Oct 2011 14:08:26 +0000 (10:08 -0400)]
We need to init the auth system regardless of whether we need a
password since we will be closing the PAM session in the monitor
process. Fixes a crash in the monitor on Solaris; bugzilla #518
Todd C. Miller [Sat, 22 Oct 2011 18:28:33 +0000 (14:28 -0400)]
Wrap error/errorx and warning/warningx functions with debug statements.
Disable wrapping for standalone sudoers programs as well as memory
allocation functions (to avoid infinite recursion).