Commit Graph

7300 Commits

Author SHA1 Message Date
Todd C. Miller
fd88ed42c8 Use MSG_WAITALL when receiving struct command_status over the Unix
domain socket since we no longer use datagrams.  This should avoid
the need to handle incomplete reads, though in theory it is still
possible.
2013-10-29 15:26:32 -06:00
Todd C. Miller
abe0314e01 SIGKILL is not catchable 2013-10-29 14:20:43 -06:00
Todd C. Miller
449c4a290a Add sudo_ev_get_timeleft() to get the amount of time left before
an event times out and use it in sudoreplay.
2013-10-29 08:16:42 -06:00
Todd C. Miller
f4cd08ef63 If the user presses <return> or <enter> in sudoreplay, skip to the
next event.  Useful for skipping past long pauses in the data.
2013-10-28 17:01:23 -06:00
Todd C. Miller
1bc2901a26 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.
2013-10-28 16:40:04 -06:00
Todd C. Miller
b8f5d3edf7 Move session replay into its own function. 2013-10-28 14:44:50 -06:00
Todd C. Miller
4d1f912746 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.
2013-10-28 11:13:45 -06:00
Todd C. Miller
4413f89bd3 rename sudo_ev_loop_impl() -> sudo_ev_scan_impl() 2013-10-28 10:10:22 -06:00
Todd C. Miller
8861e01d16 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.
2013-10-28 10:00:09 -06:00
Todd C. Miller
d8b368b503 Now that sudo_ev_base_free() removes all events before freeing we
don't need to do this by hand.
2013-10-26 07:52:59 -06:00
Todd C. Miller
e16c99cd2a 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.
2013-10-26 06:55:23 -06:00
Todd C. Miller
f68ca0168b Remove any existing events before freeing the event base. 2013-10-26 06:55:15 -06:00
Todd C. Miller
60d20f1e6e mon_handler() should be static 2013-10-25 13:55:21 -06:00
Todd C. Miller
e2bfbe6039 If user specified start_tls and ldaps, display a warning and ignore
start_tls.  There's no reason to make this a fatal error.
2013-10-24 15:40:02 -06:00
Todd C. Miller
07e0a068dc 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.
2013-10-24 10:40:51 -06:00
Todd C. Miller
a090d0678c 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.
2013-10-24 10:19:36 -06:00
Todd C. Miller
38a5b0a655 Should not attempt start_tls on an ldaps connection. 2013-10-24 07:16:57 -06:00
Todd C. Miller
548efb83da Fix sign compare warning. 2013-10-23 16:18:28 -06:00
Todd C. Miller
8dfe0b6053 Eliminate warning about circular dependency from GNU make. 2013-10-23 16:05:57 -06:00
Todd C. Miller
0817429583 More sign compare fixes. On Solaris id_t is signed so use uid_t
in the set_perms.c ID macro instead.
2013-10-23 15:19:41 -06:00
Todd C. Miller
07a804caf3 Quiet sign comparision warnings. 2013-10-23 15:03:31 -06:00
Todd C. Miller
f4d2978f30 Add -Wsign-compare to --enable-warnings 2013-10-23 15:02:22 -06:00
Todd C. Miller
994879c044 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.
2013-10-23 11:15:24 -06:00
Todd C. Miller
340fc0a583 Quiet compiler warnings. 2013-10-23 09:43:36 -06:00
Todd C. Miller
29361ec003 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.
2013-10-22 16:52:23 -06:00
Todd C. Miller
d825a58943 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.
2013-10-22 15:54:41 -06:00
Todd C. Miller
e8ce021e7d 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).
2013-10-22 14:58:00 -06:00
Todd C. Miller
65c6f34aa4 If pam_open_session() fails don't call pam_getenvlist() with a NULL
pam handle.
2013-10-22 14:47:51 -06:00
Todd C. Miller
798e82bd61 Fix newly introduced use after frees found by llvm checker. 2013-10-22 10:43:15 -06:00
Todd C. Miller
b2cba83688 Remove an errant list_next() call that should have been removed
in the TAILQ conversion.
2013-10-22 09:33:12 -06:00
Todd C. Miller
b38d253e98 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.
2013-10-22 09:08:38 -06:00
Todd C. Miller
f85106ea67 Use SLIST and STAILQ macros instead of doing headless singly linked
lists manually.  As a bonus we now use a tail queue for ldap.c and
sudoreplay.c.
2013-10-22 09:08:09 -06:00
Todd C. Miller
923edabe6c 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.
2013-10-22 09:00:37 -06:00
Todd C. Miller
fe0e953e9b Fix AND operator broken by changes to fix OR. 2013-10-21 16:00:29 -06:00
Todd C. Miller
2c8d5add86 Fix OR operator. 2013-10-19 16:59:08 -06:00
Todd C. Miller
04588f6136 Fix memory leak of I/O buffer events in safe_close(). 2013-10-18 16:28:49 -06:00
Todd C. Miller
69ab48f16d Don't allow the debug subsystem to be initialized twice.
Otherwise we can exhuast our stack when built in static mode.
2013-10-16 16:44:21 -06:00
Todd C. Miller
6a5d6f9e9e Make sure we do not try to usie index -1 in base->pfds[]. 2013-10-16 16:08:54 -06:00
Todd C. Miller
58f71c00ec Bump version to 1.8.9 2013-10-14 11:00:12 -06:00
Todd C. Miller
b985948e72 Convert the monitor process to the event subsystem. 2013-10-12 05:57:42 -06:00
Todd C. Miller
83d2d25c4c 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.
2013-10-12 05:53:52 -06:00
Todd C. Miller
79acd5db49 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).
2013-10-12 05:53:43 -06:00
Todd C. Miller
ff18c65862 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.
2013-10-12 05:39:02 -06:00
Todd C. Miller
a6b4f41103 Fix removal of trailing newlines in a debug message. 2013-10-06 14:22:14 -06:00
Todd C. Miller
020fb00948 When checking for unused Runas_Aliases, count those used as part
of a Runas Group too.  Fixes a false positive warning.
2013-10-04 16:22:25 -06:00
Todd C. Miller
e223df6908 Include stddef.h for rsize_t and errno_t on systems that support
it natively.
2013-09-29 18:35:34 -06:00
Todd C. Miller
48d7c407e0 Fix braino. 2013-09-29 15:09:43 -06:00
Todd C. Miller
fc332461ed Rebuild message catalog files. 2013-09-29 15:04:11 -06:00
Todd C. Miller
4b5021fed5 Rebuild message catalog files. 2013-09-29 14:59:18 -06:00
Todd C. Miller
aff3320f3f Czech translation for sudo from translationproject.org. 2013-09-29 14:45:28 -06:00