Todd C. Miller [Mon, 16 Apr 2012 14:18:32 +0000 (10:18 -0400)]
Include sys/mkdev.h if present instead of sys/sysmacros.h for
minor(). This is needed on Solaris (at least) where the makedev
macros in sysmacros.h are obsolete and library functions should be
used instead.
Todd C. Miller [Fri, 13 Apr 2012 20:00:32 +0000 (16:00 -0400)]
When looking for a device match, do a breadth-first search instead
of depth-first. We already special case /dev/pts/ so chances are
good that if it is not a pseudo-tty it is in the base of /dev/.
Also avoid a stat(2) when possible if struct dirent has d_type.
Todd C. Miller [Wed, 11 Apr 2012 23:51:56 +0000 (19:51 -0400)]
Instead of treating ^C from tgetpass() specially, always
return AUTH_INTR if tgetpass() returned NULL.
Treat PAM_AUTHINFO_UNAVAIL like PAM_AUTH_ERR which Mac OS X
returns this when there is no tty.
Todd C. Miller [Wed, 11 Apr 2012 18:48:08 +0000 (14:48 -0400)]
Rototill code to determine the tty. For Linux, we now look up the
tty device in /proc/pid/stat instead of trying to open /proc/pid/fd/[0-2].
The sudo_ttyname_dev() function maps the given device number to a
string. On BSD, we can use devname(). On Solaris, _ttyname_dev()
does what we want.
TODO: write /dev/ traversal code for the generic sudo_ttyname_dev().
Todd C. Miller [Tue, 10 Apr 2012 18:35:30 +0000 (14:35 -0400)]
Better support for SVR4-style /proc entries where we can't use
ttyname() on the /proc/pid/fd/[0-2] entries. We can, however,
attempt to map the device number back to the correct pseudo-tty
slave device.
Todd C. Miller [Tue, 10 Apr 2012 14:18:39 +0000 (10:18 -0400)]
Linux select() may return ENOMEM if there is a kernel resource
shortage. Older Solaris select() may return EIO instead of EBADF
when the tty goes away. If we get an unhandled select() failure,
kill the child and exit cleanly.
Todd C. Miller [Fri, 6 Apr 2012 16:45:30 +0000 (12:45 -0400)]
Ignore SIGTTIN and SIGTTOU in main sudo process when I/O logging.
It is better to receive EIO from read()/write() than to be suspended
when we don't expect it. Fixes a problem when our terminal is
revoked which can happen when, e.g. our sshd is killed unceremoniously.
Also, only change the value of "alive" from true to false, never
from false to true. It is possible for us to receive notification
of the child having stopped after it is already dead. This does
not mean it has risen from the grave.
Todd C. Miller [Thu, 5 Apr 2012 17:04:00 +0000 (13:04 -0400)]
Always pass __func__, __FILE__ and __LINE__ in sudo_debug_printf()
and use a new flag, SUDO_DEBUG_FILENO to specify when to use it.
This allows consumers of sudo_debug_printf() to log that data without
having to specify it manually.
Todd C. Miller [Thu, 5 Apr 2012 16:40:51 +0000 (12:40 -0400)]
Don't try to restore the terminal if we are not the foreground
process. Otherwise, we may be stopped by SIGTTOU when we try to
update the terminal settings when cleaning up.
Todd C. Miller [Wed, 4 Apr 2012 20:59:31 +0000 (16:59 -0400)]
Add SUDO_DEBUG_ERRNO flag to debug functions so we can log errno.
Use this flag when wrapping error() and warning() so the debug
output includes the error string.
Todd C. Miller [Thu, 29 Mar 2012 14:32:29 +0000 (10:32 -0400)]
Fix building the builtin zlib from a build dir.
When a zlib dir was specified, prepend its include path instead of
appending so we get the right zlib headers.
Todd C. Miller [Tue, 27 Mar 2012 16:41:28 +0000 (12:41 -0400)]
If there is nothing to read from the askpass program, set errno to
EINTR. This makes the cancel button behave like the user entered
^C at the password prompt when PAM is used.
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.