Commit Graph

11022 Commits

Author SHA1 Message Date
Todd C. Miller
788708c9ff Add intercept_authenticate sudoers option, defaults to false.
By default, sudoers will not require authentication of commands run
via an intercepted session.  To require authenticaton of subsequent
commands, enable intercept_authenticate in sudoers.
2021-08-09 15:50:26 -06:00
Todd C. Miller
13b89e9103 Make the log_children option only log and not check policy. 2021-08-09 15:50:25 -06:00
Todd C. Miller
258fa9d4f9 Add debug support to sudo_intercept.so 2021-08-09 15:50:25 -06:00
Todd C. Miller
9c3df47da9 Move preload_dso() to its own file and rename to sudo_preload_dso().
It now takes an intercept fd as an optional argument instead of a
list of extra variables to add.  This lets us check whether it is
already set to the expected value (and add it if not).
sudo_intercept.so now uses sudo_preload_dso() to make sure that
LD_PRELOAD and SUDO_INTERCEPT_FD are set properly before executing.
2021-08-09 15:50:25 -06:00
Todd C. Miller
60e76e3e35 Take control of the tty and save its settings before doing a policy check.
Otherwise the policy plugin won't be able to read the password.
2021-08-09 15:50:25 -06:00
Todd C. Miller
42598735d0 Call the approval plugin after the policy plugin accepts a command.
Previously, for intercepted commands we only called the policy plugin.
2021-08-09 15:50:25 -06:00
Todd C. Miller
4ff3f7604d Reduce the number of function args passed to plugin wrappers.
This makes sudo_settings, user_info, submit_argv, submit_envp and
submit_optind global.  This will be required for calling the wrapper
from outside of sudo.c where we may not have access to those
variables.
2021-08-09 15:50:25 -06:00
Todd C. Miller
840bf4b09d Add return values for most of the plugin function wrappers that returned void.
Previously, they would just exit if there was an error.
Now the error is passed back up the stack so we can use them in
sudo_intercept.so.
2021-08-09 15:50:25 -06:00
Todd C. Miller
4cf3d1c416 Implement sudo_intercept.so.
Uses protobuf to talk to main sudo process over a socketpair.
2021-08-09 15:50:25 -06:00
Todd C. Miller
d7380bb271 Implement the sudo side of the sudo_intercept.so communication. 2021-08-09 15:50:25 -06:00
Todd C. Miller
cede7dd92d Define protocol for sudo <-> sudo_intercept.so communication.
Uses google protocol buffers.
2021-08-09 15:50:25 -06:00
Todd C. Miller
5d4120fa5d Add separate convenience lib for protobuf-c
We need to use it for sudo <-> sudo_intercept.so communication.
2021-08-09 15:50:25 -06:00
Todd C. Miller
9d776b4e7b Allow multiple accept/reject messages during a logsrv conversation.
The log server now advertises a subcommands flag if it supports
logging subcommands (e.g. commands run from a sudo-spawned program
like a shell).  The client should only log additional commands
during a session if this flag is set in the ServerHello message.
2021-08-09 15:50:25 -06:00
Todd C. Miller
1ae9954c63 Use run_argv and run_envp passed into the audit plugin for event logging.
Previously we used NewArgv[] and env_get() but now that logging is
performed via an audit plugin we should use the values passed in.
2021-08-09 15:50:25 -06:00
Todd C. Miller
5e3ce532fe Allow set_perms(PERM_INITIAL) to be called more than once.
If the perm stack depth is non-zero when set_perms(PERM_INITIAL)
is called, rewind it first and re-initialize the stack depth to 0.
Fixes a user-after-free bug if set_perms(PERM_INITIAL) is called
multiple times.
2021-08-09 15:50:25 -06:00
Todd C. Miller
132936f8f0 Make it possible to call the sudoers policy check function multiple times.
We need to reset the Defaults values to their original state.
2021-08-09 15:50:25 -06:00
Todd C. Miller
a556b373c9 Allocate a socketpair to communicate with sudo_intercept.so over.
This is used for the intercept and log_children options.
2021-08-09 15:50:25 -06:00
Todd C. Miller
6287e8ca7d Add support for loading the sudo_intercept.so DSO. 2021-08-09 15:50:25 -06:00
Todd C. Miller
786e5865cb Add "intercept" Defaults setting to allow interception of sub-commands.
This causes "intercept" to be set to true in command_info[] which
the sudo front-end will use to determine whether or not to intercept
attempts to run further commands, such as from a shell.  Also add
"log_children" which will use the same mechanism but only log (audit)
further commands.
2021-08-09 15:50:25 -06:00
Todd C. Miller
b3e86c65b1 expand_prompt: use correct strlcpy() size parameter
The available size passed to strlcpy() was computed incorrectly.
Switch to updating the length after writing to the new prompt instead
of computing it each time.  The actual buffer size is computed and
allocated correctly so there is no real consequence to this bug.
Found by Qualys.
2021-08-09 08:19:40 -06:00
Todd C. Miller
14ffa00c06 The tls_verify setting only affects server behavior, not the client.
Originally, there was a flag in the ServerHello message to indicate
that the client should verify the server cert, but this was removed
TLS was moved to a separate port.  Client validation of the server
certificate is now configured in the sudoers file instead.
2021-08-03 09:50:07 -06:00
Todd C. Miller
57cb62d7dc On macOS, don't disable tty tickets and set password timeout to 0.
This more closely matches the options used by the macOS version of sudo.
2021-08-02 11:11:05 -06:00
Todd C. Miller
d1c29fb008 Add some debugging info to find_path() 2021-08-02 08:57:35 -06:00
Todd C. Miller
e4568ceafe iolog_mkdtemp: umask must not be more restrictive than the file modes.
We need this even though we will be calling mkdtemp() since the
umask affects the mode of any parent directories.
2021-07-30 13:55:26 -06:00
Todd C. Miller
8b009f62eb Plug memory leak in error path when sudoers cannot be opened. 2021-07-29 15:26:04 -06:00
Todd C. Miller
1032fca5b8 Trying to use "+=" or "-=" operators on a non-list is an error.
Previously, they were simply treated as "=" for non-lists.
2021-07-29 09:29:10 -06:00
Todd C. Miller
2ea773ed1f Plug a memory leak in check_net_ifs found by address sanitizer. 2021-07-29 09:29:09 -06:00
Todd C. Miller
40496f510b Prefix sanitizer and fuzzer options with -XCClinker in ASAN_LDFLAGS.
Otherwise libtool may ignore the options when linking.
2021-07-29 09:29:07 -06:00
Todd C. Miller
aee82efe45 Display the correct error message if X509_verify_cert() fails.
We must use X509_STORE_CTX_get_error() and X509_verify_cert_error_string()
instead of the generic OpenSSL error functions.
2021-07-27 14:49:28 -06:00
Todd C. Miller
d109cd61d9 In new_logline check for NULL args->reason for EVLOG_RAW.
This can't happen in practice since we never set EVLOG_RAW
without passing in a reason.  Coverity CID 237142 237143
2021-07-27 12:19:53 -06:00
Todd C. Miller
e00ed390d5 format_json: don't dereference evlog if it is NULL.
Also silence a PVS Studio false positive.
2021-07-27 10:45:35 -06:00
Todd C. Miller
625ab9d298 Bump version to 1.9.7p2 2021-07-26 18:03:14 -06:00
Todd C. Miller
8d23e26110 Sudo 1.9.7p2 2021-07-26 17:54:22 -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
532e00aa2b Only replace getaddrinfo for FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION.
This works around an issue on SCO which uses inline functions in
the header files which call the actual, versioned, library function.
2021-07-26 11:39:41 -06:00
MertsA
0a506b3801 Rewind utmp file pointer after searching for entry (#108)
getutline() advances the file pointer until it matches or reaches EOF. pututline() starts from the current position in utmp. This rewinds the file pointer to the beginning to avoid allocating additional spurious utmp entries.
2021-07-26 09:07:10 -06:00
Todd C. Miller
f8e05dd984 Use AC_CACHE_CHECK in place of AC_MSG_CHECKING + AC_CACHE_VAL where possible. 2021-07-25 19:29:25 -06:00
Todd C. Miller
4a90deb2a0 Add configure check for va_copy instead of using #ifdef
This prevents the va_copy compat #define from being used if
sudo_compat.h is somehow included before stdarg.h.
2021-07-25 15:51:23 -06:00
Todd C. Miller
b0ae7a566b Avoid using RLIM_INFINITY for the nofile soft limit to prevent
closefrom_fallback() from closing too many file descriptors.
2021-07-23 15:10:46 -06:00
Todd C. Miller
b48cd11a4b Include signal.h for SIG2STR_MAX and sig2str(). 2021-07-23 15:02:26 -06:00
Todd C. Miller
c234bab7b2 Remove unused info_cb and info arguments from eventlog_exit() 2021-07-15 11:07:25 -06:00
Todd C. Miller
fa7250ead7 Create a UUID and log it in the JSON version of the event log. 2021-07-15 11:07:25 -06:00
Todd C. Miller
0dd2b6442a Add log_exit setting in the sudo_logsrvd.conf eventlog stanza
This causes sudo_logsrvd to log a record with the exit status or
terminating signal in response to an ExitMessage.
2021-07-09 11:08:44 -06:00
Todd C. Miller
17a415ae77 Add log_exit_status sudoers option to log when a command exits.
This option defaults to off.
2021-07-09 11:08:44 -06:00
Todd C. Miller
b54a16e174 Add support for logging exit status events.
For sudo-formatted logs, this is a record with "EXIT=number" and
potentially "SIGNAL=name" after the command.  For JSON-format logs,
a new "exit" record is logged which contains an "exit_value" and
potentially "signal" and "core_dumped".  JSON-format logs now incude
a UUID to associate the "exit" record with the "accept" record.
2021-07-09 11:08:44 -06:00
Todd C. Miller
657897b8bf Check that the python module we actually loaded is what we intended.
This is intended to provide a more useful error message if the
user defines a module which conflicts with a system python module.
For example, a module called test.py would conflicts with the system
python test module.
2021-07-08 15:50:04 -06:00
Todd C. Miller
16f78f59ba Mention that xkcd inspired the sandwich logo. 2021-07-02 14:19:59 -06:00
Todd C. Miller
86680255ba Mention log server and fuzzers under Quest contributions. 2021-07-02 14:19:37 -06:00
Todd C. Miller
7a309d70bb Don't assume that the number of groups returned by getgroups() is static.
On systems where getgroups() returns results based on more than
just the per-process group vector in the kernel it is possible for
the number of groups to change in between invocations.
Based on GitHub PR #106 from Pierre-Olivier Martel.
2021-06-26 18:45:28 -06:00
Todd C. Miller
555596e57a Use "mandoc -Tlint -Wwarning" instead of -Wstyle.
The style checks now include "referenced manual not found" warnings
which is not helpful.
2021-06-26 18:20:25 -06:00