Todd C. Miller [Tue, 17 Jan 2012 17:20:28 +0000 (12:20 -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 [Fri, 13 Jan 2012 14:50:03 +0000 (09:50 -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 20:21:36 +0000 (15:21 -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, 12 Jan 2012 20:17:30 +0000 (15:17 -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.
On BSD, use the KERN_PROC_PID sysctl() instead.
Todd C. Miller [Thu, 12 Jan 2012 20:04:07 +0000 (15:04 -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, 12 Jan 2012 19:54:18 +0000 (14:54 -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, 12 Jan 2012 19:52:07 +0000 (14:52 -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.
Todd C. Miller [Thu, 12 Jan 2012 19:23:42 +0000 (14:23 -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.
Todd C. Miller [Thu, 12 Jan 2012 15:18:57 +0000 (10:18 -0500)]
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 [Mon, 10 Oct 2011 17:13:42 +0000 (13:13 -0400)]
Ignore set_logname (which is now the default) for sudoedit since
we want the LOGNAME, USER and USERNAME environment variables to
refer to the calling user since that is who the editor runs as.
This allows the editor to find the user's startup files.
Fixes bugzilla #515
Todd C. Miller [Tue, 27 Sep 2011 20:29:27 +0000 (16:29 -0400)]
Modify the authentication API such that the init and cleanup functions
are always called, regardless of whether or not we are going to
verify a password. This is needed for proper PAM session support.
Todd C. Miller [Sat, 17 Sep 2011 00:03:07 +0000 (20:03 -0400)]
Remove --with-CC option; it doesn't work correctly now that we use
libtool. Users can get the same effect by setting the CC
environment variable when running configure.
Todd C. Miller [Fri, 16 Sep 2011 23:57:12 +0000 (19:57 -0400)]
Use PAM by default on AIX 6 and higher.
Fix some square brackets in case statements that needed to be
doubled up. While here, use $OSMAJOR when it makes sense.
Todd C. Miller [Sun, 14 Aug 2011 20:00:01 +0000 (16:00 -0400)]
bash 2.x doesd not support the -l flag and exits with an error if
it is specified so use --login instead. This causes an error with
bash 1.x (which uses -login instead) but this version is hopefully
less used than 2.x.
Todd C. Miller [Sun, 14 Aug 2011 15:45:09 +0000 (11:45 -0400)]
Improved background mode support. When not allocating a pty, the
command is run in its own process group. This prevents write access
to the tty. When running in a pty, stdin is not hooked up and we
never read from /dev/tty, which results in similar behavior.
Todd C. Miller [Sun, 14 Aug 2011 14:19:48 +0000 (10:19 -0400)]
Go back to escaping the command args for "sudo -i" and "sudo -s"
in NewArgv before checking sudoers but unescape non-spaces when
building user_args to make sudoers matching easier.
Todd C. Miller [Sat, 13 Aug 2011 22:09:13 +0000 (18:09 -0400)]
When building with gcc on HP-UX, use -march=1.1 to produce portable
binaries on a pa-risc2 host. Previously, the +Dportable option was
used for the HP-UX C compiler but gcc always produced native binaries.
Todd C. Miller [Sat, 13 Aug 2011 18:43:43 +0000 (14:43 -0400)]
If the user specifies a runas group via sudo's -g option that matches
the runas user's group in the passwd database and that group is not
denied in the Runas_Spec, allow it. Thus, if user root's gid in
/etc/passwd is 0, then "sudo -u root -g root id" is allow even if
no groups are present in the Runas_Spec.
Todd C. Miller [Sat, 13 Aug 2011 18:42:57 +0000 (14:42 -0400)]
When checking aliases, also check the contents of the alias in case
there are problems with an alias that is referenced inside another.
Replace the self reference check with real alias cycle detection.
Todd C. Miller [Sat, 13 Aug 2011 18:39:32 +0000 (14:39 -0400)]
Increment alias_seqno before calls to alias_remove_recursive() to
avoid false positives with the alias loop detection. Fixes spurious
warnings about unused aliases when they are nested.
Todd C. Miller [Tue, 9 Aug 2011 18:56:05 +0000 (14:56 -0400)]
Go back to using a callback for runas_default to keep runas_pw in
sync. This is needed to make per-entry runas_default settings work
with LDAP-based sudoers. Instead of declaring it a callback in
def_data.in, sudo pokes sudo_defs_table[] which is a bit naughty,
but avoids requiring stub functions in visudo and testsudoers.