Commit Graph

136 Commits

Author SHA1 Message Date
Todd C. Miller
9b42640ef5 Change defaults callbacks to take a union sudo_defs_val * instead
of a char *.
2016-07-18 12:11:25 -06:00
Todd C. Miller
578af5af4d Use ferror() after fflush() to check the error status of the stdio
stream we wrote to.
2016-05-14 18:48:20 -06:00
Todd C. Miller
05db5aa3b8 Remove sudo_mkpwcache() and sudo_mkgrcache(). We now create the
caches as needed on demand.  Also remove calls to sudo_freepwcache()
and sudo_freegrcache() that are immediately followed by execve(),
they are not needed.
2016-05-11 09:40:31 -06:00
Todd C. Miller
23d288563e Eliminate use of setpwent()/endpwent() and setgrent()/endgrent().
Sudo never iterates over the passwd or group file.
Rename sudo_set{pw,gr}ent() -> sudo_mk{pw,gr}cache() and
use sudo_free{pw,gr}cache() instead of sudo_end{pw,gr}ent().
2016-05-11 07:06:45 -06:00
Todd C. Miller
c56a812ea2 In io_mkdirs(), change the order from stat then mkdir, to mkdir then stat.
This more closely matches what "mkdir -p" does.
Coverity CID 104120.
2016-05-06 16:42:42 -06:00
Todd C. Miller
4bfdf0c2b4 Fix fd leak in open_io_fd() if gzdopen/fdopen fails.
Coverity CID 104105
2016-05-06 08:11:34 -06:00
Todd C. Miller
444d2a5c3e Fix fd leak in io_nextid() in error path.
Coverity CID 104104
2016-05-06 08:07:40 -06:00
Todd C. Miller
6473d55aa7 Cast the return value of fcntl() to void when setting FD_CLOEXEC.
Coverity CID 104063, 104064, 104069, 104070, 104071, 104072, 104073, 104074
2016-05-05 16:16:24 -06:00
Todd C. Miller
5cbe1edcfe iolog_compress should be bool, not int 2016-01-28 15:36:15 -07:00
Todd C. Miller
a6886d2345 Add check for I/O log file handle being NULL. This could only
happen if the front-end calls iolog_open with argc == 0 but actually
runs a command.
2016-01-25 16:18:22 -07:00
Todd C. Miller
7d0a623fdd Use pread(2) and pwrite(2) where possible. 2015-09-07 06:06:08 -06:00
Todd C. Miller
0b241088b3 There's no need to conditionalize the #include <unistd.h>, we require
a POSIX system.
2015-07-02 09:08:28 -06:00
Todd C. Miller
4a07b472f0 Only include stddef.h where it is needed. 2015-06-20 05:34:35 -06:00
Todd C. Miller
c36415417f Add function name to "unable to allocate memory" warnings. 2015-06-19 14:51:17 -06:00
Todd C. Miller
dc883f2454 We require ANSI C so stop using the obsolete STDC_HEADERS. 2015-06-19 14:29:27 -06:00
Todd C. Miller
d004b02fc6 Use non-exiting allocatings in the sudoers plugin. 2015-06-17 06:49:59 -06:00
Todd C. Miller
2bf454b74d Use non-exiting allocators in the redblack tree and fix the fallout.
Also switch to non-exiting allocators in affected code blocks.
2015-05-27 09:51:54 -06:00
Todd C. Miller
caf5d45e0f Previously, debug_return_bool was the same as debug_return_int
except that it logged true/false for 1/0.  However, this appears
to trigger a bug in some compilers.  To avoid this, debug_return_bool
now uses bool, not int.  Callers that were passing it an int have
been converted to use debug_return_int instead.
2015-05-07 10:33:23 -06:00
Todd C. Miller
973286c7ac Check the return value of gettimeofday(), even though it should
never fail.
2015-02-25 07:10:25 -07:00
Todd C. Miller
59ab26dbcc Go back to a 2 args debug_decl and just use the "default" instance,
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
9d6e1a57d5 Add sudoers_debug_deregister() and use it instead of calling
sudo_debug_deregister() directly.
2014-10-27 16:06:20 -06:00
Todd C. Miller
34d9cfe1cf Initialize the debug subsystem in sudoers early. Currently this
means iterating over the settings list twice.
2014-10-24 12:50:12 -06:00
Todd C. Miller
4bf641df69 In the plugin registers with the debug framework at open time, the
sudo front-end will now set the default debug instance appropriately
before calling into the plugin.  This means the plugin no longer needs
to do the sudo_debug_set_default_instance() dance.
2014-10-24 11:17:48 -06:00
Todd C. Miller
935e48c6e4 Don't call into the debug subsystem after we've deregistered the
plugin's instance.
2014-10-23 13:42:50 -06:00
Todd C. Miller
e9914a91b1 The sudoers plugin now defines its own list of debugging subsystem names
and defines.
2014-10-22 13:30:52 -06:00
Todd C. Miller
866cfc4fc3 Add support for multiple Debug lines per program. Callers may
register arbitrary debug facilities or use built-in defaults.  We
now use separate Debug statements for plugins and programs.
2014-10-22 13:23:05 -06:00
Todd C. Miller
e20475922d There is no longer a reason for the plugin to init the debug subsystem
itself.  It will always be initialized by the front-end if needed.
2014-09-08 16:24:32 -06:00
Todd C. Miller
af9306cd81 Return -1 from logging functions if we get a write error. 2014-08-26 13:54:29 -06:00
Todd C. Miller
36a5767e3e efree -> sudo_efree for consistency 2014-07-10 15:35:04 -06:00
Todd C. Miller
a8fa112a53 atobool -> sudo_strtobool
atoid-> sudo_strtoid
atomode -> sudo_strtomode
2014-06-27 14:53:54 -06:00
Todd C. Miller
2d61d38c23 Add sudo_ prefix to alloc.c functions and rename alloc.h -> sudo_alloc.h 2014-06-27 10:48:31 -06:00
Todd C. Miller
aecef4aa1d Rename warning/fatal -> sudo_warn/sudo_fatal to avoid namespace
pollution in libsudo_util.so.
2014-06-27 09:30:52 -06:00
Todd C. Miller
f029e3e744 Remove touch() from fileops.c and just call utimes/futimes directly.
Rename lock_file -> sudo_lock_file to avoid namespace pollution
2014-06-26 15:51:15 -06:00
Todd C. Miller
2166a6afe1 Remove use of setjmp/longjmp in the sudoers plugin. We no longer
call fatal() except in the malloc wrappers and due to libsudo_util
there is now a single copy of fatal/fatalx.
2014-06-26 15:51:15 -06:00
Todd C. Miller
b0f1fa7d05 Rename log_warning flags and only send mail if SLOG_SEND_MAIL is
set instead of mailing by default like we used to.
2014-05-02 20:54:01 -06:00
Todd C. Miller
954a3e77b1 Add log_warningx 2014-05-02 16:40:30 -06:00
Todd C. Miller
cbee9cc8cb Remove now-unused log_fatal() 2014-04-30 17:00:20 -06:00
Todd C. Miller
bd86ced96a Don't call ferror() on a closed stream, just check the return value
of fclose() instead.  Found by cppcheck.
2014-04-24 11:12:18 -06:00
Todd C. Miller
9b7dfa7522 Remove calls to log_fatal() in I/O log functions and just pass an
error back to the caller.
2014-04-04 15:30:12 -06:00
Todd C. Miller
b813c4de48 Use sudo_timeval macros and remove compat macros from missing.h 2014-01-30 15:51:59 -07:00
Todd C. Miller
12fc51060e When writing length to timing file, use %u not %d as it is unsigned. 2014-01-08 16:45:06 -07:00
Todd C. Miller
27598bc0ab Update copyright year. 2014-01-07 10:43:31 -07:00
Todd C. Miller
0e1d726aac Handle a sequence file with no trailing newline. 2014-01-04 12:42:34 -07:00
Todd C. Miller
391bc02e25 Truncate io log and timing files on open when recycling them.
Only an issue when the sequence number wraps around.
2014-01-03 18:28:07 -07:00
Todd C. Miller
6fe419423a Repair reading of the iolog sequence number that got broken when
adding stricter strtoul() checks.
2014-01-03 18:11:27 -07:00
Todd C. Miller
cbf41b8b96 The OpenBSD strtonum() uses very short error strings that can't
be translated usefully.  Convert them to longer strings on error.
Also use the longer strings for atomode() and atoid().
2013-12-11 13:43:10 -07:00
Todd C. Miller
8f9ce7249a Use strtonum() instead of atoi(), strtol() or strtoul() where possible. 2013-12-10 16:23:21 -07:00
Todd C. Miller
96eb2c4f8f Add warning_gettext() wrapper function that changes to the user locale,
then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
2013-11-18 08:59:57 -07:00
Todd C. Miller
99b7351de0 Fix some #if vs. #ifdef and remove an extraneous semicolon.
Bug #624; from Daniel Richard G.
2013-11-17 16:15:36 -07:00
Todd C. Miller
07a804caf3 Quiet sign comparision warnings. 2013-10-23 15:03:31 -06:00