MySQL 8.0.30
Source Code Documentation
migrate_keyring.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2022, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MIGRATE_KEYRING_H_INCLUDED
24#define MIGRATE_KEYRING_H_INCLUDED
25
26#include <string>
27#include "mysql.h"
29#include "sql_common.h" // NET_SERVER
30
33
34class THD;
35
36#define MAX_KEY_LEN 16384
37
39
40class Key_info {
41 public:
42 Key_info() = default;
43 Key_info(char *key_id, char *user_id) {
44 m_key_id = key_id;
45 m_user_id = user_id;
46 }
47 Key_info(const Key_info &ki) {
48 this->m_key_id = ki.m_key_id;
49 this->m_user_id = ki.m_user_id;
50 }
51
52 public:
53 std::string m_key_id;
54 std::string m_user_id;
55};
56
57using const_keyring_writer_t = SERVICE_TYPE(keyring_writer);
58using const_keyring_load_t = SERVICE_TYPE(keyring_load);
59
61 public:
62 Destination_keyring_component(const std::string component_path,
63 const std::string implementation_name);
65
68
69 bool ok() { return ok_; }
70
71 private:
72 const std::string component_path_;
76 bool ok_;
77};
78
80 public:
81 /**
82 Standard constructor.
83 */
85 /**
86 Initialize all needed parameters to proceed with migration process.
87 */
88 bool init(int argc, char **argv, char *source_plugin,
89 char *destination_plugin, char *user, char *host, char *password,
90 char *socket, ulong port, bool migrate_to_component);
91 /**
92 Migrate keys from source keyring to destination keyring.
93 */
94 bool execute();
95 /**
96 Standard destructor
97 */
99
100 private:
101 /**
102 Load source or destination plugin.
103 */
104 bool load_plugin(enum_plugin_type plugin_type);
105 /**
106 Load component
107 */
108 bool load_component();
109 /**
110 Fetch keys from source plugin and store in destination plugin.
111 */
113 /**
114 Disable @@keyring_operations variable.
115 */
117 /**
118 Enable @@keyring_operations variable.
119 */
121
122 private:
124 char **m_argv;
129 std::string m_internal_option[2];
132 std::vector<Key_info> m_source_keys;
137};
138
139#endif /* MIGRATE_KEYRING_H_INCLUDED */
Definition: migrate_keyring.h:60
const_keyring_writer_t * writer()
Definition: migrate_keyring.h:66
Destination_keyring_component(const std::string component_path, const std::string implementation_name)
Definition: migrate_keyring.cc:35
~Destination_keyring_component()
Definition: migrate_keyring.cc:92
bool ok_
Definition: migrate_keyring.h:76
const std::string component_path_
Definition: migrate_keyring.h:72
const_keyring_load_t * initializer()
Definition: migrate_keyring.h:67
const_keyring_load_t * keyring_load_service_
Definition: migrate_keyring.h:73
const_keyring_writer_t * keyring_writer_service_
Definition: migrate_keyring.h:74
bool component_loaded_
Definition: migrate_keyring.h:75
bool ok()
Definition: migrate_keyring.h:69
Definition: migrate_keyring.h:40
std::string m_key_id
Definition: migrate_keyring.h:53
Key_info(char *key_id, char *user_id)
Definition: migrate_keyring.h:43
Key_info(const Key_info &ki)
Definition: migrate_keyring.h:47
std::string m_user_id
Definition: migrate_keyring.h:54
Key_info()=default
Definition: migrate_keyring.h:79
st_mysql_keyring * m_source_plugin_handle
Definition: migrate_keyring.h:130
std::string m_source_plugin_option
Definition: migrate_keyring.h:125
Destination_keyring_component * m_destination_component
Definition: migrate_keyring.h:136
int m_argc
Definition: migrate_keyring.h:123
NET_SERVER server_extn
Definition: migrate_keyring.h:134
st_mysql_keyring * m_destination_plugin_handle
Definition: migrate_keyring.h:131
bool enable_keyring_operations()
Enable @keyring_operations variable.
Definition: migrate_keyring.cc:545
std::string m_destination_plugin_option
Definition: migrate_keyring.h:126
bool load_component()
Load component.
Definition: migrate_keyring.cc:362
bool fetch_and_store_keys()
Fetch keys from source plugin and store in destination plugin.
Definition: migrate_keyring.cc:440
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)
Initialize all needed parameters to proceed with migration process.
Definition: migrate_keyring.cc:150
~Migrate_keyring()
Standard destructor.
Definition: migrate_keyring.cc:563
MYSQL * mysql
Definition: migrate_keyring.h:133
char ** m_argv
Definition: migrate_keyring.h:124
Migrate_keyring()
Standard constructor.
Definition: migrate_keyring.cc:113
std::string m_source_plugin_name
Definition: migrate_keyring.h:127
bool m_migrate_to_component
Definition: migrate_keyring.h:135
std::vector< Key_info > m_source_keys
Definition: migrate_keyring.h:132
std::string m_internal_option[2]
Definition: migrate_keyring.h:129
bool disable_keyring_operations()
Disable @keyring_operations variable.
Definition: migrate_keyring.cc:528
std::string m_destination_plugin_name
Definition: migrate_keyring.h:128
bool load_plugin(enum_plugin_type plugin_type)
Load source or destination plugin.
Definition: migrate_keyring.cc:382
bool execute()
Migrate keys from source keyring to destination keyring.
Definition: migrate_keyring.cc:291
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
char * argv[]
Definition: do_ctype.cc:45
get_options & argc
Definition: do_ctype.cc:51
enum_plugin_type
Definition: migrate_keyring.h:38
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:55
char * user
Definition: mysqladmin.cc:59
const char * host
Definition: mysqladmin.cc:58
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:56
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:32
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:75
Definition: mysql.h:298
Definition: mysql_com_server.h:58
Keyring load service provides way to initialize or reiniitalize keyring component.
Definition: keyring_load.h:51
Keyring writer service provides APIs to add/remove sensitive data to/from keyring backend.
Definition: keyring_writer.h:69
The descriptor structure for the plugin, that is referred from st_mysql_plugin.
Definition: plugin_keyring.h:38