| 1 | /* Copyright (c) 2015, 2026, Oracle and/or its affiliates. |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License, version 2.0, |
| 5 | as published by the Free Software Foundation. |
| 6 | |
| 7 | This program is designed to work with certain software (including |
| 8 | but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | as designated in a particular file or component or in included license |
| 10 | documentation. The authors of MySQL hereby grant you an additional |
| 11 | permission to link the program and your derivative works with the |
| 12 | separately licensed software that they have either included with |
| 13 | the program or referenced in the documentation. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License, version 2.0, for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program; if not, write to the Free Software |
| 22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 23 | |
| 24 | #include <assert.h> |
| 25 | #include <sys/types.h> |
| 26 | |
| 27 | #include <atomic> |
| 28 | #include <cstdint> |
| 29 | #include <memory> |
| 30 | |
| 31 | #include "my_config.h" // NOLINT(build/include_subdir) |
| 32 | // NOLINT(build/include_subdir) |
| 33 | #include "mysql/service_plugin_registry.h" |
| 34 | #include "violite.h" // NOLINT(build/include_subdir) |
| 35 | |
| 36 | #include "plugin/x/src/xpl_performance_schema.h" |
| 37 | #include "sql/replication.h" |
| 38 | #include "unittest/gunit/xplugin/xpl/mock/component_services.h" |
| 39 | |
| 40 | #ifdef HAVE_ARPA_INET_H |
| 41 | #include <arpa/inet.h> |
| 42 | #endif |
| 43 | #ifdef HAVE_SYS_UN_H |
| 44 | #include <sys/un.h> |
| 45 | #endif |
| 46 | #if !defined(_WIN32) |
| 47 | #include <sys/utsname.h> |
| 48 | #endif |
| 49 | |
| 50 | const char *my_localhost; |
| 51 | std::atomic<int32> connection_events_loop_aborted_flag; |
| 52 | bool opt_initialize = false; |
| 53 | |
| 54 | int ip_to_hostname(struct sockaddr_storage *, const char *, char **, |
| 55 | uint32_t *) { |
| 56 | assert(0); |
| 57 | return 1; |
| 58 | } |
| 59 | |
| 60 | int register_server_state_observer(Server_state_observer *, void *) { |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | int unregister_server_state_observer(Server_state_observer *, void *) { |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | void ssl_wrapper_version(Vio *, char *, const size_t) {} |
| 69 | |
| 70 | void ssl_wrapper_cipher(Vio *, char *, const size_t) {} |
| 71 | |
| 72 | // NOLINTNEXTLINE(runtime/int) |
| 73 | long ssl_wrapper_cipher_list(Vio *, const char **, const long) { return 0; } |
| 74 | |
| 75 | // NOLINTNEXTLINE(runtime/int) |
| 76 | long ssl_wrapper_verify_depth(Vio *) { return 0; } |
| 77 | |
| 78 | // NOLINTNEXTLINE(runtime/int) |
| 79 | long ssl_wrapper_verify_mode(Vio *) { return 0; } |
| 80 | |
| 81 | void ssl_wrapper_get_peer_certificate_issuer(Vio *, char *, const size_t) {} |
| 82 | |
| 83 | void ssl_wrapper_get_peer_certificate_subject(Vio *, char *, const size_t) {} |
| 84 | |
| 85 | // NOLINTNEXTLINE(runtime/int) |
| 86 | long ssl_wrapper_get_verify_result_and_cert(Vio *) { return 0; } |
| 87 | |
| 88 | // NOLINTNEXTLINE(runtime/int) |
| 89 | long ssl_wrapper_ctx_verify_depth(struct st_VioSSLFd *) { return 0; } |
| 90 | |
| 91 | // NOLINTNEXTLINE(runtime/int) |
| 92 | long ssl_wrapper_ctx_verify_mode(struct st_VioSSLFd *) { return 0; } |
| 93 | |
| 94 | void ssl_wrapper_ctx_server_not_after(struct st_VioSSLFd *, char *, |
| 95 | const size_t) {} |
| 96 | |
| 97 | void ssl_wrapper_ctx_server_not_before(struct st_VioSSLFd *, char *, |
| 98 | const size_t) {} |
| 99 | |
| 100 | void ssl_wrapper_thread_cleanup() {} |
| 101 | |
| 102 | // NOLINTNEXTLINE(runtime/int) |
| 103 | long ssl_wrapper_sess_accept(struct st_VioSSLFd *) { return 0; } |
| 104 | |
| 105 | // NOLINTNEXTLINE(runtime/int) |
| 106 | long ssl_wrapper_sess_accept_good(struct st_VioSSLFd *) { return 0; } |
| 107 | |
| 108 | SERVICE_TYPE(registry) * mysql_plugin_registry_acquire() { |
| 109 | using xpl::test::mock::Mysql_plugin_registry; |
| 110 | |
| 111 | if (Mysql_plugin_registry::m_mysql_plugin_registry) |
| 112 | return Mysql_plugin_registry::m_mysql_plugin_registry |
| 113 | ->mysql_plugin_registry_acquire(); |
| 114 | return nullptr; |
| 115 | } |
| 116 | |
| 117 | int mysql_plugin_registry_release(SERVICE_TYPE(registry) * reg) { |
| 118 | using xpl::test::mock::Mysql_plugin_registry; |
| 119 | |
| 120 | if (Mysql_plugin_registry::m_mysql_plugin_registry) |
| 121 | return Mysql_plugin_registry::m_mysql_plugin_registry |
| 122 | ->mysql_plugin_registry_release(reg); |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | thread_local THD *current_thd = nullptr; |
| 128 | |
| 129 | THD *thd_get_current_thd() { return current_thd; } |
| 130 | |
| 131 | bool check_address_is_wildcard(const char *, size_t) { return false; } |
| 132 | |
| 133 | void conditional_sync_point(std::string) {} |
| 134 | |
| 135 | uint opt_debug_sync_timeout; |
| 136 | void debug_sync(THD *, char const *, size_t) {} |
| 137 | |
| 138 | #ifdef HAVE_SETNS |
| 139 | bool set_network_namespace(const std::string &) { return false; } |
| 140 | |
| 141 | bool restore_original_network_namespace() { return false; } |
| 142 | |
| 143 | void release_network_namespace_resources() {} |
| 144 | #endif |