Commit Graph

12536 Commits

Author SHA1 Message Date
Todd C. Miller
f6291bf83e Move code to display a cmndspec in long form to display_cmndspec_long(). 2023-08-09 09:58:24 -06:00
Todd C. Miller
5a1a3ff74b sudo -ll: display the sudoers file the rule came from. 2023-08-09 08:50:56 -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
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
f6a9bb2e23 Use a single callback for sudoers_lookup() and add a closure pointer.
The single callback now receives all the match info (or UNSPEC if
no match was attempted).  This makes it possible to use the callback
for more than just printing testsudoers output.
2023-08-07 15:06: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
5f2a0a70e5 Fix printf format string mismatch now that 'i' is size_t. 2023-08-07 11:31:04 -06:00
Todd C. Miller
77f94f291a sudo_digest_getlen: return size_t, and 0 on error instead of -1
This is an API change, sudo_digest_getlen_v1 remains for binary
compatibility.
2023-08-07 08:43:13 -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
e5f2354c85 Move compat definition of ASN1_STRING_get0_data to hostcheck.c.
It is not used anywhere else.
2023-08-06 14:26:24 -06:00
Todd C. Miller
fc7bfd5046 Move OpenSSL compat defines to sudo_ssl_compat.h 2023-08-05 14:16:39 -06:00
Todd C. Miller
d6d467b92e Add implementation of SSL_read_ex/SSL_write_ex for those without. 2023-08-05 10:38:02 -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
d404f544fc Don't use sudo when building AIX packages
PolyPkg uses "sudo installp -l" to list the built package by default
but we may not have sudo privileges on the build host.
2023-08-01 11:20:54 -06:00
Todd C. Miller
002e22f846 Add --configure-only option to quit after the configure run.
This will be used to avoid building the entire package when we just
want the 32 or 64 bit sudo_intercept.so and sudo_noexec.so.
2023-08-01 11:05:59 -06:00
Todd C. Miller
8e22ede2a6 Parse --disable-python in mkpkg and don't override -m32 for Solaris.
We want to be able to build without python and to specify the memory
model when building 32-bit .so's for Solaris.
2023-08-01 09:36:39 -06:00
Todd C. Miller
0a181849a1 Add --enable-postinstall, an optional phase when building packages.
This makes it possible to run an arbitrary script between "make
install" and the polypkg run.  This will be used to copy different
word size versions of sudo_intercept.so and sudo_noexec.so.
2023-07-31 19:46:00 -06:00
Todd C. Miller
980e0216ac Add basic support for 32-bit and 64-bit LD_PRELOAD equivalents.
The noexec and intercept DSO settings may now include both a 32-bit
DSO and a 64-bit DSO specified by a colon.  For example:
/usr/libexec/sudo/sudo_intercept.so:/usr/libexec/sudo/sudo_intercept_64.so.
2023-07-31 13:46:57 -06:00
Todd C. Miller
7cb1f7f3a9 Cast TIOCSWINSZ to int to avoid overflow warning on 64-bit AIX. 2023-07-31 09:58:13 -06:00
Todd C. Miller
961f23af94 Read path section of sudo.conf for sudo_conf_intercept_path(). 2023-07-28 19:31:19 -06:00
Todd C. Miller
bdde6dfa11 visudo: document that a new file is only created if the editor writes it.
If visudo is used to create a new file, the file will only be created
if the user writes to the file via the editor.  Simply running
visudo and exiting the editor will no longer cause the file to be
created.  There is an exception for file created due to the addition
of a @include directive, which need to be present for the sudoers
file to parse properly.  GitHub issue #294.
2023-07-27 11:32:56 -06:00
Todd C. Miller
4f3786f70f visudo: do not create a new file if the user made no changes
This prevents visudo from creating a new zero-length sudoers file
if the user exited the editor without making any changes.  Files
created via a @include directive are preserved, even if empty, to
avoid a parse error.  GitHub issue #294.
2023-07-27 11:23:25 -06:00
Todd C. Miller
50fde5d815 Make the sections on bug reporting consistent with each other.
GitHub issue #292
2023-07-27 09:51:57 -06:00
Todd C. Miller
857653f9f5 Remove unused variable introduced in last commit. 2023-07-26 19:49:25 -06:00
Todd C. Miller
760c9c1107 Don't assume that if std{in,out,err} is a tty, it is the user's tty.
Previously, sudo only checked that the fd was a terminal, not that
it matched sudo's idea of the user's terminal.  This matters when
input or output is redirected to a different terminal.  In that
case we want to interpose the fd with a pipe even if it refers to
a terminal.  Bug #1056.
2023-07-26 19:43:49 -06:00
Todd C. Miller
14f1a12e2d testsudoers: add -L, -l and -v tests 2023-07-26 13:59:33 -06:00
Todd C. Miller
d62d704e55 testsudoers: display when a password is required 2023-07-26 11:14:45 -06:00
Todd C. Miller
75256516bd testsudoers: add -L, -l and -v options.
This makes it possible to test "sudo -l" and "sudo -v" using
testsudoers.
2023-07-26 10:37:52 -06:00
Todd C. Miller
538be58ac0 sudoers_lookup_pseudo: sync with sudoers_lookup_check
This makes sudoers_lookup_pseudo(), which is used for pseudo-command
like "list" and "validate" a bit more like sudoers_lookup_check().
Time of day checks are performed, and callbacks are supported.  We
cannot use the same code for regular commands and pseudo-commands
due to the "pwcheck == all" case.
2023-07-25 15:57:20 -06:00
Todd C. Miller
d486db46cf Fix user warning message for "sudo -l command" when not allowed.
Reported by the sudo-rs project.

