Todd C. Miller
2a29daee18
Clear the write bit from the I/O log timing file when it is complete.
...
This matches the behavior of sudo_logsrvd.
2020-05-18 13:16:29 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
0cf2e09e0c
Apply spelling fixes.
...
Fixes from PR #30 (ka7) and Bug #925 (fossies.org codespell)
2020-05-06 09:27:43 -06:00
Todd C. Miller
8186b98208
Adapt sudoers iolog client to log server dual port changes.
...
The TLS handshake now occurs before the ServerHello message is read.
This fixes potential man-in-the-middle attacks and works better with
TLS 1.3.
2020-05-05 13:23:26 -06:00
Todd C. Miller
132b943a2d
Only display error string once on I/O error.
...
We already include the error string in the format so no need to use
errno too.
2020-04-17 15:36:45 -06:00
Todd C. Miller
ae7bb12335
Free passwd and group caches in I/O plugin after log_warning(), not before.
...
The logging functions may try to use the cache via set_perms(PERM_ROOT).
2020-04-17 15:07:25 -06:00
Todd C. Miller
ea9b711a70
Write an extended I/O info log in JSON format.
...
This will be used by sudoreplay if it exists to get more information
about the command being replayed.
2020-03-29 05:05:08 -06:00
Todd C. Miller
bf2bc931ab
Revert change to initialize io_operations earlier.
...
Instead, check io_operations.open for NULL which is the case for
"sudo -V". Also move the early return in sudoers_io_open() for
"sudo -V" until after we have initialized debugging.
2020-03-01 13:36:54 -07:00
Todd C. Miller
f590f81b3c
Initialize io_operations earlier.
2020-02-28 07:03:15 -07:00
Todd C. Miller
5635c22f6b
Add --disable-log-server and --disable-log-client configure options.
...
These can be used to optionally disable building sudo_logsrvd and
support for remote I/O logging in the sudoers plugin respectively.
2020-02-26 13:17:40 -07:00
Todd C. Miller
b9bea25592
Read ServerHello message synchronously before the command is executed.
...
Otherwise, the command could be run before the TLS handshake completes.
2020-01-31 19:48:27 -07:00
Todd C. Miller
45e589d443
Pass back a failure or error string to the front end.
...
The audit_failure() function now stores the failure string.
This will allow an audit plugin to log the reason if the user's
request is a rejected.
2020-01-30 13:25:36 -07:00
Laszlo Orban
6f3f45aa24
sudoers: disable SO_KEEPALIVE socket option based on log_server_disable_keepalive flag in sudoers
2020-01-22 10:52:18 -07:00
Todd C. Miller
c3bd025052
Store the server host name and IP in client_closure_fill().
...
Also check for getpeername() and inet_ntop() failure.
2020-01-20 14:03:41 -07:00
Todd C. Miller
5a86073bd0
Portability fixes and correct path to hostcheck.h in MANIFEST.
...
Include sys/socket.h for getpeername().
Link with -lnsl on Solaris to get inet_pton().
2020-01-18 11:32:45 -07:00
Laszlo Orban
de02745a3f
save a pointer to the currently connected audit server in the closure object
2020-01-18 05:49:54 -07:00
Todd C. Miller
bbb9520c3a
Use SUDOERS_DEBUG_* not SUDO_DEBUG_* in debug_decl() for the sudoers plugin.
2020-01-15 14:11:18 -07:00
Todd C. Miller
486ee2b71f
debug_decl and debug_decl_vars now require a semicolon at the end.
2019-12-22 08:48:16 -07:00
Todd C. Miller
9d737441f4
Fix event loop called via I/O log close function.
...
We need to set events that were pending in the old base in the new one.
Fixes sending the final I/O log data and the ExitMessage to the server.
2019-12-07 08:42:12 -07:00
Laszlo Orban
a409d8f1fc
process tls config options
2019-11-28 15:58:56 +01:00
Todd C. Miller
3241b82a7e
Make a shallow copy of user_env in I/O plugin in case it is reallocated.
...
The policy plugin's session init function may reallocate the user
environment pointer. Fixes a use after free when PAM is used.
2019-11-18 10:29:11 -07:00
Todd C. Miller
82237194dd
Add support for logging to the log server
2019-11-15 13:41:51 -07:00
Todd C. Miller
5793023ffd
Add a plugin interface to sudo main event loop.
2019-11-15 13:36:01 -07:00
Todd C. Miller
ee91b7360b
Simplify expand_iolog_path()
2019-10-24 20:04:33 -06:00
Todd C. Miller
13e3eaad5f
Simplify iolog_set_user and iolog_set_group
2019-10-24 20:04:33 -06:00
Todd C. Miller
aaf5d0dc6e
Read logsrvd.conf in two steps: first read, then apply if OK.
...
This fixes a problem where when logsrvd.conf was reloaded while
running (due to SIGHUP) and there was an error we could end up with
a partial config.
2019-10-24 20:04:33 -06:00
Todd C. Miller
282263c113
Use openat(2) when opening files in the I/O log directory.
2019-10-24 20:04:31 -06:00
Todd C. Miller
059b55ce72
Refactor code in sudoers that creates I/O log files to share with logsrvd.
2019-10-24 20:04:31 -06:00
Todd C. Miller
c3ce3a84fb
Refer to user-ID and group-ID instead of "user ID" and "group ID"
2019-10-19 14:26:41 -06:00
Todd C. Miller
40bf4081be
Rename sudo_strtoid() to sudo_strtoidx() and add simplified sudo_strtoid()
2019-10-20 10:21:29 -06:00
Todd C. Miller
2512f6efbf
Use sudo_strtonum() explicitly instead of via a macro.
2019-10-14 10:09:30 -06:00
Todd C. Miller
3e56be3564
Store signal name, not number in I/O log timing file.
...
The "SIG" prefix is not used so, e.g. SIGTERM -> "TERM".
This makes the I/O log files portable from one system to another.
Older I/O log files with signal numbers can still be replayed.
2019-08-05 16:30:58 -06:00
Todd C. Miller
9d8f374397
Add ssizeof macro that returns ssize_t.
...
We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
2019-06-25 09:45:10 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
985600e7f0
Minor snprintf() usage tweaks:
...
1) don't assume snprintf() returns -1 on error, check for <0
2) when comparing return value of sizeof(foo), cast the sizeof, not the len
3) cast return value to void in cases where snprintf cannot fail
2019-01-20 07:49:48 -07:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
cf07dc0757
Add a suspend event type to the I/O log to log suspend/resume of
...
the command so we can skip that delay during replay.
2018-10-05 14:16:08 -06:00
Todd C. Miller
0d36ea9325
We cannot reuse last_time for the I/O log info file now that it is
...
a monotonic timer. Just call time(3) in write_info_log() directly.
2018-08-23 13:50:00 -06:00
Todd C. Miller
31e065c6ca
Remove unused struct script_buf
2018-08-21 10:30:42 -06:00
Todd C. Miller
3f1470ebed
Use a monotonic timer that only runs while not suspended for the
...
iolog timing values and write nsec-precision entries.
2018-08-19 09:55:08 -06:00
Todd C. Miller
afad4eb94d
Fix I/O log timing file on systems without a C99-compatible snprintf().
...
On those systems we use our own snprintf() that doesn't support
floating point. We don't actually need floating point in this case
since the we can print seconds and microseconds without using it.
2018-08-18 20:29:30 -06:00
Todd C. Miller
418bf793f7
Fix the return value of sudoers_io_change_winsize() on success.
...
Otherwise, we only log a single window size change.
2018-08-11 21:29:43 -06:00
Todd C. Miller
e2213dc1e3
Remove dead store, found by cppcheck.
2018-02-10 09:44:34 -07:00
Todd C. Miller
a885b952fb
Remove use of AC_HEADER_TIME, only obsolete platforms actually
...
need this. Also stop removing sys/time.h unless the source file
uses struct timeval.
2018-01-17 09:52:15 -07:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
f79a236533
Log window size change events in the sudoers I/O plugin.
...
Let sudoreplay parse a timing file with window change events
(currently ignored).
2017-07-12 05:47:28 -06:00
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