MySQL 8.0.40
Source Code Documentation
config_generator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_CONFIG_GENERATOR_INCLUDED
27#define ROUTER_CONFIG_GENERATOR_INCLUDED
28
29#include <chrono>
30#include <functional>
31#include <map>
32#include <ostream>
33#include <set>
34#include <stdexcept>
35#include <string>
36#include <vector>
37
38#include "auto_cleaner.h"
45#include "mysqlrouter/uri.h"
46#include "random_generator.h"
47#include "tcp_address.h"
48#include "unique_ptr.h"
49
50namespace mysql_harness {
51class Path;
52}
53
54namespace mysqlrouter {
55class ClusterMetadata;
56class MySQLSession;
57class SysUserOperationsBase;
58class SysUserOperations;
59struct ClusterInfo;
60
62 public:
64 std::ostream &out_stream = std::cout, std::ostream &err_stream = std::cerr
65#ifndef _WIN32
66 ,
68#endif
69 );
71
72 /** @brief first part of the bootstrap process
73 *
74 * This function does a lot of initialisation before bootstrap starts making
75 * changes.
76 *
77 * @param server_url server to bootstrap from
78 * @param bootstrap_options bootstrap options
79 *
80 * @throws std::runtime_error
81 */
82 void init(const std::string &server_url,
83 const std::map<std::string, std::string> &bootstrap_options);
84
85 /** @brief logs warning and returns false if SSL mode is set to PREFERRED and
86 * SSL is not being used, true otherwise
87 *
88 * @param options map of commandline options
89 *
90 * @returns false if SSL mode is set to PREFERRED and SSL is not being used,
91 * true otherwise
92 *
93 * @throws std::runtime_error
94 */
95 bool warn_on_no_ssl(const std::map<std::string, std::string> &options);
96
98 const std::string &program_name, const std::string &config_file_path,
99 const std::string &state_file_path,
100 const std::map<std::string, std::string> &options,
101 const std::map<std::string, std::vector<std::string>> &multivalue_options,
102 const std::map<std::string, std::string> &default_paths);
103
105 const std::string &program_name, const std::string &directory,
106 const std::map<std::string, std::string> &options,
107 const std::map<std::string, std::vector<std::string>> &multivalue_options,
108 const std::map<std::string, std::string> &default_paths);
109
110 void set_keyring_info(const KeyringInfo &keyring_info) {
111 keyring_info_ = keyring_info;
112 }
113
114 struct Options {
115 struct Endpoint {
116 int port;
117 std::string socket;
118 Endpoint() : port(0) {}
119 Endpoint(const std::string &path) : port(0), socket(path) {}
120 Endpoint(int port_) : port(port_) {}
121
122 operator bool() const { return port > 0 || !socket.empty(); }
123 };
124 Options() = default;
125
130
131 std::string override_logdir;
133 std::string override_rundir;
134 std::string override_datadir;
135 std::string socketsdir;
136
137 std::string keyring_file_path;
140
141 std::string bind_address;
142
145
147
148 std::chrono::milliseconds ttl;
150
151 bool disable_rest{false};
152 std::string https_port_str;
153
154 std::string client_ssl_cert;
155 std::string client_ssl_cipher;
156 std::string client_ssl_curves;
157 std::string client_ssl_mode;
158 std::string client_ssl_key;
160
161 std::string server_ssl_cipher;
162 std::string server_ssl_curves;
163 std::string server_ssl_mode;
164 std::string server_ssl_ca;
165 std::string server_ssl_capath;
166 std::string server_ssl_crl;
168 std::string server_ssl_verify;
169
170 // only relevant for ClusterSet
171 std::string target_cluster;
173 };
174
175 void set_file_owner(
176 const std::map<std::string, std::string> &options,
177 const std::string &owner) const; // throws std::runtime_error
178
179 private:
180 /**
181 * init() calls this to read and validate several command-line options;
182 * results are stored in member fields.
183 *
184 * @param bootstrap_options options map to process
185 *
186 * @throws std::runtime_error on an invalid option
187 */
189 const std::map<std::string, std::string> &bootstrap_options);
190
191 /**
192 * init() calls this to validate and extract metadata server info from server
193 * URI, including user credentials. It will also:
194 * - set user name to "root" if not provided in the URI
195 * - prompt for user password if not provided in the URI
196 *
197 * @param server_uri server URI (--bootstrap|-B argument)
198 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
199 * argumenent)
200 *
201 * @returns URI with required information
202 *
203 * @throws std::runtime_error on an invalid data
204 */
205 URI parse_server_uri(const std::string &server_uri,
206 const std::string &bootstrap_socket);
207
208 /**
209 * init() calls this to connect to metadata server; sets mysql_ (connection)
210 * object.
211 *
212 * @param u parsed server URL (--bootstrap|-B argument)
213 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
214 * argumenent)
215 * @param bootstrap_options bootstrap command-line options
216 *
217 * @throws std::runtime_error
218 * @throws std::logic_error
219 */
221 const URI &u, const std::string &bootstrap_socket,
222 const std::map<std::string, std::string> &bootstrap_options);
223
224 /**
225 * init() calls this to set GR-related member fields.
226 *
227 * @param u parsed server URL (--bootstrap|-B argument)
228 * @param bootstrap_socket bootstrap (unix) socket (--bootstrap-socket
229 * argumenent)
230 *
231 * @throws TODO
232 */
233 void init_gr_data(const URI &u, const std::string &bootstrap_socket);
234
236 bool valid{false};
237 uint32_t router_id{0};
238 std::string username;
239 uint16_t rw_x_port{0};
240 uint16_t ro_x_port{0};
241 };
242
243 Options fill_options(const std::map<std::string, std::string> &user_options,
244 const std::map<std::string, std::string> &default_paths,
245 const ExistingConfigOptions &existing_config_options);
246
247 void create_start_script(const std::string &program_name,
248 const std::string &directory,
249 bool interactive_master_key,
250 const std::map<std::string, std::string> &options);
251
252 void create_stop_script(const std::string &directory,
253 const std::map<std::string, std::string> &options);
254
255 // virtual so we can disable it in unit tests
256 virtual void set_script_permissions(
257 const std::string &script_path,
258 const std::map<std::string, std::string> &options);
259
260 // returns bootstrap report (several lines of human-readable text) if desired
261 std::string bootstrap_deployment(
262 const std::string &program_name, std::ostream &config_file,
263 std::ostream &state_file, const mysql_harness::Path &config_file_path,
264 const mysql_harness::Path &state_file_path, const std::string &name,
265 const std::map<std::string, std::string> &options,
266 const std::map<std::string, std::vector<std::string>> &multivalue_options,
267 const std::map<std::string, std::string> &default_paths,
268 bool directory_deployment, AutoCleaner &auto_clean);
269
270 std::tuple<std::string> try_bootstrap_deployment(
271 uint32_t &router_id, std::string &username, std::string &password,
272 const std::string &router_name, const ClusterInfo &cluster_info,
273 const std::map<std::string, std::string> &user_options,
274 const std::map<std::string, std::vector<std::string>> &multivalue_options,
275 const Options &options);
276
277 void create_config(
278 std::ostream &config_file, std::ostream &state_file, uint32_t router_id,
279 const std::string &router_name, const std::string &system_username,
280 const ClusterInfo &cluster_info, const std::string &username,
281 const Options &options,
282 const std::map<std::string, std::string> &default_paths,
283 const std::map<std::string, std::string> &config_overwrites,
284 const std::string &state_file_name = "");
285
286 void print_bootstrap_start_msg(uint32_t router_id, bool directory_deployment,
287 const mysql_harness::Path &config_file_path);
288
289 std::string get_bootstrap_report_text(
290 const std::string &program_name, const std::string &config_file_name,
291 const std::string &router_name, const std::string &metadata_cluster,
292 const std::string &cluster_type_name, const std::string &hostname,
293 bool is_system_deployment, const Options &options);
294
296 const std::map<std::string, std::string> &default_paths,
297 const std::map<std::string, std::string> &user_options,
298 const Options &options);
299
300 /** @brief Deletes Router accounts just created
301 *
302 * This method runs as a cleanup after something goes wrong. Its purpose is
303 * to undo CREATE USER [IF NOT EXISTS] for accounts that got created during
304 * bootstrap. Note that it will drop only those accounts which did not exist
305 * prior to bootstrap (it may be a subset of account names passed to
306 * CREATE USER [IF NOT EXISTS]). If it is not able to determine what this
307 * (sub)set is, it will not drop anything - instead it will advise user on
308 * how to clean those up manually.
309 */
310 void undo_create_user_for_new_accounts() noexcept;
311
312 /** @brief Finds all hostnames given on command-line
313 *
314 * MySQL accounts are of form `<username>@<hostname>`. This function returns
315 * all `<hostname>` parts that were provided via --account-host switches
316 *
317 * @param multivalue_options key/list-of-values map of bootstrap config;
318 * carries --account-host inside
319 */
320 static std::set<std::string> get_account_host_args(
321 const std::map<std::string, std::vector<std::string>>
322 &multivalue_options) noexcept;
323
324 /** @brief Creates Router accounts
325 *
326 * Creates Router accounts for all hostnames (ie. `someuser@host1`,
327 * `someuser@host2`, `someuser@%`, etc). It will create such accounts for
328 * all hosts that appear in hostnames_cmdline, but not in hostnames_db.
329 *
330 * @note This is the higher-level method, which drives calls to lower-level
331 * methods like create_account_with_compliant_password() and
332 * create_accounts().
333 *
334 * @param user_options key/value map of bootstrap config options
335 * @param hostnames hostnames provided as --account-host arguments
336 * @param username Router account to be created (without the hostname part)
337 * @param password_change_ok password is allowed to be changed if needed
338 * @param password Router account password, will be overwritten if empty
339 *
340 * @returns auto-generated password
341 *
342 * @throws std::logic_error on not connected
343 * std::runtime_error on bad password or Server's password policy
344 * changing during bootstrap
345 * MySQLSession::Error on other (unexpected) SQL error
346 */
348 const std::map<std::string, std::string> &user_options,
349 const std::set<std::string> &hostnames, const std::string &username,
350 const std::string &password, bool password_change_ok);
351
352 /** @brief Creates Router account with compliant password
353 *
354 * Creates Router account with a (self-generated) password that will pass
355 * Server's password policy. It first tries creating a hashed password using
356 * mysql_native_password plugin. If that fails, it falls back to using
357 * plaintext password, which the Server may reject for not being strong
358 * enough. If that's the case, it will generate another password and try again
359 * 2 more times (for a total of 3 password-generation attempts), after which
360 * it will give up.
361 *
362 * @note This is a higher-level method, with smart logic that drives calls to
363 * lower-level create_accounts() method.
364 *
365 * @param user_options key/value map of bootstrap config options
366 * @param username Router account to be created - the username part
367 * @param hostnames Router accounts to be created - the hostname part
368 * @param password Password for the account
369 * @param password_change_ok password is allowed to be changed if needed
370 * @param if_not_exists if true, CREATE USER IF NOT EXISTS will be used
371 * instead of CREATE USER
372 *
373 * @returns password
374 *
375 * @throws std::logic_error on not connected
376 * std::runtime_error on bad password
377 * MySQLSession::Error on other (unexpected) SQL error
378 */
380 const std::map<std::string, std::string> &user_options,
381 const std::string &username, const std::set<std::string> &hostnames,
382 const std::string &password, bool password_change_ok, bool if_not_exists);
383
384 /** @brief Creates Router account (low-level function)
385 *
386 * Creates Router account using CREATE USER [IF NOT EXISTS] and gives it
387 * GRANTs.
388 *
389 * @param username Router account to be created - the username part
390 * @param hostnames Router accounts to be created - the hostnames part
391 * @param password Password for the account
392 * @param if_not_exists if true, CREATE USER IF NOT EXISTS will be used
393 * instead of CREATE USER
394 *
395 * @throws std::logic_error on not connected
396 * password_too_weak on Server not liking the password
397 * account_exists if running without IF NOT EXISTS and account exists
398 * already MySQLSession::Error on other (unexpected) SQL error
399 */
400 void create_accounts(const std::string &username,
401 const std::set<std::string> &hostnames,
402 const std::string &password, bool if_not_exists = false);
403
404 void create_users(const std::string &username,
405 const std::set<std::string> &hostnames,
406 const std::string &password, bool if_not_exists);
407
409 const std::string &username);
410
412 const std::string &username, const std::set<std::string> &hostnames,
413 bool if_not_exists);
414
415 void give_grants_to_users(const std::string &new_accounts);
416
417 std::string make_account_list(const std::string username,
418 const std::set<std::string> &hostnames);
419
420 ExistingConfigOptions get_options_from_config_if_it_exists(
421 const std::string &config_file_path,
422 const mysqlrouter::ClusterInfo &cluster_info, bool forcing_overwrite);
423
424 void update_router_info(uint32_t router_id, const Options &options);
425
427 const mysql_harness::Path &config_path, const std::string &new_file_path,
428 const std::map<std::string, std::string> &options,
429 AutoCleaner *auto_cleaner = nullptr);
430
431 void set_keyring_info_real_paths(std::map<std::string, std::string> &options,
432 const mysql_harness::Path &path);
433
435 AutoCleaner &auto_clean,
436 const std::map<std::string, std::string> &user_options,
437 uint32_t router_id, const std::string &username,
438 const std::string &password, Options &options);
439
440 std::string fetch_password_from_keyring(const std::string &username,
441 uint32_t router_id);
442
444 AutoCleaner &auto_clean,
445 const std::map<std::string, std::string> &user_options,
446 uint32_t router_id);
447
448 void init_keyring_file(uint32_t router_id, bool create_if_needed = true);
449
450 static void set_ssl_options(
451 MySQLSession *sess, const std::map<std::string, std::string> &options);
452
453 void ensure_router_id_is_ours(uint32_t &router_id,
454 const std::string &hostname_override);
455
456 uint32_t register_router(const std::string &router_name,
457 const std::string &hostname_override, bool force);
458
459 void verify_router_account(const std::string &username,
460 const std::string &password, bool strict);
461
462 /**
463 * @brief Prepare X.509 certificates for the Router.
464 *
465 * If user provides Router certificate and key files they are used in the
466 * first place so no action is taken in this method. If there are no existing
467 * certificate files then CA certificate and key along with Router certificate
468 * and key will be created.
469 *
470 * @param[in] user_options Key/value map of bootstrap config options.
471 * @param[in] default_paths Map of predefined default paths.
472 * @param[in,out] auto_cleaner Automatic file cleanup object that guarantees
473 * file cleanup if bootstrap fails at any point.
474 *
475 * @throws std::runtime_error Data directory contains some certificate files
476 * but Router certificate and/or key is missing.
477 */
479 const std::map<std::string, std::string> &user_options,
480 const std::map<std::string, std::string> &default_paths,
481 AutoCleaner *auto_cleaner) const;
482
483 /**
484 * @brief Check if datadir directory contains only files that are allowed
485 * before the bootstrap.
486 *
487 * @param[in] dir Data directory representation.
488 *
489 * @retval false - datadir contains files that are not allowed before the
490 * bootstrap.
491 * @retval true - datadir does not contain files that are not allowed before
492 * the bootstrap.
493 */
495 const mysql_harness::Directory &dir) const;
496
497 private:
502
503 // For GR cluster Group Replication ID, for AR cluster cluster_id from the
504 // metadata, for ClusterSet clusterset_id
511
514
515 std::ostream &out_stream_;
516 std::ostream &err_stream_;
517
519 enum {
520 kNotSet = 1, // =1 is not a requirement, just defensive programming
522 kNewAccounts
523 } type = kNotSet;
524 std::string accounts;
526
527 const struct TLS_filenames {
528 std::string ca_key{"ca-key.pem"};
529 std::string ca_cert{"ca.pem"};
530 std::string router_key{"router-key.pem"};
531 std::string router_cert{"router-cert.pem"};
533
534#ifndef _WIN32
536#endif
537
539};
540} // namespace mysqlrouter
541#endif // ROUTER_CONFIG_GENERATOR_INCLUDED
The ClusterMetadata class encapsulates a connection to the Metadata server.
Definition: cluster_metadata.h:64
Class representing an error.
Definition: error.h:48
KeyringInfo class encapsulates loading and storing master key using master-key-reader and master-key-...
Definition: keyring_info.h:76
A helper class for handling file paths.
Definition: path.h:38
Class representing a path in a file system.
Definition: filesystem.h:63
Automatic cleanup on scope exit utility class.
Definition: auto_cleaner.h:62
Definition: cluster_metadata.h:59
Definition: config_generator.h:61
void give_grants_to_users(const std::string &new_accounts)
Definition: config_generator.cc:3081
std::string fetch_password_from_keyring(const std::string &username, uint32_t router_id)
Definition: config_generator.cc:1955
std::string cluster_initial_password_
Definition: config_generator.h:509
void connect_to_metadata_server(const URI &u, const std::string &bootstrap_socket, const std::map< std::string, std::string > &bootstrap_options)
init() calls this to connect to metadata server; sets mysql_ (connection) object.
Definition: config_generator.cc:387
SysUserOperationsBase * sys_user_operations_
Definition: config_generator.h:535
void init(const std::string &server_url, const std::map< std::string, std::string > &bootstrap_options)
first part of the bootstrap process
Definition: config_generator.cc:422
std::string cluster_initial_username_
Definition: config_generator.h:508
void create_users(const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists)
Definition: config_generator.cc:2915
std::unique_ptr< MySQLSession > mysql_
Definition: config_generator.h:498
std::string cluster_initial_socket_
Definition: config_generator.h:510
void create_stop_script(const std::string &directory, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3544
bool keyring_initialized_
Definition: config_generator.h:513
bool datadir_contains_allowed_files(const mysql_harness::Directory &dir) const
Check if datadir directory contains only files that are allowed before the bootstrap.
Definition: config_generator.cc:612
void set_keyring_info_real_paths(std::map< std::string, std::string > &options, const mysql_harness::Path &path)
Definition: config_generator.cc:1942
void set_file_owner(const std::map< std::string, std::string > &options, const std::string &owner) const
Definition: config_generator.cc:3648
ExistingConfigOptions get_options_from_config_if_it_exists(const std::string &config_file_path, const mysqlrouter::ClusterInfo &cluster_info, bool forcing_overwrite)
Get selected configuration options from the existing Router configuration file.
Definition: config_generator.cc:3334
void init_keyring_and_master_key(AutoCleaner &auto_clean, const std::map< std::string, std::string > &user_options, uint32_t router_id)
Definition: config_generator.cc:2006
std::ostream & out_stream_
Definition: config_generator.h:515
mysqlrouter::MetadataSchemaVersion schema_version_
Definition: config_generator.h:538
void create_config(std::ostream &config_file, std::ostream &state_file, uint32_t router_id, const std::string &router_name, const std::string &system_username, const ClusterInfo &cluster_info, const std::string &username, const Options &options, const std::map< std::string, std::string > &default_paths, const std::map< std::string, std::string > &config_overwrites, const std::string &state_file_name="")
Definition: config_generator.cc:2439
void throw_account_exists(const MySQLSession::Error &e, const std::string &username)
Definition: config_generator.cc:2861
std::string create_router_accounts(const std::map< std::string, std::string > &user_options, const std::set< std::string > &hostnames, const std::string &username, const std::string &password, bool password_change_ok)
Creates Router accounts.
Definition: config_generator.cc:2762
std::unique_ptr< ClusterMetadata > metadata_
Definition: config_generator.h:499
void bootstrap_directory_deployment(const std::string &program_name, const std::string &directory, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths)
Create a self-contained deployment of the Router in a directory.
Definition: config_generator.cc:629
std::string get_bootstrap_report_text(const std::string &program_name, const std::string &config_file_name, const std::string &router_name, const std::string &metadata_cluster, const std::string &cluster_type_name, const std::string &hostname, bool is_system_deployment, const Options &options)
Definition: config_generator.cc:2657
int connect_timeout_
Definition: config_generator.h:500
void print_bootstrap_start_msg(uint32_t router_id, bool directory_deployment, const mysql_harness::Path &config_file_path)
Definition: config_generator.cc:2634
void init_gr_data(const URI &u, const std::string &bootstrap_socket)
init() calls this to set GR-related member fields.
Definition: config_generator.cc:410
std::string make_account_list(const std::string username, const std::set< std::string > &hostnames)
Definition: config_generator.cc:3112
void undo_create_user_for_new_accounts() noexcept
Deletes Router accounts just created.
Definition: config_generator.cc:3181
std::string cluster_specific_id_
Definition: config_generator.h:505
void update_router_info(uint32_t router_id, const Options &options)
std::ostream & err_stream_
Definition: config_generator.h:516
bool warn_on_no_ssl(const std::map< std::string, std::string > &options)
logs warning and returns false if SSL mode is set to PREFERRED and SSL is not being used,...
Definition: config_generator.cc:240
ConfigGenerator(std::ostream &out_stream=std::cout, std::ostream &err_stream=std::cerr, SysUserOperationsBase *sys_user_operations=SysUserOperations::instance())
Definition: config_generator.cc:189
std::string bootstrap_deployment(const std::string &program_name, std::ostream &config_file, std::ostream &state_file, const mysql_harness::Path &config_file_path, const mysql_harness::Path &state_file_path, const std::string &name, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths, bool directory_deployment, AutoCleaner &auto_clean)
Definition: config_generator.cc:1430
int read_timeout_
Definition: config_generator.h:501
void verify_router_account(const std::string &username, const std::string &password, bool strict)
Definition: config_generator.cc:1630
URI parse_server_uri(const std::string &server_uri, const std::string &bootstrap_socket)
init() calls this to validate and extract metadata server info from server URI, including user creden...
Definition: config_generator.cc:329
struct mysqlrouter::ConfigGenerator::UndoCreateAccountList undo_create_account_list_
void set_log_file_permissions(const std::map< std::string, std::string > &default_paths, const std::map< std::string, std::string > &user_options, const Options &options)
Definition: config_generator.cc:1256
void init_keyring_file(uint32_t router_id, bool create_if_needed=true)
Definition: config_generator.cc:2034
std::set< std::string > get_hostnames_of_created_accounts(const std::string &username, const std::set< std::string > &hostnames, bool if_not_exists)
Definition: config_generator.cc:2971
void bootstrap_system_deployment(const std::string &program_name, const std::string &config_file_path, const std::string &state_file_path, const std::map< std::string, std::string > &options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const std::map< std::string, std::string > &default_paths)
Definition: config_generator.cc:518
void parse_bootstrap_options(const std::map< std::string, std::string > &bootstrap_options)
init() calls this to read and validate several command-line options; results are stored in member fie...
Definition: config_generator.cc:284
const struct mysqlrouter::ConfigGenerator::TLS_filenames tls_filenames_
void create_start_script(const std::string &program_name, const std::string &directory, bool interactive_master_key, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3449
std::string cluster_initial_hostname_
Definition: config_generator.h:506
Options fill_options(const std::map< std::string, std::string > &user_options, const std::map< std::string, std::string > &default_paths, const ExistingConfigOptions &existing_config_options)
Definition: config_generator.cc:860
void prepare_ssl_certificate_files(const std::map< std::string, std::string > &user_options, const std::map< std::string, std::string > &default_paths, AutoCleaner *auto_cleaner) const
Prepare X.509 certificates for the Router.
Definition: config_generator.cc:1290
KeyringInfo keyring_info_
Definition: config_generator.h:512
virtual void set_script_permissions(const std::string &script_path, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:3431
unsigned int cluster_initial_port_
Definition: config_generator.h:507
uint32_t register_router(const std::string &router_name, const std::string &hostname_override, bool force)
Definition: config_generator.cc:1571
void create_accounts(const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists=false)
Creates Router account (low-level function)
Definition: config_generator.cc:3132
void ensure_router_id_is_ours(uint32_t &router_id, const std::string &hostname_override)
Definition: config_generator.cc:1548
void store_credentials_in_keyring(AutoCleaner &auto_clean, const std::map< std::string, std::string > &user_options, uint32_t router_id, const std::string &username, const std::string &password, Options &options)
Definition: config_generator.cc:1983
static std::set< std::string > get_account_host_args(const std::map< std::string, std::vector< std::string > > &multivalue_options) noexcept
Finds all hostnames given on command-line.
Definition: config_generator.cc:1612
static void set_ssl_options(MySQLSession *sess, const std::map< std::string, std::string > &options)
Definition: config_generator.cc:211
std::tuple< std::string > try_bootstrap_deployment(uint32_t &router_id, std::string &username, std::string &password, const std::string &router_name, const ClusterInfo &cluster_info, const std::map< std::string, std::string > &user_options, const std::map< std::string, std::vector< std::string > > &multivalue_options, const Options &options)
Definition: config_generator.cc:1865
bool backup_config_file_if_different(const mysql_harness::Path &config_path, const std::string &new_file_path, const std::map< std::string, std::string > &options, AutoCleaner *auto_cleaner=nullptr)
Definition: config_generator.cc:3617
std::string create_accounts_with_compliant_password(const std::map< std::string, std::string > &user_options, const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool password_change_ok, bool if_not_exists)
Creates Router account with compliant password.
Definition: config_generator.cc:2812
void set_keyring_info(const KeyringInfo &keyring_info)
Definition: config_generator.h:110
Definition: mysql_session.h:153
Base class to allow multiple SysUserOperations implementations.
Definition: sys_user_operations.h:45
static SysUserOperations * instance()
Definition: sys_user_operations.cc:49
Parse and create URIs according to RFC3986.
Definition: uri.h:70
static std::map< string, enum_variable_source > default_paths
Defines mapping between config files names and its corresponding enum values.
Definition: my_default.cc:116
static char * password
Definition: mysql_secure_installation.cc:56
static char * path
Definition: mysqldump.cc:137
constexpr pos_type Options
Definition: http_request.h:261
std::string dir
Double write files location.
Definition: buf0dblwr.cc:77
const std::string config_file_name
Definition: config.cc:64
Definition: common.h:42
Definition: dim.h:358
Definition: options.cc:49
Definition: gcs_xcom_synode.h:64
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2875
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2883
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2893
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2439
required string type
Definition: replication_group_member_actions.proto:34
case opt name
Definition: sslopt-case.h:33
Definition: cluster_metadata.h:40
Definition: config_generator.h:235
uint32_t router_id
Definition: config_generator.h:237
bool valid
Definition: config_generator.h:236
uint16_t ro_x_port
Definition: config_generator.h:240
std::string username
Definition: config_generator.h:238
uint16_t rw_x_port
Definition: config_generator.h:239
Definition: config_generator.h:115
std::string socket
Definition: config_generator.h:117
int port
Definition: config_generator.h:116
Endpoint(const std::string &path)
Definition: config_generator.h:119
Endpoint()
Definition: config_generator.h:118
Endpoint(int port_)
Definition: config_generator.h:120
Definition: config_generator.h:114
std::string target_cluster_by_name
Definition: config_generator.h:172
Endpoint ro_x_endpoint
Definition: config_generator.h:129
std::string server_ssl_curves
Definition: config_generator.h:162
std::string client_ssl_dh_params
Definition: config_generator.h:159
std::string server_ssl_verify
Definition: config_generator.h:168
std::string target_cluster
Definition: config_generator.h:171
std::string keyring_master_key_file_path
Definition: config_generator.h:139
std::string override_logfilename
Definition: config_generator.h:132
std::string client_ssl_mode
Definition: config_generator.h:157
std::string keyring_master_key
Definition: config_generator.h:138
Endpoint ro_endpoint
Definition: config_generator.h:127
std::string bind_address
Definition: config_generator.h:141
mysqlrouter::SSLOptions ssl_options
Definition: config_generator.h:146
int connect_timeout
Definition: config_generator.h:143
std::string client_ssl_curves
Definition: config_generator.h:156
bool disable_rest
Definition: config_generator.h:151
std::string client_ssl_key
Definition: config_generator.h:158
std::string override_datadir
Definition: config_generator.h:134
std::string override_logdir
Definition: config_generator.h:131
Endpoint rw_x_endpoint
Definition: config_generator.h:128
std::string server_ssl_mode
Definition: config_generator.h:163
Endpoint rw_endpoint
Definition: config_generator.h:126
std::string server_ssl_cipher
Definition: config_generator.h:161
std::string client_ssl_cert
Definition: config_generator.h:154
int read_timeout
Definition: config_generator.h:144
std::string server_ssl_capath
Definition: config_generator.h:165
std::string https_port_str
Definition: config_generator.h:152
std::string keyring_file_path
Definition: config_generator.h:137
std::chrono::milliseconds ttl
Definition: config_generator.h:148
std::string socketsdir
Definition: config_generator.h:135
bool use_gr_notifications
Definition: config_generator.h:149
std::string override_rundir
Definition: config_generator.h:133
std::string client_ssl_cipher
Definition: config_generator.h:155
std::string server_ssl_crlpath
Definition: config_generator.h:167
std::string server_ssl_crl
Definition: config_generator.h:166
std::string server_ssl_ca
Definition: config_generator.h:164
Definition: config_generator.h:527
std::string router_key
Definition: config_generator.h:530
std::string router_cert
Definition: config_generator.h:531
std::string ca_key
Definition: config_generator.h:528
std::string ca_cert
Definition: config_generator.h:529
Definition: config_generator.h:518
@ kAllAccounts
Definition: config_generator.h:521
std::string accounts
Definition: config_generator.h:524
Definition: cluster_metadata.h:40
SSL connection related options.
Definition: datatypes.h:39