Todd C. Miller [Mon, 28 Oct 2013 22:40:04 +0000 (16:40 -0600)]
Fix sudo_ev_scan_impl() return value in event_poll.c.
Make sure we clear active flag from unprocessed events if
sudo_ev_loopbreak() or sudo_ev_loopcontinue() are used.
Remove bogus optimization when the timeout is zero or negative; it
could prevent an I/O event from being triggered.
Todd C. Miller [Mon, 28 Oct 2013 17:13:45 +0000 (11:13 -0600)]
Get rid of cur and pending pointers in struct sudo_event_base. We
now pop the first event off the active queue instead of using a
foreach loop with deferred removal of the event.
Add SUDO_EVQ_INSERTED and SUDO_EVQ_TIMEOUTS flags to indicate that
the event on the event queue and timeouts queue respectively.
No longer need to compare the timeout to {0,0} or compare the
event's base pointer to NULL to determine queue membership.
Todd C. Miller [Mon, 28 Oct 2013 16:00:09 +0000 (10:00 -0600)]
Add support for libevent-style timed events. Adding a timed event
is currently O(n). The only consumer of timed events is sudoreplay
which only used a singled one so O(n) == O(1) for now. This also
allows us to remove the nanosleep compat function as we now use a
timeout event instead.
Todd C. Miller [Sat, 26 Oct 2013 12:55:23 +0000 (06:55 -0600)]
Add a list of active events in the base that the back end sets when
it calls poll or select. This allows the front end to iterate over
the events instead of having that code in both back ends. It will
also simplify support for timeout events. Also make sure we can't
touch freed memory if a callback frees its own event.
Todd C. Miller [Thu, 24 Oct 2013 16:40:51 +0000 (10:40 -0600)]
Add missing else when the connection from the monitor to the parent
sudo process is broken (due to the parent dying). Prevents a
spurious "unexpected reply type on backchannel" warning.
Todd C. Miller [Thu, 24 Oct 2013 16:19:36 +0000 (10:19 -0600)]
When flushing output we don't care whether we are the foreground
process or not, we still need to flush to /dev/tty. If we are in
the background, it is OK to get SIGTTOU.
Todd C. Miller [Wed, 23 Oct 2013 17:15:24 +0000 (11:15 -0600)]
Ignore SIGPIPE when connecting to the LDAP server so we can get a
proper error message with the IBM LDAP libs. Also return LDAP_SUCCESS
instead of 0 from most sudo_ldap_* functions that return an int.
Todd C. Miller [Tue, 22 Oct 2013 22:52:23 +0000 (16:52 -0600)]
sudo_ldap_parse_uri() should join multiple URIs in the string list
together but it was clearing the host entry each time through the
loop. Fixes a bug with multiple URI entries in ldap.conf where
only the last one was being honored.
Todd C. Miller [Tue, 22 Oct 2013 21:54:41 +0000 (15:54 -0600)]
Avoid a double free introduced when plugging a memory leak in
safe_close(). A new ev_free_by_fd() function is used to remove and
free any events sharing the specified fd. This can be used after
safe_close() to make sure we don't try to select() on a closed fd.
Todd C. Miller [Tue, 22 Oct 2013 20:58:00 +0000 (14:58 -0600)]
Quiet some llvm check false positives. The common idiom of using
TAILQ_FIRST, TAILQ_REMOVE and free in a loop to free each entry in
a TAILQ confuses llvm. Use TAILQ_FOREACH_SAFE instead (which is
probably faster anyway).
Todd C. Miller [Tue, 22 Oct 2013 15:08:38 +0000 (09:08 -0600)]
Add "headless" tail queues and use them in place of the semi-circular
lists in sudoers. Once the headless tail queue is built up it is
converted to a normal TAILQ. This removes the last consumer of
list.c and list.h so those can now be removed.
Todd C. Miller [Tue, 22 Oct 2013 15:00:37 +0000 (09:00 -0600)]
Convert sudo to use BSD TAILQ macros instead of home ground tail
queue functions. This includes a private queue.h header derived
from FreeBSD. It is simpler to just use our own header rather than
try to deal with macros that may or may not be present in various
queue.h incarnations.
Todd C. Miller [Sat, 12 Oct 2013 11:53:52 +0000 (05:53 -0600)]
Convert the main sudo event loop to use the event subsystem.
Read events for I/O buffers are added before the loop starts.
Write events are added on demand as the buffers are filled.
Todd C. Miller [Sat, 12 Oct 2013 11:53:43 +0000 (05:53 -0600)]
Simple event subsystem that uses poll() or select(). Basically a
simplied subset of libevent2. Currently only fd events are supported
(since that's all we need). The poll() backend is used by default,
except on Mac OS X where poll() is broken for devices (including
/dev/tty and ptys).
Todd C. Miller [Sat, 12 Oct 2013 11:39:02 +0000 (05:39 -0600)]
Use SOCK_STREAM for socketpair, not SOCK_DGRAM so we get consistent
semantics when the other end closes. This should make the conversion
to poll() less problematic.
Todd C. Miller [Wed, 18 Sep 2013 17:48:26 +0000 (11:48 -0600)]
Change "next" back to 2. In the context of "next Friday" we really
do want the friday of the upcoming (not current) week. Unfortunately,
this means that things like "next week" and "next year" will match
one more than we really want. Fixing this will require some fairly
major changes to the grammar.
Todd C. Miller [Mon, 9 Sep 2013 22:41:27 +0000 (16:41 -0600)]
Make "this" and "next" qualifiers work a bit better. There is still
room for improvement as "this week" will use the current time instead
of the beginning of the week. That's a separate issue though.
Todd C. Miller [Wed, 21 Aug 2013 16:09:04 +0000 (10:09 -0600)]
Add configure checks for the exec functions we will dummy out. This
is only really needed on Mac OS X when symbol interposition is being
performed but won't hurt elsewhere.
Todd C. Miller [Tue, 20 Aug 2013 21:14:17 +0000 (15:14 -0600)]
Fix installation of sudo_noexec on Mac OS X.
Use library symbol interposition on Mac OS X 10.4 and higher so
we don't need to set DYLD_FORCE_FLAT_NAMESPACE=1.
Todd C. Miller [Sat, 17 Aug 2013 11:08:20 +0000 (07:08 -0400)]
Fix error display from ldap_ssl_client_init(). There are two error
codes. The return value can be decoded via ldap_err2string() but the
ssl reason code cannot (you have to look it up in a table online).
Todd C. Miller [Sat, 17 Aug 2013 12:34:09 +0000 (06:34 -0600)]
When merging the PAM environment, allow environment variables set
in PAM to override ones set by sudo as long as they do not match
the env_keep or env_check lists.
Todd C. Miller [Fri, 16 Aug 2013 19:50:48 +0000 (13:50 -0600)]
Don't redefine opterr, optind, optopt, optarg in getopt_long.c.
Add a check for optreset which is a BSD extension and provide a
definition in getopt_long.c if it is not present.
Todd C. Miller [Thu, 15 Aug 2013 20:09:53 +0000 (14:09 -0600)]
Add support to the debug subsystem for zero-length strings. This
can happen for things like warning(NULL) or fatal(NULL) where we
just want to log the errno string.