Todd C. Miller
adaba9c0f0
Remove trailing whitespace from test output.
2023-07-20 06:57:19 -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
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
modric
cbdc4883d1
Fix some typos
2022-11-21 14:50:22 +08:00
Todd C. Miller
86c108b50b
Add mkdtempat() and mkostempsat() for systems without them.
2022-09-21 19:08:11 -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
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
def7a51f4d
Bump plugin version in test data to 1.18.
2021-11-09 13:59:36 -07:00
Todd C. Miller
7c2224584d
Regenerate test output with python 3.10a7
...
Also adjust debug tests so they pass on older python versions
2021-04-16 15:24:12 -06:00
Todd C. Miller
bdf5530014
Set pp_ignore_define_body=false in uncrustify config.
...
Need to work around a bug that produces closed brace errors,
see https://github.com/uncrustify/uncrustify/issues/2569
2020-11-23 10:47:47 -07:00
Todd C. Miller
d688f4d34e
Back out regex use in python tests, filter the output instead.
...
This makes it possible to regenerate the test output again.
Also adds an update_test_data target to the Makefile.
2020-11-11 19:04:01 -07:00
Todd C. Miller
fe9e65754c
Add event_alloc to the audit plugin API.
...
The sudoers audit plugin will use this to communicate with sudo_logsrvd.
2020-11-02 15:28:21 -07:00
Todd C. Miller
c4a579cf8a
Pass resource limits values to the plugin in user_info[]
...
Sudo resets the resource limits early in its execution so
the plugin cannot tell what the original limits were itself.
2020-08-31 16:37:01 -06:00
Todd C. Miller
3e12b99eed
Check asprintf() return value.
2020-06-06 19:13:21 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
26b599a5b1
Add missing sys/wait.h include; fixes a compilation problem on musl libc.
2020-05-15 19:08:16 -06:00
Todd C. Miller
0cf2e09e0c
Apply spelling fixes.
...
Fixes from PR #30 (ka7) and Bug #925 (fossies.org codespell)
2020-05-06 09:27:43 -06:00
Todd C. Miller
75b9a26a37
If the signal.Signals enum is not present, search the dictionary.
...
The Signals enum was added in Python 3.5. If it is not present we
need to iterate over the dictionary items, looking for signal name
to number mappings. Fixes the signal tests with Python 3.4.
2020-04-09 10:49:59 -06:00
Todd C. Miller
57cef10ce9
Python dictionaries are sparse so we cannot use pos as an index.
...
When converting sudo options from a dictionary to a tuple we need
to track the current index into the tuple separately from the
position of the dictionary entry.
2020-04-09 08:34:29 -06:00
Todd C. Miller
cd74b83c21
Make most python tests pass with Python 3.4
...
Dictionary order is not stable in Python < 3.6 so we need to sort
by key to have consistent results.
The LogHandler output is also different on older Python versions.
Also, don't stop running python tests after the first error.
2020-04-07 14:03:58 -06:00
Todd C. Miller
fa5025a569
Use regex to match __init__.py instead of hacking it in verify_log_lines()
2020-04-07 14:03:58 -06:00
Todd C. Miller
a77ef93f8a
Use regular expressions when matching expected and actual text.
2020-04-07 14:03:58 -06:00
Todd C. Miller
8a2c0d784f
Sort the list of possible plugins before printing it.
...
This gives more reproducible error messages for the tests.
2020-04-07 14:03:58 -06:00
Todd C. Miller
02a117f336
Avoid using typing annotations so tests run with Python 3.4.
2020-04-07 14:03:58 -06:00
Todd C. Miller
a23048bbb2
Avoid using sprintf(), vsprintf(), strcat(), and strncat().
...
It is less error-prone to use functions with a return value that
indicates when truncation ocurred.
2020-03-11 19:46:07 -06:00
Todd C. Miller
ec78f06890
Don't hard-code path to logging/__init__.py or line numbers.
...
Allows python plugin tests to success on versions other than 3.7.
2020-03-11 17:18:10 -06:00
Robert Manner
6c9515496d
plugins/python/regress: add a test and example of using the python logger
2020-02-28 05:46:54 -07:00
Robert Manner
34b4bb72d6
plugins/python: autodetect ClassName field
...
If "ClassName" is not specified, load the one and only sudo.Plugin from
the module (if so), otherwise display which plugins are available from
which the system admin can choose.
2020-02-28 05:46:54 -07:00
Robert Manner
9cc46f115d
plugins/python/regress: update tests for show_version changes
...
- plugin->show_version is not marked NULL any more.
- if verbose, it also displays which python class was loaded from which file
2020-02-26 13:15:52 -07:00
Robert Manner
27de7dd24d
plugins/python: only deinit interpreters when sudo unlinks the plugin
...
This only happens when sudo unloads the last python plugin.
The reason doing so is because there are some python modules which
does not support importing them again after destroying the interpreter
which has imported them previously.
Another solution would be to just leak the interpreters (let the kernel
free up), but then there might be some python resources like open files
would not get cleaned up correctly if the plugin is badly written.
Tests are meant to test the scenario sudo does, so I have modified them
to generally do not unlink but only a few times (~per plugin type) so it
does not use 48 interpreters (one gets started on every plugin->open) and
it is visible at least which type of plugin fails deinit if there is an
error.
2020-02-19 11:48:16 -07:00
Robert Manner
8395a20a20
plugins/python/regress/testhelpers.c: replace fromisoformat
...
fromisoformat is only supported from python >=3.7
2020-02-14 09:25:37 -07:00
Robert Manner
43e256e34f
plugins/python/regress: add tests for approval plugin
2020-02-12 11:16:00 -07:00
Robert Manner
33e7fdcae0
plugins/python/regress: strengthen errstr verification
...
Tests did not catch the issue where errstr was not set correctly, but
its pointer contained the expected data, because the memory allocator
reused the same space for storing the string.
Now it is either verified to be NULL, or reset to NULL.
2020-02-12 11:16:00 -07:00
Robert Manner
9fa6500d6a
plugins/python/regress: simplify plugin option creation
2020-02-12 11:16:00 -07:00
Robert Manner
d1f94c857c
plugins/python/regress: still some memleak fix
2020-02-12 11:16:00 -07:00
Robert Manner
1a1cb54975
plugins/python/regress/check_python_examples: add audit_plugin tests
2020-02-10 05:24:16 -07:00
Robert Manner
bbbcb39334
plugins/python/example_*.py: document returning error string
2020-02-10 05:24:16 -07:00
Robert Manner
9c4f076f85
plugins/python/regress: add test for callback error msg return
2020-02-10 05:24:16 -07:00
Robert Manner
45d2638571
plugins/python/example*.py: pep8 fixes (mainly line too long)
2020-02-10 05:24:16 -07:00
Robert Manner
0f3631cc08
plugins/python/regress: load/unload module for each testcase
...
so they can start from clean state. (My problem was optional argument
tests has destroyed the callbacks.)
2020-02-10 05:24:16 -07:00