diff --git a/plugins/python/regress/check_python_examples.c b/plugins/python/regress/check_python_examples.c index 484cfcb4e..de5a41390 100644 --- a/plugins/python/regress/check_python_examples.c +++ b/plugins/python/regress/check_python_examples.c @@ -175,7 +175,8 @@ check_example_io_plugin_version_display(int is_verbose) if (is_verbose) { // Note: the exact python version is environment dependant VERIFY_STR_CONTAINS(data.stdout_str, "Python interpreter version:"); - VERIFY_STR_CONTAINS(data.stdout_str, "Python io plugin API version"); + *strstr(data.stdout_str, "Python interpreter version:") = '\0'; + VERIFY_STDOUT(expected_path("check_example_io_plugin_version_display_full.stdout")); } else { VERIFY_STDOUT(expected_path("check_example_io_plugin_version_display.stdout")); } @@ -687,7 +688,8 @@ check_example_policy_plugin_version_display(int is_verbose) if (is_verbose) { // Note: the exact python version is environment dependant VERIFY_STR_CONTAINS(data.stdout_str, "Python interpreter version:"); - VERIFY_STR_CONTAINS(data.stdout_str, "Python policy plugin API version"); + *strstr(data.stdout_str, "Python interpreter version:") = '\0'; + VERIFY_STDOUT(expected_path("check_example_policy_plugin_version_display_full.stdout")); } else { VERIFY_STDOUT(expected_path("check_example_policy_plugin_version_display.stdout")); } @@ -928,7 +930,10 @@ check_policy_plugin_callbacks_are_optional(void) VERIFY_PTR(python_policy->invalidate, NULL); VERIFY_PTR_NE(python_policy->check_policy, NULL); // (not optional) VERIFY_PTR(python_policy->init_session, NULL); - VERIFY_PTR(python_policy->show_version, NULL); + + // show_version always displays the plugin, but it is optional in the python layer + VERIFY_PTR_NE(python_policy->show_version, NULL); + VERIFY_INT(python_policy->show_version(1), SUDO_RC_OK); python_policy->close(0, 0); return true; @@ -1014,9 +1019,12 @@ check_io_plugin_callbacks_are_optional(void) VERIFY_PTR(python_io->log_stderr, NULL); VERIFY_PTR(python_io->log_ttyin, NULL); VERIFY_PTR(python_io->log_ttyout, NULL); - VERIFY_PTR(python_io->show_version, NULL); VERIFY_PTR(python_io->change_winsize, NULL); + // show_version always displays the plugin, but it is optional in the python layer + VERIFY_PTR_NE(python_io->show_version, NULL); + VERIFY_INT(python_io->show_version(1), SUDO_RC_OK); + python_io->close(0, 0); return true; } @@ -1261,7 +1269,10 @@ check_audit_plugin_callbacks_are_optional(void) VERIFY_PTR(python_audit->accept, NULL); VERIFY_PTR(python_audit->reject, NULL); VERIFY_PTR(python_audit->error, NULL); - VERIFY_PTR(python_audit->show_version, NULL); + + // show_version always displays the plugin, but it is optional in the python layer + VERIFY_PTR_NE(python_audit->show_version, NULL); + VERIFY_INT(python_audit->show_version(1), SUDO_RC_OK); python_audit->close(SUDO_PLUGIN_NO_STATUS, 0); return true; diff --git a/plugins/python/regress/testdata/check_example_audit_plugin_version_display.stdout b/plugins/python/regress/testdata/check_example_audit_plugin_version_display.stdout index 3f7015ba1..1586f462d 100644 --- a/plugins/python/regress/testdata/check_example_audit_plugin_version_display.stdout +++ b/plugins/python/regress/testdata/check_example_audit_plugin_version_display.stdout @@ -1,6 +1,6 @@ (AUDIT) -- Started by user root (0) -- Python Example Audit Plugin -Python audit plugin API version 1.0 +Python audit plugin (API 1.0): SudoAuditPlugin (loaded from 'SRC_DIR/example_audit_plugin.py') Python Example Audit Plugin (version=1.0) (AUDIT) Sudo has run into an error: 222 (AUDIT) -- Finished -- diff --git a/plugins/python/regress/testdata/check_example_debugging_py_calls@info.log b/plugins/python/regress/testdata/check_example_debugging_py_calls@info.log index e235d9853..a67f146ff 100644 --- a/plugins/python/regress/testdata/check_example_debugging_py_calls@info.log +++ b/plugins/python/regress/testdata/check_example_debugging_py_calls@info.log @@ -1,6 +1,5 @@ DebugDemoPlugin.__init__ was called with arguments: () {'version': '1.0', 'settings': ('debug_flags=/tmp/sudo_check_python_exampleXXXXXX/debug.log py_calls@info', 'plugin_path=python_plugin.so'), 'user_env': (), 'user_info': (), 'plugin_options': ('ModulePath=SRC_DIR/example_debugging.py', 'ClassName=DebugDemoPlugin')} DebugDemoPlugin.__init__ returned result: -DebugDemoPlugin function 'show_version' is not implemented DebugDemoPlugin function 'log_ttyin' is not implemented DebugDemoPlugin function 'log_ttyout' is not implemented DebugDemoPlugin function 'log_stdin' is not implemented diff --git a/plugins/python/regress/testdata/check_example_io_plugin_version_display_full.stdout b/plugins/python/regress/testdata/check_example_io_plugin_version_display_full.stdout new file mode 100644 index 000000000..cfb3921c8 --- /dev/null +++ b/plugins/python/regress/testdata/check_example_io_plugin_version_display_full.stdout @@ -0,0 +1,3 @@ +Example sudo python plugin will log to /tmp/sudo_check_python_exampleXXXXXX/sudo.log +Python io plugin (API 1.0): SudoIOPlugin (loaded from 'SRC_DIR/example_io_plugin.py') +Python Example IO Plugin version: 1.0 diff --git a/plugins/python/regress/testdata/check_example_policy_plugin_version_display_full.stdout b/plugins/python/regress/testdata/check_example_policy_plugin_version_display_full.stdout new file mode 100644 index 000000000..a23cf1269 --- /dev/null +++ b/plugins/python/regress/testdata/check_example_policy_plugin_version_display_full.stdout @@ -0,0 +1,2 @@ +Python policy plugin (API 1.0): SudoPolicyPlugin (loaded from 'SRC_DIR/example_policy_plugin.py') +Python Example Policy Plugin version: 1.0 diff --git a/plugins/python/regress/testdata/check_multiple_approval_plugin_and_arguments.stdout b/plugins/python/regress/testdata/check_multiple_approval_plugin_and_arguments.stdout index 4eca0f47a..1ba0dcafe 100644 --- a/plugins/python/regress/testdata/check_multiple_approval_plugin_and_arguments.stdout +++ b/plugins/python/regress/testdata/check_multiple_approval_plugin_and_arguments.stdout @@ -59,7 +59,7 @@ "_id": "(APPROVAL 2)" } (APPROVAL 1) Show version was called with arguments: (0,) -Python approval plugin API version 1.0 +Python approval plugin (API 1.0): ApprovalTestPlugin (loaded from 'SRC_DIR/regress/plugin_approval_test.py') (APPROVAL 2) Show version was called with arguments: (1,) (APPROVAL 1) Check was called with arguments: (('CMDINFO1=value1', 'CMDINFO2=VALUE2'), ('whoami', '--help'), ('USER_ENV1=VALUE1', 'USER_ENV2=value2')) (APPROVAL 2) Check was called with arguments: (('CMDINFO1=value1', 'CMDINFO2=VALUE2'), ('whoami', '--help'), ('USER_ENV1=VALUE1', 'USER_ENV2=value2'))