Commit Graph

11104 Commits

Author SHA1 Message Date
Todd C. Miller
9077daee93 Avoid clobbering errno in warning(). 2021-05-01 11:35:19 -06:00
Todd C. Miller
bc82430a6f Set relay name string to NULL after dropping the reference.
Otherwise it is possible to decrement the reference more than once.
2021-05-01 08:48:24 -06:00
Todd C. Miller
af0345e238 Fix cut & pasto that prevented the verify_server option from being set.
The "log_server_verify" setting passed from the policy plugin was
applied to the "keepalive" option instead of "verify_server".
From Krisztian Kovacs.
2021-04-30 11:03:23 -06:00
Todd C. Miller
01bdfd3be2 Write client and server information to debug file on SIGUSR1
This can be used to debug client problems such as a connection
not being closed as expected.
2021-04-29 16:20:02 -06:00
Todd C. Miller
cefa72c6a6 Document journal file directories in store_first mode. 2021-04-29 14:34:54 -06:00
Todd C. Miller
f92bb8840c Create journal files in an incoming directory, move to outgoing when complete.
This will make it possible to process completed journal files
periodically if the relay server is down.
2021-04-29 14:19:08 -06:00
Todd C. Miller
5c593d5a4a Add missing connection_close() call for relay-only connections.
For an immediate relay we will close the connection when the client
disconnects (or there is a timeout).  However, for store-and-forward
mode the client has already disconnected at the time we are relaying.
2021-04-29 14:19:07 -06:00
Todd C. Miller
d4bdc85d74 Replace non-ascii characters in warning string. 2021-04-27 16:39:43 -06:00
Todd C. Miller
ac878d3e27 Quiet clang analyzer false positive in regress tests. 2021-04-27 15:56:24 -06:00
Todd C. Miller
84a01d3a93 Move local iolog log functions to logsrvd_local.c 2021-04-27 14:46:27 -06:00
Todd C. Miller
6d8942e82c Better client error reporting on relay server connection error.
More detailed error messages may be found in the debug log.
2021-04-27 12:25:19 -06:00
Todd C. Miller
e55991f244 Update debug pid string when sudo_logsrvd becomes a daemon. 2021-04-27 08:57:11 -06:00
Todd C. Miller
f25275ad5b Must call SSL_shutdown() before closing the underlying socket.
This got broken by some code rearrangement when relay mode was added.
2021-04-26 19:07:40 -06:00
Todd C. Miller
67029f3cc4 Recover if the client or relay server closes the TLS connection uncleanly.
The other end of the connection should perform a proper TLS shutdown
but as long as we are in the correct state there is no need to treat
this as a user-visible error.
2021-04-26 17:05:34 -06:00
Todd C. Miller
66c6edada2 Sudo 1.9.7 2021-04-26 13:12:28 -06:00
Todd C. Miller
8a65893435 Add a suppression file for the libpython leaks.
This is a big hammer but it seems like the best we can do for now.
Allows "make check" to succeed when address sanitizer is used.
2021-04-26 08:58:00 -06:00
Todd C. Miller
6907376ae9 When spliting EDITOR check for escaped quote characters.
Also add check_editor to sudoers "make check".
2021-04-25 19:12:50 -06:00
Todd C. Miller
5e5131dec3 Treat a lone backslash at the end of a string as a literal backslash.
GitHub issue #99
2021-04-24 14:19:46 -06:00
Todd C. Miller
d6d2e3488b Fix typo. 2021-04-24 13:23:25 -06:00
Todd C. Miller
a85c6b41a6 Avoid a potential NULL dereference when mutating args_str.
Coverit CID 221401
2021-04-23 19:05:45 -06:00
Todd C. Miller
65a55497ec Avoid calling fread() with a NUL buffer if msg_len is 0.
Coverity CID 221399
2021-04-23 19:01:44 -06:00
Todd C. Miller
d9f0eba1fa Set a restrictive umask so new files are only read/write by owner.
Coverity CID 221402
2021-04-23 18:58:55 -06:00
Todd C. Miller
bfd5803bd2 In connection_closure_free() only close sock if it is not -1.
When relaying from a journal there will be no socket.
Coverity CID 221403
2021-04-23 17:02:35 -06:00
Todd C. Miller
57b8122cf3 Avoid potential NULL dereference in get_free_buf().
Coverity CID 221400
2021-04-23 16:56:29 -06:00
Todd C. Miller
21641a27e4 Remove some now-dead code in the error path.
Coverity CID 221397 and 221398
2021-04-23 16:56:23 -06:00
Todd C. Miller
761b02d34f Use function pointers for each client message type instead of conditionals.
This separats out the message handler from the functions that store
or relay the message contents.
2021-04-23 16:56:21 -06:00
Todd C. Miller
64ac63918e Add enqueue_error_message() helper function.
Formats and enqueues an error message and enables the write event.
2021-04-23 16:56:20 -06:00
Todd C. Miller
050e91f8d1 Forward the journaled entry after it has been stored locally. 2021-04-23 16:56:18 -06:00
Todd C. Miller
280fabac38 Stash the value of the store_first config setting in connection_closure.
If the configuration changes it should not affect a connection that
is already in progress.
2021-04-23 16:56:17 -06:00
Todd C. Miller
c2d3070fa1 Journal messages to disk when store_first is set in the relay section.
Instead of forwarding messages immediately, they are journaled
locally in wire format.
This will be used to implement relay store-and-forward mode.
2021-04-23 16:55:30 -06:00
Todd C. Miller
6f5b353e87 Add configuration for sudo_logsrvd store-and-forward mode.
Adds "relay_dir" and "store_first" settings to sudo_logsrvd.conf
in the [relay] section.  Also adds a --with-relaydir configure
argument to change the default value (usually /var/log/logsrvd-relay.
2021-04-23 16:54:15 -06:00
Todd C. Miller
727056e0c9 Make sure SIGCHLD is not ignored when sudo is executed.
If SIGCHLD is ignored there is a race condition between when the
process is executed and when the SIGCHLD handler is installed.
This fixes the bug described by GitHub PR #98
2021-04-23 07:41:27 -06:00
Todd C. Miller
b0a32fe738 Remove the HP-UX 11.0 pread64() hack, it causes problems on modern HP-UX. 2021-04-20 14:59:19 -06:00
Todd C. Miller
6717415e73 Add minimum value to consider when overriding resource limits.
Currently only used for RLIMIT_DATA and RLIMIT_AS.

This works around a problem on HP-UX where setting RLIMIT_DATA
changes the resource limits for both 32-bit and 64-bit processes.
HP-UX processes start out with RLIMIT_DATA set based on the values
of the maxdsiz and maxdsiz_64bit kernel tunables, depending on
whether they are 32-bit or 64-bit.  By default this limit is 1GB
for 32-bit processes and 4GB for 64-bit.  However, once RLIMIT_DATA
is changed, it does not appear to be possible to restore the old
values.  This can result in a 64-bit process that is executed by a
32-bit shell getting the 32-bit RLIMIT_DATA instead of the 64-bit
one.  Bug #973
2021-04-20 14:31:40 -06:00
Todd C. Miller
32f742389b Don't use msg_len as a length after converting it to network byte order. 2021-04-19 16:28:18 -06:00
Todd C. Miller
110d9667e5 Use the packed message buffer when relaying if possible.
There's no need to rebuild the message buffer for anything but
RestartMessage and ClientHello.
2021-04-19 09:44:37 -06:00
Todd C. Miller
935daf6b7e Allocate the data buffer in get_free_buf() too.
We always know the size of the data buffer we need at allocation time.
2021-04-18 17:10:53 -06:00
Todd C. Miller
3dce67ec10 Relay ChangeWindowSize and CommandSuspend events too. 2021-04-17 07:59:13 -06:00
Todd C. Miller
7c2224584d Regenerate test output with python 3.10a7
Also adjust debug tests so they pass on older python versions
2021-04-16 15:24:12 -06:00
Todd C. Miller
5ffa915c9c determine Python (3.10) version number correctly.
from upstream automake
2021-04-16 14:06:07 -06:00
Todd C. Miller
fbbf602664 Move python.m4 and runlog.m4 to the m4 directory.
Previously they were inline in aclocal.m4.
2021-04-16 13:41:43 -06:00
Todd C. Miller
d76cc96af6 Add hiuxmpp where we have hpux for special cases.
Also move the HP-UX 11.00 pread(2) workaround into the section where
pread(2) is tested for, not before it.
2021-04-15 13:07:13 -06:00
Todd C. Miller
620b0dec86 Only replace the last instance of "sudo" in example and doc dir.
Otherwise we end up with weird paths for a prefix like /opt/sudo.
2021-04-15 10:31:28 -06:00
Todd C. Miller
a1323ba43b Fix lint warning. 2021-04-13 14:29:59 -06:00
Todd C. Miller
556b8f62cb Mention relay mode and update TLS example. 2021-04-13 14:24:50 -06:00
Todd C. Miller
d028410bf7 If libssl_dep was not passed in, use ldd to determine its value.
Normally, mkpkg will figure this out, but if the user does "make
package" outside of the mkpkg script, libssl_dep will not be set.
2021-04-13 10:00:57 -06:00
Todd C. Miller
28d41cecad Enable the use of OpenSSL if log client/server not disabled.
This adds a dependency on OpenSSL unless it is explicitly disabled
(--disable-openssl) or the sudo log client and server are disabled
(--disable-log-client and --disable-log-server).
2021-04-12 14:10:49 -06:00
Todd C. Miller
b8fda5b0a9 configure aux scripts moved to the scripts directory 2021-04-09 16:30:39 -06:00
Todd C. Miller
4e9baba2b5 Set logsrvd_config to NULL in logsrvd_conf_cleanup() after freeing it.
Fixes a double free in fuzz_logsrvd_conf (but not sudo_logsrvd itself).
Also fix linking fuzz_logsrvd_conf with OpenSSL.
2021-04-09 14:02:50 -06:00
Todd C. Miller
e4e0e734b9 Update sudo_logsrvd.conf fuzzer to match configuration changes. 2021-04-09 13:34:36 -06:00