plugins/python: fix confusing version display

IO/Group/Policy Python API version is displayed instead of sudo version,
because that is not very meaningful in this context.

They are only displayed in verbose mode.

Example plugins express it more concrete that they are displaying their
version, not the API version.
This commit is contained in:
Robert Manner
2020-01-09 11:38:08 +01:00
committed by Todd C. Miller
parent 87d76f4bbc
commit 2ee1dd3ec3
5 changed files with 15 additions and 3 deletions

View File

@@ -107,7 +107,7 @@ class SudoIOPlugin(sudo.Plugin):
self._log("SUSPEND", signal_description) self._log("SUSPEND", signal_description)
def show_version(self, is_verbose: int) -> int: def show_version(self, is_verbose: int) -> int:
sudo.log_info("Python IO Plugin version: {}".format(VERSION)) sudo.log_info("Python Example IO Plugin version: {}".format(VERSION))
if is_verbose: if is_verbose:
sudo.log_info("Python interpreter version:", sys.version) sudo.log_info("Python interpreter version:", sys.version)

View File

@@ -122,7 +122,7 @@ class SudoPolicyPlugin(sudo.Plugin):
pass # we have no cache pass # we have no cache
def show_version(self, is_verbose: int): def show_version(self, is_verbose: int):
sudo.log_info("Python Policy Plugin version: {}".format(VERSION)) sudo.log_info("Python Example Policy Plugin version: {}".format(VERSION))
if is_verbose: if is_verbose:
sudo.log_info("Python interpreter version:", sys.version) sudo.log_info("Python interpreter version:", sys.version)

View File

@@ -401,7 +401,6 @@ 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);
py_sudo_log(SUDO_CONV_INFO_MSG, "Python language plugin version %s\n", PACKAGE_VERSION);
debug_return_int(python_plugin_api_rc_call(plugin_ctx, python_callback_name, debug_return_int(python_plugin_api_rc_call(plugin_ctx, python_callback_name,
Py_BuildValue("(i)", is_verbose))); Py_BuildValue("(i)", is_verbose)));
} }

View File

@@ -129,6 +129,13 @@ int
python_plugin_io_show_version(int verbose) python_plugin_io_show_version(int verbose)
{ {
debug_decl(python_plugin_io_show_version, PYTHON_DEBUG_CALLBACKS); debug_decl(python_plugin_io_show_version, PYTHON_DEBUG_CALLBACKS);
if (verbose) {
py_sudo_log(SUDO_CONV_INFO_MSG, "Python io plugin API version %d.%d\n", "%d.%d",
SUDO_API_VERSION_GET_MAJOR(PY_IO_PLUGIN_VERSION),
SUDO_API_VERSION_GET_MINOR(PY_IO_PLUGIN_VERSION));
}
debug_return_int(python_plugin_show_version(&plugin_ctx, CALLBACK_PYNAME(show_version), verbose)); debug_return_int(python_plugin_show_version(&plugin_ctx, CALLBACK_PYNAME(show_version), verbose));
} }

View File

@@ -187,6 +187,12 @@ python_plugin_policy_version(int verbose)
{ {
debug_decl(python_plugin_policy_version, PYTHON_DEBUG_CALLBACKS); debug_decl(python_plugin_policy_version, PYTHON_DEBUG_CALLBACKS);
if (verbose) {
py_sudo_log(SUDO_CONV_INFO_MSG, "Python policy plugin API version %d.%d\n", "%d.%d",
SUDO_API_VERSION_GET_MAJOR(PY_POLICY_PLUGIN_VERSION),
SUDO_API_VERSION_GET_MINOR(PY_POLICY_PLUGIN_VERSION));
}
debug_return_int(python_plugin_show_version(&plugin_ctx, CALLBACK_PYNAME(show_version), verbose)); debug_return_int(python_plugin_show_version(&plugin_ctx, CALLBACK_PYNAME(show_version), verbose));
} }