Commit Graph

13 Commits

Author SHA1 Message Date
Robert Manner
c039a99c10 plugins/python/sudo_module: add sudo.LogHandler
so python log system can be used with sudo logsystem.
Loggers use it by default (the handler is set on the root logger).
If that is not the intent, it can be overridden explicitly.
2020-02-28 05:46:54 -07:00
Todd C. Miller
de9a143a3e Use C99 __func__ instead of gcc-specific __PRETTY_FUNCTION__ 2020-02-27 14:10:53 -07:00
Robert Manner
06b1f58e9f plugins/python/sudo_python_module.c: remove unused declaration
We do not use structsequence any more.
2020-02-19 11:48:16 -07:00
Robert Manner
b2ae79c2be plugins/python: add missing annotations to help cpychecker 2020-02-14 09:25:37 -07:00
Robert Manner
23af39b005 plugins/python: add python approval plugin wrapper 2020-02-12 11:16:00 -07:00
Robert Manner
b165242035 plugins/python/sudo_module: let a reject also supply error message
Same as sudo.PluginError exception, have a sudo.PluginReject exception
as well. Added common base exception as well.
2020-02-12 11:16:00 -07:00
Robert Manner
cbf60cff5d plugins/python: add python audit plugin wrapper 2020-02-10 05:24:16 -07:00
Robert Manner
3dd5f37af7 plugins/python: add support for callback errstr arguments
Plugins can raise a sudo.PluginError exception to add context message
for the failure.

The callback's errstr gets filled up with the specified message.
But, as sudo expects a string constant (will not free the string),
we store it in the plugin context at least until next callback
invocation.
2020-02-10 05:24:16 -07:00
Robert Manner
99f99e8a56 plugins/python/sudo_python_module.c: fix options_as_dict if no equal sign
The intented behaviour was that those get skipped, but the PyList_GetItem
sets the interpreter into error state, so python has raised exception.
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
f268e851d7 plugins/sudo_python_module: Fix double free in sudo.options_as_dict function
PyArg_ParseTuple sets the py_config_tuple pointer, but it does not
increment the reference count, so by decrementing, we end up freeing
the argument passed in.
2020-01-28 07:20:44 -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
9b49d44e84 plugins/python: add a sudo python module 2019-12-14 12:55:42 -07:00