There was a missing space between "list" and the actual command.
This also changes the output to include the command as specified
by the user, not the path found in the path.  Previously, if the
command did not exist it would not be included in the message.
2023-07-25 13:56:08 -06:00
Todd C. Miller
1a00423afd Add free function for sudo Python module.
This reduces the amount of memory leaked on unload.
2023-07-25 09:33:03 -06:00
Todd C. Miller
e59c487434 Document bug fixes in 1.9.14p3. 2023-07-24 14:24:18 -06:00
Todd C. Miller
09b9632699 Merge sudo_module_register_loghandler and sudo_module_set_default_loghandler.
We now create the LogHandler class for each interpreter in
python_plugin_init() instead of just once in sudo_module_init().
This fixes the crash seen in Py_EndInterpreter() with Python 3.12
and significantly reduces the number of leaked objects tracked by
MemorySanitizer.
2023-07-24 11:07:45 -06:00
Todd C. Miller
56b829f66b sudo_module_register_conv_message: fix copy pasta in debug_decl 2023-07-24 10:47:15 -06:00
Todd C. Miller
0462a4ee8c sudo_module_register_loghandler: clear sudo_type_LogHandler on error
Also add comments about PyModule_AddObject stealing a ref on success.
2023-07-22 08:33:04 -06:00
Todd C. Miller
b52c32f234 Use Py_XDECREF instead of manual NULL check + Py_DECREF 2023-07-22 08:32:17 -06:00
Todd C. Miller
4e6254fea2 Work around a crash with Python 3.12.
In sudo_module_set_default_loghandler() if we don't leak the reference
to py_loghandler we get a crash in Py_EndInterpreter() with Python
3.12.  This probably indicates a reference counting bug elsewhere.
2023-07-21 12:20:18 -06:00
Todd C. Miller
91ea599459 Unbuffer stdout so we don't miss output during a crash. 2023-07-21 10:48:20 -06:00
Todd C. Miller
8c4cec148e Use PyObject_CallNoArgs() where possible. 2023-07-21 10:47:28 -06:00
Todd C. Miller
ba5ef624f2 Make sudo_type_ConvMessage and sudo_type_LogHandler static.
They are not used outside their respective compilation units.
2023-07-21 10:46:16 -06:00
Todd C. Miller
432ac12128 Pass TEST_VERBOSE to all test programs. 2023-07-20 10:13:40 -06:00
Todd C. Miller
7499b2d274 All test programs should accept the -v option, even if it is ignored. 2023-07-20 10:10:05 -06:00
Todd C. Miller
e710f79420 Revert last change, wrong diff committed. 2023-07-20 07:49:17 -06:00
Todd C. Miller
a12dbfe909 We can rely on Py_FinalizeEx() to free sub-interpreters. 2023-07-19 09:16:51 -06:00
Todd C. Miller
2cb4835781 Adapt to changed formatting of a rejected result in Python 3.12 2023-07-20 07:46:28 -06:00
Todd C. Miller
adaba9c0f0 Remove trailing whitespace from test output. 2023-07-20 06:57:19 -06:00
Todd C. Miller
7a10cdc286 _python_plugin_new_interpreter switches to the new interpreter
No need to do PyThreadState_Swap in the caller.
2023-07-20 06:58:53 -06:00
Todd C. Miller
cc939297a1 Call PyImport_AppendInittab after pre-initialization.
Also remove redundant PyConfig settings.
2023-07-19 09:13:23 -06:00
Todd C. Miller
da60384ad8 Use Py_InitializeFromConfig() not Py_InitializeEx() for Python >= 3.8.
Avoids deprecation warnings on Python 3.12.
2023-07-18 20:18:38 -06:00