@@ -51,6 +51,36 @@ static void add_to_plugin_load_list(const char *plugin_def)
51
51
52
52
static char XTRABACKUP_EXE[] = " xtrabackup" ;
53
53
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
+
54
84
void encryption_plugin_backup_init (MYSQL *mysql)
55
85
{
56
86
MYSQL_RES *result;
@@ -78,7 +108,17 @@ void encryption_plugin_backup_init(MYSQL *mysql)
78
108
79
109
std::string plugin_load (name);
80
110
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
+ }
81
120
plugin_load += std::string (" =" ) + library;
121
+ }
82
122
83
123
oss << " plugin_load=" << plugin_load << std::endl;
84
124
@@ -140,14 +180,18 @@ extern int finalize_encryption_plugin(st_plugin_int *plugin);
140
180
141
181
void encryption_plugin_prepare_init (int argc, char **argv)
142
182
{
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
145
189
{
146
190
finalize_encryption_plugin (0 );
147
191
return ;
148
192
}
149
193
150
- add_to_plugin_load_list (xb_plugin_load );
194
+ add_to_plugin_load_list (plugin_load. c_str () );
151
195
152
196
if (xb_plugin_dir)
153
197
strncpy (opt_plugin_dir, xb_plugin_dir, FN_REFLEN);
0 commit comments