Todd C. Miller
a842913aa7
Use debug logging instead of ignore_result() where possible.
2017-05-12 10:02:18 -06:00
Todd C. Miller
1d1ebb6111
Add io_open() wrapper for open(2) that retries with PERM_IOLOG if
...
open(2) fails with EACCES. Use io_open() instead of duplicate
copies of the same fallback code.
2017-05-04 11:00:22 -06:00
Todd C. Miller
8757691fc7
Don't retry the open() if set_perms() fails.
2017-05-04 10:45:05 -06:00
Todd C. Miller
237eddd95e
Fix typo (fd2 vs. fd) caught by coverity, CID 168359.
2017-05-04 10:30:59 -06:00
Todd C. Miller
4df6b62b56
Only retry mkdir or create with PERM_IOLOG if errno is EACCES.
...
Also always use PERM_IOLOG for mkdtemp() since we cannot retry
if it fails. Since we are guaranteed to create a new directory
there's no real need to try w/o PERM_IOLOG in this case.
2017-03-23 17:00:27 -06:00
Todd C. Miller
31b16fd3e9
Add fallback to PERM_IOLOG when making the final componenet of iolog_dir.
2017-03-22 15:55:16 -06:00
Todd C. Miller
4621e43676
quiet a warning on older zlib
2017-03-22 08:47:10 -06:00
Todd C. Miller
8d1e994d84
cast mode_t to unsigned int when printing with %o
2017-03-22 08:37:12 -06:00
Todd C. Miller
7668b4b42b
Set umask temporarily when creating files instead of changing the
...
mode after the fact. This is slightly less error prone.
2017-03-21 16:21:17 -06:00
Todd C. Miller
2a37590b7d
remove now-useless variable
2017-03-21 15:04:47 -06:00
Todd C. Miller
1bd90d8fff
Explicitly set the file mode of I/O log files so the mode is not
...
affected by the invoking user's umask.
2017-03-21 13:54:27 -06:00
Todd C. Miller
8d57491dc1
Add PERM_IOLOG so we can create I/O log files on an NFS-mounted
...
filesystem where root is remapped to an unprivileged user.
2017-03-21 13:41:14 -06:00
Todd C. Miller
c4e703696a
Add iolog_flush option.
2017-03-20 10:25:58 -06:00
Todd C. Miller
8c8d078f66
Don't allow the user to specify an I/O log file mode that sudo can't
...
read or write to. I/O logs must always be readable and writable
by the owner.
2017-03-17 10:56:17 -06:00
Todd C. Miller
6c5936296f
Add SUDO_DEBUG_INSTANCE_ERROR return value for sudo_debug_register()
...
and check for it in places where we check the return value of
sudo_debug_register().
2016-11-21 06:37:23 -10:00
Todd C. Miller
cefcb6f501
add missing sudo_pw_delref/sudo_gr_delref to plug memory leak
2016-11-09 16:07:12 -07:00
Todd C. Miller
2b020c9f17
Pass iolog mode, group and user from policy plugin to I/O log plugin.
2016-11-07 10:19:04 -07:00
Todd C. Miller
1fdcce7faf
use cp instead of *cur when comparing against plugin_path
2016-10-31 12:54:53 -06:00
Todd C. Miller
cf707cf5f0
We want to inherit the gid from the parent directory when not setting
...
permissions on intermerdiate directories.
2016-10-30 06:36:55 -06:00
Todd C. Miller
bf62530acf
Move io_mkdir_parents() to its own file and use it in ts_mkdirs().
2016-10-29 12:45:57 -06:00
Todd C. Miller
271a07ff00
Make the I/O log file/dir permissions and owner configurable.
2016-10-29 12:45:55 -06:00
Todd C. Miller
7122a733ac
Create I/O log files with the same gid as the parent directory.
2016-10-26 14:18:58 -06:00
Todd C. Miller
3f022419ae
Be consistent with the naming of the variable used to store the
...
function return value. Previously, some code used "rval", some
used "ret". This standardizes on "ret" and uses "rc" for temporary
return codes.
2016-09-08 16:38:08 -06:00
Todd C. Miller
3e4c7eed31
Move the ignoring of I/O log plugin errors into the I/O log plugin
...
itself.
2016-08-17 14:38:00 -06:00
Todd C. Miller
ed18d0d5f8
Make the behavior when we cannot write to a log or audit file
...
configurable. File log failures are ignored by default for consistency
with syslog. Audit errors are ignored by default to allow the admin
to fix the issue. I/O log file errors are still fatal by default
since if I/O logging is activated it is usually to have an audit trail.
Bug #751
2016-08-17 07:22:51 -06:00
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