MySQL 8.4.3
Source Code Documentation
migrate_keyring.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2024, 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#ifndef MIGRATE_KEYRING_H_INCLUDED
25#define MIGRATE_KEYRING_H_INCLUDED
26
27#include <string>
28#include "mysql.h"
30#include "sql_common.h" // NET_SERVER
31
36
37class THD;
38
39#define MAX_KEY_LEN 16384
40
42
43class Key_info {
44 public:
45 Key_info() = default;
46 Key_info(char *key_id, char *user_id) {
47 m_key_id = key_id;
48 m_user_id = user_id;
49 }
50 Key_info(const Key_info &ki) {
51 this->m_key_id = ki.m_key_id;
52 this->m_user_id = ki.m_user_id;
53 }
54
55 public:
56 std::string m_key_id;
57 std::string m_user_id;
58};
59
60using const_keyring_writer_t = SERVICE_TYPE(keyring_writer);
61using const_keyring_load_t = SERVICE_TYPE(keyring_load);
63 SERVICE_TYPE(keyring_reader_with_status);
65 SERVICE_TYPE(keyring_keys_metadata_iterator);
66
68 protected:
70 Keyring_component(const std::string component_path,
71 const std::string implementation_name);
73
74 public:
76 bool ok() { return ok_; }
77
78 protected:
79 const std::string component_path_;
83 bool ok_;
84};
85
87 public:
88 Source_keyring_component(const std::string component_path,
89 const std::string implementation_name);
91
94 }
97 }
98
99 private:
103};
104
106 public:
107 Destination_keyring_component(const std::string component_path,
108 const std::string implementation_name);
110
112
113 private:
115};
116
118 public:
119 /**
120 Standard constructor.
121 */
123 /**
124 Initialize all needed parameters to proceed with migration process.
125 */
126 bool init(int argc, char **argv, char *source_plugin,
127 char *destination_plugin, char *user, char *host, char *password,
128 char *socket, ulong port, bool migrate_to_component,
129 bool migrate_from_component);
130 /**
131 Migrate keys from source keyring to destination keyring.
132 */
133 bool execute();
134 /**
135 Standard destructor
136 */
138
139 private:
140 /**
141 Load source or destination plugin.
142 */
143 bool load_plugin(enum_plugin_type plugin_type);
144 /**
145 Load component
146 */
147 bool load_component();
148 /**
149 Fetch keys from source plugin and store in destination plugin.
150 */
152 /**
153 Disable @@keyring_operations variable.
154 */
156 /**
157 Enable @@keyring_operations variable.
158 */
160
161 private:
163 char **m_argv;
168 std::string m_internal_option[2];
171 std::vector<Key_info> m_source_keys;
178};
179
180#endif /* MIGRATE_KEYRING_H_INCLUDED */
Definition: migrate_keyring.h:105
const_keyring_writer_t * writer()
Definition: migrate_keyring.h:111
Destination_keyring_component(const std::string component_path, const std::string implementation_name)
Definition: migrate_keyring.cc:149
~Destination_keyring_component()
Definition: migrate_keyring.cc:183
const_keyring_writer_t * keyring_writer_service_
Definition: migrate_keyring.h:114
Definition: migrate_keyring.h:43
std::string m_key_id
Definition: migrate_keyring.h:56
Key_info(char *key_id, char *user_id)
Definition: migrate_keyring.h:46
Key_info(const Key_info &ki)
Definition: migrate_keyring.h:50
std::string m_user_id
Definition: migrate_keyring.h:57
Key_info()=default
Definition: migrate_keyring.h:67
bool component_loaded_
Definition: migrate_keyring.h:82
const_keyring_load_t * keyring_load_service_
Definition: migrate_keyring.h:81
~Keyring_component()
Definition: migrate_keyring.cc:70
bool ok()
Definition: migrate_keyring.h:76
const std::string component_path_
Definition: migrate_keyring.h:79
const_keyring_load_t * initializer()
Definition: migrate_keyring.h:75
my_h_service h_keyring_load_service
Definition: migrate_keyring.h:80
Keyring_component()
Definition: migrate_keyring.h:69
bool ok_
Definition: migrate_keyring.h:83
Definition: migrate_keyring.h:117
st_mysql_keyring * m_source_plugin_handle
Definition: migrate_keyring.h:169
std::string m_source_plugin_option
Definition: migrate_keyring.h:164
Destination_keyring_component * m_destination_component
Definition: migrate_keyring.h:177
int m_argc
Definition: migrate_keyring.h:162
NET_SERVER server_extn
Definition: migrate_keyring.h:173
st_mysql_keyring * m_destination_plugin_handle
Definition: migrate_keyring.h:170
bool enable_keyring_operations()
Enable @keyring_operations variable.
Definition: migrate_keyring.cc:748
std::string m_destination_plugin_option
Definition: migrate_keyring.h:165
bool load_component()
Load component.
Definition: migrate_keyring.cc:454
bool fetch_and_store_keys()
Fetch keys from source plugin and store in destination plugin.
Definition: migrate_keyring.cc:614
~Migrate_keyring()
Standard destructor.
Definition: migrate_keyring.cc:766
MYSQL * mysql
Definition: migrate_keyring.h:172
char ** m_argv
Definition: migrate_keyring.h:163
Migrate_keyring()
Standard constructor.
Definition: migrate_keyring.cc:190
std::string m_source_plugin_name
Definition: migrate_keyring.h:166
bool init(int argc, char **argv, char *source_plugin, char *destination_plugin, char *user, char *host, char *password, char *socket, ulong port, bool migrate_to_component, bool migrate_from_component)
Initialize all needed parameters to proceed with migration process.
Definition: migrate_keyring.cc:231
bool m_migrate_to_component
Definition: migrate_keyring.h:174
std::vector< Key_info > m_source_keys
Definition: migrate_keyring.h:171
std::string m_internal_option[2]
Definition: migrate_keyring.h:168
bool disable_keyring_operations()
Disable @keyring_operations variable.
Definition: migrate_keyring.cc:731
std::string m_destination_plugin_name
Definition: migrate_keyring.h:167
Source_keyring_component * m_source_component
Definition: migrate_keyring.h:176
bool load_plugin(enum_plugin_type plugin_type)
Load source or destination plugin.
Definition: migrate_keyring.cc:486
bool execute()
Migrate keys from source keyring to destination keyring.
Definition: migrate_keyring.cc:390
bool m_migrate_from_component
Definition: migrate_keyring.h:175
Definition: migrate_keyring.h:86
~Source_keyring_component()
Definition: migrate_keyring.cc:136
const_keyring_keys_metadata_iterator_t * metadata_iterator()
Definition: migrate_keyring.h:95
Source_keyring_component(const std::string component_path, const std::string implementation_name)
Definition: migrate_keyring.cc:88
const_keyring_keys_metadata_iterator_t * keyring_keys_metadata_iterator_service_
Definition: migrate_keyring.h:101
const_keyring_reader_with_status_t * reader()
Definition: migrate_keyring.h:92
const_keyring_reader_with_status_t * keyring_reader_service_
Definition: migrate_keyring.h:102
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
enum_plugin_type
Definition: migrate_keyring.h:41
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
static char * password
Definition: mysql_secure_installation.cc:58
char * user
Definition: mysqladmin.cc:66
const char * host
Definition: mysqladmin.cc:65
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
Definition: mysql.h:300
Definition: mysql_com_server.h:59
Keyring keys metadata iterator service provides APIs to create and use iterator to access metadata as...
Definition: keyring_keys_metadata_iterator.h:76
Keyring load service provides way to initialize or reiniitalize keyring component.
Definition: keyring_load.h:52
Keyring reader with status service provides APIs to fetch sensitive data from keyring backend.
Definition: keyring_reader_with_status.h:128
Keyring writer service provides APIs to add/remove sensitive data to/from keyring backend.
Definition: keyring_writer.h:70
The descriptor structure for the plugin, that is referred from st_mysql_plugin.
Definition: plugin_keyring.h:39