Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
cc15f847ac
Bump info_msgs_size to make room for the source.
2023-08-09 16:14:52 -06:00
Todd C. Miller
0b03511b85
Log source in JSON logs
...
This makes it possible to tell which rule resulted in a match.
2023-08-08 09:56:19 -06:00
Todd C. Miller
1e6c5f3e79
Fix checking of SSL_{read,write}_ex() return value.
...
These have a boolean-style return value. However, our emulated
versions can return -1 on error, which we need to preserve for older
versions of SSL_get_error() which expect it.
2023-08-08 10:18:57 -06:00
Todd C. Miller
184e03b4a9
ERR_get_error() returns unsigned long, not int.
2023-08-07 08:05:00 -06:00
Todd C. Miller
e6d14c95b6
Use SSL_read_ex() and SSL_write_ex() instead of SSL_read() and SSL_write().
2023-08-05 10:38:01 -06:00
Todd C. Miller
4891f37a45
sudo_logsrvd: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
f6d1542416
Move display of usage text into display_usage() so usage() always exits.
2023-07-04 19:47:28 -06:00
Todd C. Miller
e95bd883d7
Promote length/size/offset in struct connection_buffer to size_t.
2023-07-03 17:02:24 -06:00
Rose
45fdfa18f1
Mark functions not returning as sudo_noreturn
...
We also put NOTREACHED where it applies.
2023-07-01 17:40:16 -04:00
Rose
e54ba33ea0
Avoid compiler casting warnings by assigning to the same type where possible
...
This saves instructions that are related to casting as well as compiler warnings.
2023-06-28 17:25:26 -04:00
Todd C. Miller
b013711e48
Check for sudo_pow2_roundup() overflow.
...
Calling sudo_pow2_roundup(INT_MAX+2) will return since there is no
power of 2 larger than INT_MAX+1 that fits in an unsigned int.
This is not an issue in practice since we restrict messages to 2Mib.
2023-03-01 13:58:32 -07:00
Todd C. Miller
b6151781ce
Quiet some harmless PVS Studio warnings.
2022-06-29 10:08:55 -06:00
Todd C. Miller
54ed54d94e
Use "unable to allocate memory" warning on malloc failure.
...
This is consistent with the rest of the sudo source code.
2022-06-29 10:00:03 -06:00
Todd C. Miller
3e21c8da5c
Add missing PVS Studio Open Source comments.
...
Also avoid checking protobuf-c source and protobuf-c generated files.
2022-06-29 09:45:04 -06:00
Todd C. Miller
e5834bd405
Use #include <config.h> not #include "config.h" for consistency.
...
Otherwise, some compilers may do the wrong thing in a build
dir if there is a config.h file in the source dir too.
2022-06-29 08:47:16 -06:00
Todd C. Miller
13672f28df
Make sudo pass -Wwrite-strings
2022-06-28 16:33:15 -06:00
Todd C. Miller
f5ac1317c4
Make sudo pass -Wmissing-prototypes
2022-06-27 12:48:03 -06:00
Todd C. Miller
161b01fccd
Treat EINTR in a callback like we do EAGAIN.
...
We shouldn't get EINTR in practice since we set SA_RESTART when
registering signal handlers but it doesn't hurt to be consistent.
2022-06-07 09:25:07 -06:00
Todd C. Miller
db6fc237c4
If write(2) returns EAGAIN just re-enter the event loop.
...
This is consistent with how we handle EAGAIN for read(2).
2022-06-06 19:42:06 -06:00
Todd C. Miller
38c6e1bffb
Standardize protobuf "unable to unpack" warning messages.
2022-05-26 09:35:18 -06:00
Todd C. Miller
d7df7abf87
If ERR_reason_error_string() returns NULL, fall back on strerror(errno).
...
That way we get reasonable error messages for missing files, etc.
2022-05-17 09:18:03 -06:00
Todd C. Miller
cc6157d7d4
Add support for WolfSSL's OpenSSL compatibility layer.
...
Based on changes from Hayden Roche
2021-10-25 13:17:57 -06:00
Todd C. Miller
87c1dd9d7d
Move include of log_server.pb-c.h into logsrvd.h and sendlog.h
...
This way there is no include file order issue with the
PROTOBUF_C_VERSION_NUMBER check.
2021-10-25 12:25:24 -06:00
Todd C. Miller
e73e9d5e47
sudo_sendlog: send runenv, rungid and runuid from log.json too
...
With this change, sudo_sendlog can now round-trip sudo-style I/O
logs that use the newer log.json format without losing any information.
2021-10-23 09:04:26 -06:00
Todd C. Miller
14873832c6
sudo_sendlog: send multiple I/O log records together if possible
...
Try to fill the write buffer and then send to the server instead
of sending records one at a time.
2021-10-20 19:16:23 -06:00
Todd C. Miller
1a26d2c883
sudo_sendlog: support multiple write buffers like sudo_logsrvd
2021-10-20 19:03:19 -06:00
Todd C. Miller
5eebc30987
sendlog: use runargv from log.json if available
2021-10-19 09:42:48 -06:00
Todd C. Miller
a71d1f7ce6
sudo_sendlog: send exit data in eventlog if present
2021-10-19 09:42:46 -06:00
Todd C. Miller
70aef0eb2d
sudo_debug_register: add minfd argument to specify lowest fd number
...
Use this in sudo_intercept.so to avoid allocating a low-numbered
fd which the shell reserves for use by scripts.
2021-08-26 09:57:24 -06:00
Todd C. Miller
0e2094471b
Call shutdown() on sockets before closing() if they are connected.
...
This should ensure that the other side sees any queued data before
the connection is dropped.
2021-08-11 14:08:48 -06:00
Todd C. Miller
79129613e5
If SSL_shutdown() returns 0 it needs to be called one more time.
2021-08-11 10:16:36 -06:00
Todd C. Miller
5a3bbba12b
Use sudo_warnx?() instead of sudo_debug_printf for errors.
...
We now hook the warn functions so the messages are logged.
The messages still show up in the debug log too.
2021-06-15 13:58:12 -06:00
Todd C. Miller
9d734d57e7
sudo_sendlog: rename -m (max-time) to -s (stop-after).
2021-05-04 12:14:02 -06:00
Todd C. Miller
7376fa632f
Add "-m elapsed" option to specify the max elapsed time of records to send.
...
Useful for testing the ability of the server to handle restarted log
transfers.
2021-05-04 08:22:34 -06:00
Todd C. Miller
109a0331a5
Don't hard-code the TLS connect timeout, use normal connect timeout.
...
For sudo_logsrvd, this is the relay connect_timeout setting.
For sudoers, this is the log_server_timeout setting.
2021-05-03 09:01:00 -06:00
Todd C. Miller
b1c4de2088
Add support for relaying to another sudo_logsrvd via TLS.
2021-04-06 14:44:19 -06:00
Todd C. Miller
72c40ae0e1
Move common TLS client code to tls_client.c and use it in sendlog.c.
2021-04-06 14:44:19 -06:00
Todd C. Miller
71e5275a1c
Move common TLS initialization code to tls_init.c.
2021-03-10 16:29:27 -07:00
Todd C. Miller
5a79841208
Return NULL if init_tls_client_context() fails.
...
Otherwise, we will call SSL_new with a freed SSL context.
Bug #970
2021-03-31 07:57:09 -06:00
Todd C. Miller
dceab7d756
Break up the long help string into multiple printf() statements.
...
AIX xlc compiler doesn't like cpp directives in between strings.
Also fixes a complaint from cppcheck and makes translation easier.
2021-01-28 08:53:25 -07:00
Todd C. Miller
de58c11dba
Set server_name before initiating TLS connection so verify function works.
...
Fixes a crash in the SSL_VERIFY_PEER callback. Also call inet_ntop(3)
with addr pointer, not sockaddr pointer so we get the correct IP address.
2020-11-02 09:30:45 -07:00
Todd C. Miller
e0c2635fb3
Apply Google inclusive language guidelines.
...
Also replace backwards with backward.
2020-10-30 10:15:30 -06:00
Todd C. Miller
db72498257
Use struct eventlog in place of struct iolog_info.
2020-10-26 15:31:41 -06:00
Todd C. Miller
eaa95acb31
Post-process protoc-c files to avoid depending on anonymous unions.
...
Based on a patch from Michael Osipov.
GitHub issue #60
2020-09-04 13:17:51 -06:00
Todd C. Miller
961a4afe67
Fix some warnings from pvs-studio
2020-08-12 13:45:09 -06:00
Todd C. Miller
cbad17a994
Move inclusion of compat headers up with the system headers.
...
Now that sudo_dso_public is defined in config.h we don't need sudo_compat.h
before including the compat headers.
2020-08-12 10:07:07 -06:00
Todd C. Miller
985af422d2
Rename __dso_public -> sudo_dso_public and move to config.h.
2020-08-12 09:57:42 -06:00
Todd C. Miller
076d0376db
We no longer need to include sudo_gettext.h before sudo_compat.h
2020-08-12 09:50:35 -06:00
Todd C. Miller
63dadad9df
Refactor freeing of InfoMessage list into free_info_messages().
...
Also fixes a false positive from the clang analyzer.
2020-08-07 14:22:28 -06:00