A helper for the verify plugin command functions. * * @param[in] args The arguments passed to the -C command option. This includes * verify_global_plugin. * * @param[in] symbols The expected symbols to verify exist in the plugin file. * * @return a CMD status code. See the CMD_ defines above in this file. */
| 1084 | * @return a CMD status code. See the CMD_ defines above in this file. |
| 1085 | */ |
| 1086 | int |
| 1087 | verify_plugin_helper(char *args, plugin_type_t plugin_type) |
| 1088 | { |
| 1089 | const auto *plugin_filename = skip(args); |
| 1090 | if (!plugin_filename) { |
| 1091 | fprintf(stderr, "ERROR: verifying a plugin requires a plugin SO file path argument\n"); |
| 1092 | return CMD_FAILED; |
| 1093 | } |
| 1094 | |
| 1095 | fs::path plugin_path(plugin_filename); |
| 1096 | fprintf(stderr, "NOTE: verifying plugin '%s'...\n", plugin_filename); |
| 1097 | |
| 1098 | if (!fs::exists(plugin_path)) { |
| 1099 | fprintf(stderr, "ERROR: verifying plugin '%s' Fail: No such file or directory\n", plugin_filename); |
| 1100 | return CMD_FAILED; |
| 1101 | } |
| 1102 | |
| 1103 | auto ret = CMD_OK; |
| 1104 | std::string error; |
| 1105 | if (try_loading_plugin(plugin_type, plugin_path, error)) { |
| 1106 | fprintf(stderr, "NOTE: verifying plugin '%s' Success\n", plugin_filename); |
| 1107 | } else { |
| 1108 | fprintf(stderr, "ERROR: verifying plugin '%s' Fail: %s\n", plugin_filename, error.c_str()); |
| 1109 | ret = CMD_FAILED; |
| 1110 | } |
| 1111 | return ret; |
| 1112 | } |
| 1113 | |
| 1114 | /** Verify whether a given SO file looks like a valid global plugin. |
| 1115 | * |
no test coverage detected