Commit Graph

27 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
9c4f076f85 plugins/python/regress: add test for callback error msg return 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
Robert Manner
a3a7630ff4 plugins/python: memleak fixes in test
The main problem was that string array objects were constructed
differently:
- if constructed by the test, then the elements were constant
- if constructed by the plugin, then the elements were allocated

Modified it so that now each array contains allocated strings so
they can be handled similarly. For freeing, I have used the
str_array_free function from the plugin, so I have linked its object
into the test runner.

Happy path is now free of "definitely lost" memleaks, so the test
can be used for valgrind.
2020-02-10 05:24:16 -07:00
Todd C. Miller
a88a05c1eb Adapt python plugin to new plugin API changes 2020-01-30 13:25:38 -07:00
Todd C. Miller
4e87e1a97b Fix typo in a test: python_policy->close not python_io->close 2020-01-28 13:00:33 -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
8cacaabe9b plugins/python/regress: add missing license texts 2020-01-20 06:30:20 -07:00
Robert Manner
b66ecf6e13 plugins/python: various portability improvements 2020-01-20 06:30:20 -07:00
Robert Manner
40f2189586 plugins/python/regress: load the python plugin dynamically
instead of linking with it.
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