Skip to content

Commit

Permalink
fix the encryption.filekeys_nofile test
Browse files Browse the repository at this point in the history
and move the error reporting where it belongs
  • Loading branch information
vuvova committed Oct 10, 2015
1 parent affff1a commit c4e336e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions mysql-test/suite/encryption/r/filekeys_nofile.result
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
call mtr.add_suppression("File '' not found");
call mtr.add_suppression("file-key-management-filename is not set");
call mtr.add_suppression("Plugin 'file_key_management' init function returned error");
call mtr.add_suppression("Plugin 'file_key_management' registration.*failed");
FOUND /File '' not found/ in mysqld.1.err
FOUND /file-key-management-filename is not set/ in mysqld.1.err
create table t1(c1 bigint not null, b char(200)) engine=innodb encrypted=yes encryption_key_id=1;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
select plugin_status from information_schema.plugins
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/encryption/t/filekeys_nofile.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
let SEARCH_PATTERN=File '' not found;
let SEARCH_PATTERN=file-key-management-filename is not set;
source filekeys_badtest.inc;
8 changes: 0 additions & 8 deletions plugin/file_key_management/file_key_management_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "parser.h"
#include <mysql/plugin_encryption.h>
#include <mysqld_error.h>
#include <string.h>

static char* filename;
Expand Down Expand Up @@ -166,13 +165,6 @@ struct st_mariadb_encryption file_key_management_plugin= {

static int file_key_management_plugin_init(void *p)
{
if (!filename || !filename[0])
{
my_printf_error(ER_CANT_INITIALIZE_UDF,
"file_key_management-filename is not set", MYF(0));
return 1;
}

Parser parser(filename, filekey);
return parser.parse(&keys);
}
Expand Down
12 changes: 10 additions & 2 deletions plugin/file_key_management/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,16 @@ int Parser::parse_line(char **line_ptr, keyentry *key)

char* Parser::read_and_decrypt_file(const char *secret)
{
int f= my_open(filename, O_RDONLY, MYF(MY_WME));
if (f < 0)
if (!filename || !filename[0])
{
my_printf_error(EE_CANT_OPEN_STREAM,
"file-key-management-filename is not set",
MYF(ME_NOREFRESH));
goto err0;
}

int f;
if ((f= my_open(filename, O_RDONLY, MYF(MY_WME))) < 0)
goto err0;

my_off_t file_size;
Expand Down

0 comments on commit c4e336e

Please sign in to comment.