Skip to content

Commit 4901f31

Browse files
committed
Merge 10.2 into 10.3
2 parents c3a8017 + 59950df commit 4901f31

File tree

9 files changed

+672
-50
lines changed

9 files changed

+672
-50
lines changed

extra/mariabackup/encryption_plugin.cc

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,36 @@ static void add_to_plugin_load_list(const char *plugin_def)
5151

5252
static char XTRABACKUP_EXE[] = "xtrabackup";
5353

54+
/*
55+
Read "plugin-load" value (encryption plugin) from backup-my.cnf during
56+
prepare phase.
57+
The value is stored during backup phase.
58+
*/
59+
static std::string get_encryption_plugin_from_cnf()
60+
{
61+
FILE *f = fopen("backup-my.cnf", "r");
62+
if (!f)
63+
{
64+
msg("cannot open backup-my.cnf for reading\n");
65+
exit(EXIT_FAILURE);
66+
}
67+
char line[512];
68+
std::string plugin_load;
69+
while (fgets(line, sizeof(line), f))
70+
{
71+
if (strncmp(line, "plugin_load=", 12) == 0)
72+
{
73+
plugin_load = line + 12;
74+
// remote \n at the end of string
75+
plugin_load.resize(plugin_load.size() - 1);
76+
break;
77+
}
78+
}
79+
fclose(f);
80+
return plugin_load;
81+
}
82+
83+
5484
void encryption_plugin_backup_init(MYSQL *mysql)
5585
{
5686
MYSQL_RES *result;
@@ -78,7 +108,17 @@ void encryption_plugin_backup_init(MYSQL *mysql)
78108

79109
std::string plugin_load(name);
80110
if (library)
111+
{
112+
/* Remove shared library suffixes, in case we'll prepare on different OS.*/
113+
const char *extensions[] = { ".dll", ".so", 0 };
114+
for (size_t i = 0; extensions[i]; i++)
115+
{
116+
const char *ext = extensions[i];
117+
if (ends_with(library, ext))
118+
library[strlen(library) - strlen(ext)] = 0;
119+
}
81120
plugin_load += std::string("=") + library;
121+
}
82122

83123
oss << "plugin_load=" << plugin_load << std::endl;
84124

@@ -140,14 +180,18 @@ extern int finalize_encryption_plugin(st_plugin_int *plugin);
140180

141181
void encryption_plugin_prepare_init(int argc, char **argv)
142182
{
143-
144-
if (!xb_plugin_load)
183+
std::string plugin_load= get_encryption_plugin_from_cnf();
184+
if (plugin_load.size())
185+
{
186+
msg("Loading encryption plugin from %s\n", plugin_load.c_str());
187+
}
188+
else
145189
{
146190
finalize_encryption_plugin(0);
147191
return;
148192
}
149193

150-
add_to_plugin_load_list(xb_plugin_load);
194+
add_to_plugin_load_list(plugin_load.c_str());
151195

152196
if (xb_plugin_dir)
153197
strncpy(opt_plugin_dir, xb_plugin_dir, FN_REFLEN);

extra/mariabackup/xtrabackup.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ enum options_xtrabackup
709709
OPT_INNODB_LOG_CHECKSUMS,
710710
OPT_XTRA_INCREMENTAL_FORCE_SCAN,
711711
OPT_DEFAULTS_GROUP,
712-
OPT_PLUGIN_LOAD,
713712
OPT_INNODB_ENCRYPT_LOG,
714713
OPT_CLOSE_FILES,
715714
OPT_CORE_FILE,
@@ -1268,11 +1267,7 @@ struct my_option xb_server_options[] =
12681267
&xb_plugin_dir, &xb_plugin_dir,
12691268
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
12701269

1271-
{ "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load during 'prepare' phase.",
1272-
&xb_plugin_load, &xb_plugin_load,
1273-
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1274-
1275-
{ "innodb-encrypt-log", OPT_INNODB_ENCRYPT_LOG, "encrypton plugin to load",
1270+
{ "innodb-encrypt-log", OPT_INNODB_ENCRYPT_LOG, "Whether to encrypt innodb log",
12761271
&srv_encrypt_log, &srv_encrypt_log,
12771272
0, GET_BOOL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
12781273

0 commit comments

Comments
 (0)