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
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
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
Rose
5d758264ab
Give every printf-like function restrict qualifiers
...
The format value has to be a string literal, every time.
Otherwise, you are not using these functions correctly. To reinforce this fact, I putrestrict over every non-contrib example of this I could find.
2023-07-07 20:23:20 -04:00
Todd C. Miller
0c85f10c80
python plugin: silence -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
b926df1df2
Make the debug subsystem unsigned.
...
It was already unsigned in sudoers but not in the front-end or the
python plugin. Making this consistent resolves a lot of -Wconversion
warnings. Also clean up some other -Wconversion warnings in sudo_debug.c.
2023-07-01 16:14:50 -06:00
Todd C. Miller
a28d2d4128
Python may be built with 32-bit time_t support on 32-bit platforms.
...
We need to undef the SIZEOF_TIME_T from pyconfig.h so it does not
conflict with our own.
2023-06-11 14:05:02 -06:00
Todd C. Miller
d4c6ef1222
Add adminconfdir and --enable-adminconf to set it.
...
Configuration paths in sudo are now a colon-separated list of files
with the adminconfdir instance first (if enabled), followed by a
sysconfdir instance.
2023-05-02 10:37:39 -06:00
Todd C. Miller
2845ceafb0
Handle "locale -a" returning both C.UTF-8 and C.utf8.
...
It is possible to have mutiple matches from the output of "locale
-a". Just take the first one. Fixes GitHub issue #241 .
2023-02-15 13:49:04 -07:00
Todd C. Miller
7ff70c09fe
Update expected plugin version.
2023-01-18 13:53:33 -07:00
Todd C. Miller
3f095ff1b5
Disable sudo_debug tests when fuzzing.
...
The debug code is disable when fuzzing is enabled to avoid coverage
issues.
2022-12-29 12:38:00 -07:00
Todd C. Miller
fa1b86fca6
Remove the Python plugin import blocker code.
...
The sudo.conf file is considered a trusted source of information
and these checks suffer from TOCTOU issues anyway.
2022-12-26 07:43:55 -07:00
Todd C. Miller
0e6482e827
Add missing memory allocation failure checks.
...
Inspired by GitHub PR #221
2022-12-15 09:30:49 -07:00
Todd C. Miller
f26a2e7626
Fix some dead stores noted by PVS Studio.
...
Since rc is initialized to SUDO_RC_ERROR there is no need to set
it to SUDO_RC_ERROR again on failure if rc has not been changed
since initialization.
2022-12-11 13:46:04 -07:00
Todd C. Miller
3df7b64d80
Fix failure in check targets when there is no UTF-8 C locale.
2022-12-06 16:26:34 -07:00
modric
cbdc4883d1
Fix some typos
2022-11-21 14:50:22 +08:00
Todd C. Miller
5683fc6f7a
The name of the C locale w/ UTF-8 support is not always C.UTF-8.
...
Use a pattern to find it (if present) and use that value instead
of hard-coding C.UTF-8. This works around a leak sanitizer crash
on certain inputs.
2022-11-11 07:05:21 -07:00
Todd C. Miller
f360a8006c
Regen dependencies
2022-09-27 14:16:03 -06:00
Todd C. Miller
3ca9220e50
Implement find_spec, not the deprecated find_module.
...
Fixes a test failure due to find_module having removed from setuptools.
2022-09-27 09:03:33 -06:00
Todd C. Miller
86c108b50b
Add mkdtempat() and mkostempsat() for systems without them.
2022-09-21 19:08:11 -06:00
Todd C. Miller
a326411903
Use $(GREP) and $(EGREP) variables in Makefile.in files.
2022-09-12 16:30:52 -06:00
Todd C. Miller
9c61d7e6e9
Bump the sudo plugin minor version.
...
The "update_ticket" entry was added to the settings list and the
"intercept_verify" entry was added to the command_info list.
2022-08-02 14:28:29 -06:00
Todd C. Miller
f6e4d2765a
Add explicit include of unistd.h for getopt(3) and related variables.
2022-07-05 11:35:25 -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
9ac42292d1
Bump plugin minor version and document new intercept-related settings.
...
There should have been a minor version bump for sudo 1.9.8 when
intercept was originally implemented.
2022-05-26 09:19:08 -06:00
Todd C. Miller
930271847a
clean_output: prune lines that consisting of '^' characters and whitespace.
...
Starting with Python 3.11, backtraces may contain a line with '^'
characters to bring attention to the important part of the line.
Also replace "REJECT" with "0" in backtrace output for Python 3.11.
2022-04-11 19:05:06 -06:00
Todd C. Miller
dcb2fb26a5
Rename SSP_(C|LD)FLAGS -> HARDENING_(C|LD)FLAGS
2022-04-01 11:14:59 -06:00
Todd C. Miller
1f64aca229
Unset LANGUAGE when running tests, otherwise it may override LC_ALL.
...
Bug #1025 .
2022-03-14 13:51:03 -06:00
Todd C. Miller
dfda098ae7
Deinit python subinterpreters in reverse order (last to first).
...
This appears to work around a crash on OpenBSD with Python 3.9.10.
2022-03-06 18:39:12 -07:00
Todd C. Miller
c131b27474
For 'make check-verbose' run fuzzers with -verbose=1
...
This is the default for libFuzzer but not for the stub fuzzer lib.
2022-03-03 10:45:56 -07:00
Todd C. Miller
cdee5d48da
Add check-verbose Makefile target that runs tests in verbose mode.
2022-03-02 13:32:08 -07:00
Todd C. Miller
dda14cb57a
Less verbose output unless the -v option is used.
...
Also display a test summary at the end.
2022-03-01 16:09:32 -07:00
Todd C. Miller
853e710f4a
Only emulate Py_FinalizeEx for Python 3.[0-5].
2022-01-12 13:07:21 -07:00
Todd C. Miller
def7a51f4d
Bump plugin version in test data to 1.18.
2021-11-09 13:59:36 -07:00