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:

committed by
Todd C. Miller

parent
87d76f4bbc
commit
2ee1dd3ec3
@@ -107,7 +107,7 @@ class SudoIOPlugin(sudo.Plugin):
|
||||
self._log("SUSPEND", signal_description)
|
||||
|
||||
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:
|
||||
sudo.log_info("Python interpreter version:", sys.version)
|
||||
|
||||
|
@@ -122,7 +122,7 @@ class SudoPolicyPlugin(sudo.Plugin):
|
||||
pass # we have no cache
|
||||
|
||||
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:
|
||||
sudo.log_info("Python interpreter version:", sys.version)
|
||||
|
||||
|
@@ -401,7 +401,6 @@ python_plugin_show_version(struct PluginContext *plugin_ctx, const char *python_
|
||||
{
|
||||
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,
|
||||
Py_BuildValue("(i)", is_verbose)));
|
||||
}
|
||||
|
@@ -129,6 +129,13 @@ int
|
||||
python_plugin_io_show_version(int verbose)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
@@ -187,6 +187,12 @@ python_plugin_policy_version(int verbose)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user