Commit Graph

30 Commits

Author SHA1 Message Date
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
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
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
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
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
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
43e256e34f plugins/python/regress: add tests for approval plugin 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
45d2638571 plugins/python/example*.py: pep8 fixes (mainly line too long) 2020-02-10 05:24:16 -07:00
Robert Manner
21c02e1732 plugins/python/sudo_python_module.c: use IntEnums instead of constants
It is a bit more code, but it is more "pythonic" and easier to debug
as the enum values also know their names.

It is also an API break, eg. sudo.RC_OK becomes sudo.RC.OK as sudo.RC will
be the "type" of the enum, but I guess that is acceptable before the
initial release.
2020-02-10 05:24:16 -07:00
Robert Manner
4110800c14 plugins/python/example_io_plugin: close the file at destroy
to avoid warning of debug python build.
2020-02-10 05:24:16 -07:00
Robert Manner
99f8394182 plugins/python/regress: add a failing textcase about python plugins affect each other
Since python plugins are run inside the same interpreter, they affect
each other's state, which would be better to avoid.
2020-01-24 12:25:15 -07:00
Robert Manner
d67c64bb37 plugins/python/pyhelpers: have a default sudo_printf function
Adapted the default sudo_printf from sudoers plugin to be able to print
errors before plugin open() gets called. (This is used by the multiple io
plugin loading to display error for too much plugin load.)

Since this makes us always have a sudo_log, I have removed the logic about
whether it is available or not.
2020-01-23 12:46:14 -07:00
Robert Manner
2eeda38f95 plugins/python/regress: add a testcase for multiple io plugin loading
to verify 2 python plugins can work next to each other.
2020-01-23 12:46:14 -07:00
Robert Manner
f3b7f3c0d4 plugins/python/example_{io,conversation}: avoid printing signal number
They are platform dependant, so their test would fail on some platforms.
While we could create separate plugin for the tests, I like the idea that
the examples are ensured to be working.

I believe this is a good compromise for being able to auto update the
test cases.
2020-01-20 06:30:20 -07:00
Robert Manner
383ca80333 plugins/python/regress/testdata: generated data for the pyplugin tests 2020-01-20 06:30:20 -07:00
Robert Manner
5da7bd562c plugins/python/regress: adds tests for python plugin feature and examples 2020-01-20 06:30:20 -07:00