plugins/python/approval: fix show_version crash when it is not implemented
For approval plugins show_version is not optional.
This commit is contained in:

committed by
Todd C. Miller

parent
e588879cf5
commit
38fc37b214
@@ -38,12 +38,6 @@ struct ApprovalPluginContext
|
|||||||
// This also verifies compile time that the name matches the sudo plugin API.
|
// This also verifies compile time that the name matches the sudo plugin API.
|
||||||
#define CALLBACK_PYNAME(func_name) ((void)CALLBACK_PLUGINFUNC(func_name), #func_name)
|
#define CALLBACK_PYNAME(func_name) ((void)CALLBACK_PLUGINFUNC(func_name), #func_name)
|
||||||
|
|
||||||
#define MARK_CALLBACK_OPTIONAL(function_name) \
|
|
||||||
do { \
|
|
||||||
python_plugin_mark_callback_optional(plugin_ctx, CALLBACK_PYNAME(function_name), \
|
|
||||||
(void **)&CALLBACK_PLUGINFUNC(function_name)); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
python_plugin_approval_open(struct ApprovalPluginContext *approval_ctx,
|
python_plugin_approval_open(struct ApprovalPluginContext *approval_ctx,
|
||||||
@@ -93,9 +87,6 @@ python_plugin_approval_open(struct ApprovalPluginContext *approval_ctx,
|
|||||||
debug_return_int(rc);
|
debug_return_int(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip plugin callbacks which are not mandatory
|
|
||||||
MARK_CALLBACK_OPTIONAL(show_version);
|
|
||||||
|
|
||||||
debug_return_int(rc);
|
debug_return_int(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -531,8 +531,13 @@ python_plugin_show_version(struct PluginContext *plugin_ctx, const char *python_
|
|||||||
{
|
{
|
||||||
debug_decl(python_plugin_show_version, PYTHON_DEBUG_CALLBACKS);
|
debug_decl(python_plugin_show_version, PYTHON_DEBUG_CALLBACKS);
|
||||||
|
|
||||||
debug_return_int(python_plugin_api_rc_call(plugin_ctx, python_callback_name,
|
int rc = SUDO_RC_OK;
|
||||||
Py_BuildValue("(i)", is_verbose)));
|
if (PyObject_HasAttrString(plugin_ctx->py_instance, python_callback_name)) {
|
||||||
|
rc = python_plugin_api_rc_call(plugin_ctx, python_callback_name,
|
||||||
|
Py_BuildValue("(i)", is_verbose));
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_return_int(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user