diff --git a/plugins/python/python_plugin_approval.c b/plugins/python/python_plugin_approval.c index 55f197fb5..7451f03bc 100644 --- a/plugins/python/python_plugin_approval.c +++ b/plugins/python/python_plugin_approval.c @@ -38,12 +38,6 @@ struct ApprovalPluginContext // 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 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 python_plugin_approval_open(struct ApprovalPluginContext *approval_ctx, @@ -93,9 +87,6 @@ python_plugin_approval_open(struct ApprovalPluginContext *approval_ctx, debug_return_int(rc); } - // skip plugin callbacks which are not mandatory - MARK_CALLBACK_OPTIONAL(show_version); - debug_return_int(rc); } diff --git a/plugins/python/python_plugin_common.c b/plugins/python/python_plugin_common.c index 1225d5fb9..ee573a803 100644 --- a/plugins/python/python_plugin_common.c +++ b/plugins/python/python_plugin_common.c @@ -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_return_int(python_plugin_api_rc_call(plugin_ctx, python_callback_name, - Py_BuildValue("(i)", is_verbose))); + int rc = SUDO_RC_OK; + 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