summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/aws_key_management/aws_key_management_plugin.cc35
-rw-r--r--plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test8
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet4.result2
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6.result2
-rw-r--r--plugin/type_uuid/mysql-test/type_uuid/type_uuid.result2
5 files changed, 33 insertions, 16 deletions
diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc
index 7740c2eae60..496c7704517 100644
--- a/plugin/aws_key_management/aws_key_management_plugin.cc
+++ b/plugin/aws_key_management/aws_key_management_plugin.cc
@@ -82,6 +82,7 @@ static unsigned long log_level;
static int rotate_key;
static int request_timeout;
static char* endpoint_url;
+static char* keyfile_dir;
#ifndef DBUG_OFF
#define WITH_AWS_MOCK 1
@@ -187,13 +188,23 @@ protected:
}
};
-/* Get list of files in current directory */
-static vector<string> traverse_current_directory()
+/* Get keyfile directory */
+static const char * get_keyfile_dir()
+{
+ if (keyfile_dir && keyfile_dir[0])
+ return keyfile_dir;
+ return ".";
+}
+
+/* Get list of files in keyfile directory */
+static vector<string> traverse_keyfile_directory()
{
vector<string> v;
#ifdef _WIN32
WIN32_FIND_DATA find_data;
- HANDLE h= FindFirstFile("*.*", &find_data);
+ char path[FN_REFLEN];
+ snprintf(path, sizeof(path), "%s\\*.*", get_keyfile_dir());
+ HANDLE h= FindFirstFile(path, &find_data);
if (h == INVALID_HANDLE_VALUE)
return v;
do
@@ -203,7 +214,7 @@ static vector<string> traverse_current_directory()
while (FindNextFile(h, &find_data));
FindClose(h);
#else
- DIR *dir = opendir(".");
+ DIR *dir = opendir(get_keyfile_dir());
if (!dir)
return v;
struct dirent *e;
@@ -272,7 +283,7 @@ static int plugin_init(void *p)
if (init())
return -1;
- vector<string> files= traverse_current_directory();
+ vector<string> files= traverse_keyfile_directory();
for (size_t i=0; i < files.size(); i++)
{
@@ -316,7 +327,7 @@ static int plugin_deinit(void *p)
/* Generate filename to store the ciphered key */
static void format_keyfile_name(char *buf, size_t size, uint key_id, uint version)
{
- snprintf(buf, size, "aws-kms-key.%u.%u", key_id, version);
+ snprintf(buf, size, "%s%saws-kms-key.%u.%u", get_keyfile_dir(), IF_WIN("\\","/"), key_id, version);
}
/* Extract key id and version from file name */
@@ -336,7 +347,7 @@ static int extract_id_and_version(const char *name, uint *id, uint *ver)
static int load_key(KEY_INFO *info)
{
int ret;
- char path[256];
+ char path[FN_REFLEN];
format_keyfile_name(path, sizeof(path), info->key_id, info->key_version);
ret= read_and_decrypt_key(path, info);
@@ -531,7 +542,7 @@ static int generate_and_save_datakey(uint keyid, uint version)
return -1;
string out;
- char filename[20];
+ char filename[FN_REFLEN];
format_keyfile_name(filename, sizeof(filename), keyid, version);
int fd= open(filename, O_WRONLY |O_CREAT|O_BINARY, IF_WIN(_S_IREAD, S_IRUSR| S_IRGRP| S_IROTH));
if (fd < 0)
@@ -652,7 +663,6 @@ static unsigned int get_key(
return(0);
}
-
/* Plugin defs */
struct st_mariadb_encryption aws_key_management_plugin= {
MariaDB_ENCRYPTION_INTERFACE_VERSION,
@@ -725,6 +735,12 @@ static MYSQL_SYSVAR_STR(endpoint_url, endpoint_url,
"Used to override the default AWS API endpoint. If not set, the default will be used",
NULL, NULL, "");
+static MYSQL_SYSVAR_STR(keyfile_dir, keyfile_dir,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+ "Define the directory in which to save key files for the AWS key"
+ "management plugin. If not set, the root datadir will be used",
+ NULL, NULL, "");
+
#if WITH_AWS_MOCK
static MYSQL_SYSVAR_BOOL(mock, mock,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -740,6 +756,7 @@ static struct st_mysql_sys_var* settings[]= {
MYSQL_SYSVAR(request_timeout),
MYSQL_SYSVAR(region),
MYSQL_SYSVAR(endpoint_url),
+ MYSQL_SYSVAR(keyfile_dir),
#if WITH_AWS_MOCK
MYSQL_SYSVAR(mock),
#endif
diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test
index ce99406ab06..c446036aaae 100644
--- a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test
+++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_key_rotation_age.test
@@ -33,7 +33,7 @@ let $restart_parameters=$default_parameters --innodb_encryption_threads=5 --inno
--echo # Wait until encryption threads have encrypted all tablespaces
---let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
+--let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
@@ -63,7 +63,7 @@ alter table t33 encryption_key_id=222;
--echo # Wait until encryption threads have encrypted all tablespaces
---let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
+--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
@@ -77,7 +77,7 @@ set global innodb_encrypt_tables = OFF;
--echo # Wait until encryption threads to decrypt all encrypted tablespaces
---let $tables_count= `select count(*) - 1 from information_schema.tables where engine = 'InnoDB'`
+--let $tables_count= `select count(*) - 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0;
--source include/wait_condition.inc
@@ -105,7 +105,7 @@ set global innodb_encrypt_tables = ON;
--echo # Wait until encryption threads to encrypt all unencrypted tablespaces
---let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'`
+--let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc
diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet4.result b/plugin/type_inet/mysql-test/type_inet/type_inet4.result
index 7763b28e1fb..30cb6f7fe94 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet4.result
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet4.result
@@ -1337,7 +1337,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Using where
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 Using index; Using where
SET @@optimizer_switch=DEFAULT;
DROP TABLE t1;
#
diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result
index 8d52e85cb91..b399400ab87 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result
@@ -1330,7 +1330,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 2 Using index; Using where
+2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 1 Using index; Using where
SET @@optimizer_switch=DEFAULT;
DROP TABLE t1;
#
diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result
index ab30c262148..b3955d09735 100644
--- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result
+++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result
@@ -2524,7 +2524,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE b IN (SELECT a AS a_inner FROM t1 GROUP BY a_inner);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 2 Using index; Using where
+2 DEPENDENT SUBQUERY t1 index_subquery a a 17 func 1 Using index; Using where
SET @@optimizer_switch=DEFAULT;
DROP TABLE t1;
#