plugins/python/python_plugin_policy: fix validate() call
When calling validate() python function, TypeError exception was thrown ("argument list must be a tuple"), because the call does not have arguments, and python does not accept empty tuple for execution. NULL must be used instead, which was handled as argument construction failure previously.
This commit is contained in:

committed by
Todd C. Miller

parent
35c85596d7
commit
185471f263
@@ -342,7 +342,9 @@ python_plugin_api_call(struct PluginContext *plugin_ctx, const char *func_name,
|
||||
{
|
||||
debug_decl(python_plugin_api_call, PYTHON_DEBUG_PY_CALLS);
|
||||
|
||||
if (py_args == NULL) {
|
||||
// Note: call fails if py_args is an empty tuple. Passing no arguments works passing NULL
|
||||
// instead. So having such must be handled as valid. (See policy_plugin.validate())
|
||||
if (py_args == NULL && PyErr_Occurred()) {
|
||||
py_sudo_log(SUDO_CONV_ERROR_MSG, "Failed to build arguments for python plugin API call '%s'\n", func_name);
|
||||
py_log_last_error(NULL);
|
||||
debug_return_ptr(NULL);
|
||||
|
@@ -200,8 +200,7 @@ int
|
||||
python_plugin_policy_validate(void)
|
||||
{
|
||||
debug_decl(python_plugin_policy_validate, PYTHON_DEBUG_CALLBACKS);
|
||||
debug_return_int(python_plugin_api_rc_call(&plugin_ctx, CALLBACK_PYNAME(validate),
|
||||
Py_BuildValue("")));
|
||||
debug_return_int(python_plugin_api_rc_call(&plugin_ctx, CALLBACK_PYNAME(validate), NULL));
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user