Todd C. Miller [Fri, 25 May 2012 20:38:55 +0000 (16:38 -0400)]
When replaying a log of stdout or stderr, do newline to carriage
return + linefeed conversion. We cannot have termios do this for
us since we've disabled output postprocessing (POST) when setting
raw mode.
Todd C. Miller [Wed, 23 May 2012 19:37:24 +0000 (15:37 -0400)]
Don't prompt for a password if the user is in the exempt group, is
root, or is running the command as themselves even if the -k option
was specified. This makes "sudo -k command" consistent with the
behavior one would get if the user ran "sudo -k" immediately before
running the command.
Todd C. Miller [Wed, 23 May 2012 19:06:11 +0000 (15:06 -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 [Wed, 23 May 2012 18:21:07 +0000 (14:21 -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 [Wed, 23 May 2012 18:17:41 +0000 (14:17 -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, 23 May 2012 16:46:39 +0000 (12:46 -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. For others we do a breadth-first search of /dev.
Todd C. Miller [Mon, 21 May 2012 18:24:27 +0000 (14:24 -0400)]
If sudoers_mode is group-readable but the actual sudoers file is
not, open the file as uid 0, not uid 1. This fixes a problem when
sudoers has a more restrictive mode than what sudo expects to find.
In older versions, sudo would silently chmod the file to add the
group-readable bit.
Todd C. Miller [Thu, 17 May 2012 16:09:56 +0000 (12:09 -0400)]
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
byile is considered OK. Note that visudo will still
set the mode to the value specified at configure time.
Todd C. Miller [Thu, 17 May 2012 16:07:18 +0000 (12:07 -0400)]
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
byile is considered OK. Note that visudo will still
set the mode to the value specified at configure time.
Todd C. Miller [Thu, 17 May 2012 15:23:54 +0000 (11:23 -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 [Thu, 17 May 2012 14:58:44 +0000 (10:58 -0400)]
Split global and per-connection LDAP options into separate arrays.
Set global LDAP options before calling ldap_initialize() or ldap_init().
After we have an LDAP handle, set the per-connection options.
Fixes a problem with OpenLDAP using the nss crypto backend; bug #342
Todd C. Miller [Fri, 30 Mar 2012 17:53:19 +0000 (13:53 -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 [Fri, 30 Mar 2012 17:34:19 +0000 (13:34 -0400)]
When initializing the environment for env_reset, start out with the
contents of /etc/environment on AIX and login.conf on BSD. Also
apply environment in login.conf for "sudo -i".
Todd C. Miller [Tue, 27 Mar 2012 16:39:11 +0000 (12:39 -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 [Wed, 1 Feb 2012 17:12:53 +0000 (12:12 -0500)]
Error out if user specified --with-pam but we can't find the headers
or library. Also throw an error if the headers are present but the
library is not and vice versa.
Todd C. Miller [Thu, 26 Jan 2012 21:34:49 +0000 (16:34 -0500)]
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 #533