Todd C. Miller
432b085558
log_server_open: always pass in awake time, not wallclock time.
...
The timespec passed to log_server_open() should be from
sudo_gettime_awake() since it is used to build the command run time.
2023-11-23 09:08:04 -05:00
Todd C. Miller
6965e1b0aa
log_server_alert: use fmt_alert_message not fmt_reject_message
...
Only affects intercepted commands.
2023-11-23 09:08:04 -05:00
Todd C. Miller
13dec64f3d
log_server_alert: struct timespec argument was not actually used
...
The struct timespec argument is used to initialize the command
start time, which is not used for an alert message.
2023-11-23 09:08:04 -05:00
Todd C. Miller
3bbc7c8f85
Store submitenv in eventlog and pass it to sudo_logsrvd.
2023-10-22 08:36:44 -06:00
Todd C. Miller
726b646b48
struct eventlog: rename argv/env to runargv/runenv.
...
This matches the JSON logs.
2023-10-21 19:15:46 -06:00
Todd C. Miller
1398289fab
Add casts when storing values in a struct timespec.
...
Fixes -Wconversion warnings on some 32-bit systems where time_t is
still 32-bit.
2023-09-27 15:11:10 -06:00
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
e178b85821
Store the source of the matching rule and store in the event log.
...
The JSON logs will store the matching rule source.
2023-08-08 09:57:09 -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
861ed2b7d4
We now must pass "err" SSL_get_error(), not "nread".
2023-08-07 07:59:58 -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
56828f6412
fmt_info_messages: don't include ttyname if it is NULL
...
The NULL check was commented out for testing but should have been
restored. Fixes a potential protocol error message from sudo_logsrvd.
2023-07-11 14:15:46 -06:00
Todd C. Miller
a38b714667
sudoers plugin: silence most -Wconversion warnings.
2023-07-07 15:07:04 -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
Todd C. Miller
56a431f7ea
Make sudo_pow2_roundup() operate on size_t.
2023-07-03 16:51:05 -06: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
0b2e662b2e
Protect use of AF_INET6 with HAVE_STRUCT_IN6_ADDR guards.
...
From Tim Rice.
2023-01-31 12:22:47 -07:00
Todd C. Miller
f066ff9e01
Eliminate a few harmless dead stores.
...
Quiets warnings from Infer.
2022-11-22 11:18:24 -07:00
Todd C. Miller
e6f2ad0ed6
Add missing NULL checks for mandatory fields in protobuf messages.
...
Also no longer reject an InfoMessage with an unknown value_case,
just log and ignore it.
2022-09-28 08:47:25 -06:00
Todd C. Miller
9150423676
Don't send ttyname to log server if it is NULL.
...
Otherwise the log server will reject the AcceptMessage because a
NULL string is not allowed.
2022-09-27 15:30:02 -06:00
Todd C. Miller
b6151781ce
Quiet some harmless PVS Studio warnings.
2022-06-29 10:08:55 -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
d04810c4f2
Save a pointer to the event_alloc parameter in the plugin open function.
...
That way we don't need to pass event_alloc around to the log client
functions.
2022-06-09 13:05:21 -06:00
Todd C. Miller
c20c3b5631
Only display "unable to connect to log server" warning once.
...
Previously, in intercept mode, if the log server is unreachable the
message would be printed for each sub-command.
2022-05-31 20:03:17 -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
c7ed03c986
sudo_logsrvd: update elapsed time for winsize and suspend in journal mode
...
Fixes a bug in store-first relay mode where the commit point messages
sent by the server were incorrect.
2022-04-24 17:26:05 -06:00
Todd C. Miller
c236d58b5a
Set client_closure to NULL after freeing it.
2022-02-03 10:55:45 -07:00
Todd C. Miller
3f1bb7bc97
client_closure_alloc: init write_bufs/free_bufs before other allocations.
...
We must initialize the tail queues before any possible call to
client_closure_free(), such as due to malloc() failure.
2022-02-03 10:40:03 -07: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
00f0c233b2
Only include log_client.h if SUDOERS_LOG_CLIENT is defined.
2021-10-21 19:46:35 -06:00
Todd C. Miller
0eb677b74a
Only store the first log id received from the server.
...
Plugs a small memory leak in intercept mode if the log server sends
the log ID again for sub-commands.
2021-09-20 07:49:31 -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
2e99450d40
Fix logging intercepted commands to a log server in sudoers.
...
Only available when the server supports the subcommands capability.
2021-08-09 15:50:26 -06:00
Todd C. Miller
36fbb13c4c
Use TLS_method() instead of TLS_client_method() throughout.
...
OpenSSL returns an error for SSL_accept() if TLS_client_method()
was used to generate the context (LibreSSL doesn't care).
Prior to sudo 1.9.7, TLS_client_method() and TLS_server_method()
were used in the TLS client and server initialization code respectively.
This was refactored in sudo 1.9.7 to allow the code to be shared.
Bug #988
2021-07-26 13:40:25 -06:00
Todd C. Miller
78849e6728
Don't include errno in "unable to connect to log server" message.
...
There should be a more specific message, usually with an error
string, displayed earlier.
2021-05-12 12:19:44 -06:00
Todd C. Miller
f2155c704f
Better warning when close function is passed a non-terminal signal.
2021-05-10 13:45:25 -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
376ad5e6b4
Do not add an unfinished write buffer to the queue if it is already present.
...
In client_msg_cb() we only remove a buffer from the queue when it is
finished. Inserting the buf again can cause a cycle in the queue.
2021-01-21 12:46:48 -07:00
Todd C. Miller
eb536d8b7c
Fix problem when SSL_read() returns SSL_ERROR_WANT_WRITE. This can
...
happen when the socket cannot be written to immediately.
We need to set the read_instead_of_write flag in that case, _not_
write_instead_of_read. Also sync comments with sendlog.c.
Bug #954
2021-01-20 11:25:23 -07:00
Todd C. Miller
67e6e2085a
Reduce the number of error messages when we can't connect to the audit server.
...
Add the error string to "unable to connect to log server" instead of
using an extra error message for the connect(2) failure.
2020-12-03 13:20:18 -07:00
Todd C. Miller
a19f242796
Use correct error message when the TLS connection is dropped.
...
Was: "recv: Unknown error 0", now: "lost connection to log server".
2020-12-03 11:42:20 -07:00
Todd C. Miller
cb87253d1e
It is possible for evlog->argv or evlog->envp to be NULL.
2020-11-17 13:43:31 -07:00
Todd C. Miller
72df19088b
Refactor code to format the client message after the hello.
2020-11-09 18:32:37 -07:00
Todd C. Miller
9779009fae
Add info_msgs to AlertMessage and populate it.
...
This lets us log eventlog info along with the alert if it is available.
2020-11-09 17:15:11 -07:00