Commit Graph

299 Commits

Author SHA1 Message Date
Todd C. Miller
6c71ad5c15 Add debug_return_const_str and debug_return_const_ptr for returning
a const string or pointer.  Using const for the normal versions
produces warnings with the Tru64 compiler.
2013-11-17 16:11:39 -07:00
Todd C. Miller
237ae0b773 In v{warning,fatal}x?() make a new copy of ap for the debug functions.
It is not legal to use ap twice without reinitializing it.
Noticed by Daniel Richard G.
2013-11-11 16:00:07 -07:00
Todd C. Miller
31e83c3e7a Remove errant warning_restore_locale() call. 2013-11-11 15:24:28 -07:00
Todd C. Miller
702ec173de Move va_copy compat macro to missing.h 2013-11-11 14:35:10 -07:00
Todd C. Miller
adef363d00 Make a copy of readfds/writefds before calling select() instead
of calculating it each time.  Keep track of high fd in the base.
2013-10-31 16:13:15 -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
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
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
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
07a804caf3 Quiet sign comparision warnings. 2013-10-23 15:03:31 -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
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
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
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
5caa61d687 Use __nonnull__ attribute in __printflike. 2013-08-18 14:18:55 -06:00
Todd C. Miller
99352d6738 Rename error.h -> fatal.h now that there is no error() function. 2013-08-15 14:24:29 -06:00
Todd C. Miller
bec394dc11 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.
2013-08-15 14:09:53 -06:00
Todd C. Miller
a44d827636 Add __printflike for vfatal, vfatalx, vwarning and vwarningx. 2013-08-15 14:08:40 -06:00
Todd C. Miller
4928c8c72e Use __printf0like for warning() and fatal() since the fmt string
may be NULL.
2013-08-15 12:58:24 -06:00
Todd C. Miller
d9fd6281e4 Allow default plugin dir to be configured in sudo.conf. 2013-08-13 12:24:28 -06:00
Todd C. Miller
1f3ea50afd Implement memset_s() and use it instead of zero_bytes().
A new constant, SUDO_CONV_REPL_MAX, is defined by the plugin
API as the max conversation reply length.  This constant can be
used as a max value for memset_s() when clearing passwords
filled in by the conversation function.
2013-08-03 08:30:06 -06:00
Todd C. Miller
c2860cce57 Overload -h option to specify an optional hostname for remote access.
This is future-proofing; no policy plugins currently support this.
2013-07-16 16:31:05 -06:00
Todd C. Miller
d6282d154a Update copyright years. 2013-04-24 09:35:02 -04:00
Todd C. Miller
39acd2fcba Rename error/errorx -> fatal/fatalx and remove the exit value as
it was always 1.
2013-04-18 14:07:59 -04:00
Todd C. Miller
414fc377c9 Tru64 5.x does declare innetgr() and getdomainname(). 2013-04-01 16:39:30 -04:00
Todd C. Miller
f7b62e8dc1 Move SET/CLR/ISSET from config.h.in to missing.h 2013-04-01 15:38:09 -04:00
Todd C. Miller
6083947939 Tru64 Unix doesn't prototype innetgr() or getdomainname(). 2013-03-26 13:19:59 -04:00
Todd C. Miller
d710f1b41c Whitespace fixes 2013-03-26 10:27:06 -04:00
Todd C. Miller
7f32d1ca4c Make sesh path configurable in sudo.conf 2013-03-14 16:49:42 -04:00
Todd C. Miller
d26c0d87f6 Convert efree() to a macro that just casts to void * and does free().
If the system free() can't handle free(NULL) this may crash but C89
was a long time ago.
2013-03-07 15:41:34 -05:00
Todd C. Miller
4e5baccb9c Add __malloc_like macro to apply __malloc__ attribute to emalloc,
ecalloc and estrdup.  It cannot be applied to realloc since that
may return the same pointer.
2013-03-05 10:18:32 -05:00
Todd C. Miller
0c40e82c16 Add simple regress tests for sudo.conf parsing. 2013-02-15 14:42:10 -05:00
Todd C. Miller
67fed118b6 Add max_groups setting to sudo.conf (currently unused) and remove
unused return value from setters.
2013-02-14 13:34:33 -05:00
Todd C. Miller
7aae6bd6e3 Add line continuation support to sudo_parseln() and make it use
getline() instead of fgets() internally.
2013-02-07 10:56:01 -05:00
Todd C. Miller
630b47e22f Add group_source setting in sudo.conf to allow the admin to specify
how a user's groups are looked up.  Legal values are static (just
the kernel list from getgroups), dynamic (whatever the group database
includes) and adaptive (only use group db if kernel group list is
full).
2013-01-27 13:53:11 -05:00
Todd C. Miller
ef8e141248 Ignore duplicate entries in sudo.conf and report the line number
when there is an error.  Warn, don't abort if there is more than
one policy plugin.
2013-01-23 06:33:53 -05:00
Todd C. Miller
855a11af2b Move signal code into its own source file and add sudo_sigaction()
wrapper that has an extra flag to check the saved_signals list to
only install the handler if the signal is not already ignored.
Bump plugin API version for the new front-end signal behavior.
2013-01-17 13:29:46 -05:00
Todd C. Miller
a449e8b3e7 Add howmany() macro since some systems have this in sys/param.h
which we no longer include.
2012-12-20 14:46:45 -05:00
Todd C. Miller
1d7072fe09 Don't include <sys/param.h>. We only needed it for MAXPATHLEN,
MAXHOSTNAMELEN and the MIN/MAX macros.  We now use PATH_MAX and
HOST_NAME_MAX throughout without falling back on MAXPATHLEN or
MAXHOSTNAMELEN and define our own MIN/MAX macros as needed.
2012-12-04 10:40:47 -05:00
Todd C. Miller
3c9da162e4 Use MAX_HOST_NAME+1 (limits.h) instead of MAXHOSTNAMELEN (sys/param.h
or netdb.h).
2012-12-04 10:18:41 -05:00
Todd C. Miller
b7ae7977a6 Cannot wrap sigsetjmp() or we end up returning to the wrong place.
Use a macro instead.
2012-11-29 06:37:13 -05:00
Todd C. Miller
2632ec7e69 Move warn/error into common and make static builds work. 2012-11-25 09:34:40 -05:00
Todd C. Miller
c2c6616a0c Move _sudo_printf from src/conversation.c to common/sudo_printf.c.
Add sudo_printf function pointer that is initialized to _sudo_printf()
instead of requiring a sudo_conv function pointer everywhere.  The
plugin will reset sudo_printf to point to the version passed in via
the plugin open function.  Now plugin_error.c can just call sudo_printf
in all cases.  The sudoers binaries no longer need their own version
of sudo_printf.
2012-11-25 09:34:33 -05:00
Todd C. Miller
88c6446daf Do locale swapping in the warning()/error() macros themselves instead
of in the underlying functions.
2012-11-25 09:34:15 -05:00
Todd C. Miller
4bde57b8b2 Rename warning2()/error2() -> warning_nodebug()/error_nodebug(). 2012-11-25 09:34:10 -05:00
Todd C. Miller
acf8af9aac #unifdef HAVE_SETLOCALE, it is C89 so no need to check for it. 2012-11-12 08:51:58 -05:00
Todd C. Miller
c1db4b1546 Always include locale.h from gettext.h so we no longer need to
include locale.h from the .c files.
2012-11-11 20:23:53 -05:00
Todd C. Miller
f8660f9988 Add variants of warn/error and sudo_debug_printf that take a va_list
instead of a variable number of args.
2012-11-08 15:37:42 -05:00
Todd C. Miller
ab7dda035a Replace strsigname() with sig2str(), emulating it as needed. 2012-08-29 14:25:09 -04:00
Todd C. Miller
537dc94b9e Use strsigname() to print signal names in the debug output.
If the system has no strsigname(), use our own.
2012-08-26 20:12:51 -04:00