Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors When using "INSTALL PLUGIN" #171

Closed
RingsC opened this issue Jul 28, 2017 · 9 comments
Closed

Errors When using "INSTALL PLUGIN" #171

RingsC opened this issue Jul 28, 2017 · 9 comments

Comments

@RingsC
Copy link

RingsC commented Jul 28, 2017

Hi,
There is maybe a error. The problem describe as following:
Going into the mysqld directory and starts mysql serverice by running"./mysqld". after service startup completely.
I use sql command to install the plugin, such as "INSTALL PLUGIN AUDIT SONAME "libaudit_plugin.so" ", the plugin will be installed successfully, but we also get the errors "ERROR 29 (HY000): File './mysqld' not found (Errcode: 2 - No such file or directory)". Although, an error message comes out, but the plugin are installed truly. "show variables likes "%audit%"" does work.

I try figure out what's going on. and i found that in function,"". calc_file_md5, it can not open the file "./mysqld"
because that the current directory has been changed to data directory but the place where the mysqld placed in. So in calc_file_md5 function, can not open "./mysqld" and error comes out.
When we use my.cnf to startup the service, the input params of calc_file_md5 is a full path, such as "/xxx/xx/xxx/mysqld", so that open function can find mysqld.

the call stack as following:
#0 Diagnostics_area::set_error_status (this=0x7f9398003b58, mysql_errno=29,
message_text=0x7f93a5520d60 "File './mysqld' not found (Errcode: 2 - No such file or directory)", returned_sqlstate=0x2058909 "HY000")
at /home/homli/work/MySQL-Audit/sql/sql_error.cc:438
#1 0x000000000150a4b0 in THD::raise_condition (this=0x7f9398000df0, sql_errno=29, sqlstate=0x2058909 "HY000", level=Sql_condition::SL_ERROR,
msg=0x7f93a5520d60 "File './mysqld' not found (Errcode: 2 - No such file or directory)", use_condition_handler=false)
at /home/homli/work/MySQL-Audit/sql/sql_class.cc:1444
#2 0x0000000000ea8776 in my_message_sql (error=29, str=0x7f93a5520d60 "File './mysqld' not found (Errcode: 2 - No such file or directory)", MyFlags=0)
at /home/homli/work/MySQL-Audit/sql/mysqld.cc:2255
#3 0x00000000018b13f1 in my_error (nr=29, MyFlags=0) at /home/homli/work/MySQL-Audit/mysys/my_error.c:210
#4 0x00000000018b5e58 in my_register_filename (fd=-1, FileName=0x7ffcdd97851c "./mysqld", type_of_file=FILE_BY_OPEN, error_message_number=29, MyFlags=16)
at /home/homli/work/MySQL-Audit/mysys/my_open.c:167
#5 0x00000000018b5898 in my_open (FileName=0x7ffcdd97851c "./mysqld", Flags=0, MyFlags=16) at /home/homli/work/MySQL-Audit/mysys/my_open.c:52
#6 0x00007f939c0166d4 in calc_file_md5 (file_name=0x7ffcdd97851c "./mysqld", digest_str=0x7f93a55254f0 "") at audit_plugin.cc:1280
#7 0x00007f939c0168e1 in setup_offsets () at audit_plugin.cc:1341
#8 0x00007f939c01a95b in audit_plugin_init (p=0x7f93980b9a30) at audit_plugin.cc:2019
#9 0x0000000000ebf2d3 in initialize_audit_plugin (plugin=0x7f93980b9a30) at /home/homli/work/MySQL-Audit/sql/sql_audit.cc:1270
#10 0x000000000159e84c in plugin_initialize (plugin=0x7f93980b9a30) at /home/homli/work/MySQL-Audit/sql/sql_plugin.cc:1197
#11 0x00000000015a0b65 in mysql_install_plugin (thd=0x7f9398000df0, name=0x7f9398006220, dl=0x7f9398006230) at /home/homli/work/MySQL-Audit/sql/sql_plugin.cc:2044
#12 0x00000000015a674d in Sql_cmd_install_plugin::execute (this=0x7f9398006218, thd=0x7f9398000df0) at /home/homli/work/MySQL-Audit/sql/sql_plugin.cc:4254
#13 0x0000000001576178 in mysql_execute_command (thd=0x7f9398000df0, first_level=true) at /home/homli/work/MySQL-Audit/sql/sql_parse.cc:4894
#14 0x0000000001578101 in mysql_parse (thd=0x7f9398000df0, parser_state=0x7f93a5527610) at /home/homli/work/MySQL-Audit/sql/sql_parse.cc:5612

@RingsC RingsC changed the title Errors When using "INSTALL PLUG" Errors When using "INSTALL PLUGIN" Jul 28, 2017
@RingsC
Copy link
Author

RingsC commented Jul 28, 2017

BTW: mysql version: 5.7.18-debug, and my.cnf as following:
[mysqld]
basedir=/home/homli/work/MySQL-Audit/bin
datadir=/home/homli/work/MySQL-Audit/bin/data
plugin-dir=/home/homli/work/MySQL-Audit/bin/lib/plugin/
user=root
port=3306
max_connections=4000
log-error=/home/homli/work/MySQL-Audit/bin/data/homli.qiyi.com.err
pid-file=/home/homli/work/MySQL-Audit/bin/data/homli.qiyi.com.pid

@aharonrobbins
Copy link

Thanks for the note. We will investigate possible solutions for this.

@aharonrobbins
Copy link

Hi. If I upload a patch here, can you apply it, build the plugin, and test that it works for you? I have a thought as to how to address the issue. Thanks.

@RingsC
Copy link
Author

RingsC commented Jul 31, 2017

Yes, I will do that.

@aharonrobbins
Copy link

Here is the diff. Please let me know how it goes. I'll be unavailable tomorrow but will check the following day.

Thanks!

proc-open-diff.txt

@RingsC
Copy link
Author

RingsC commented Aug 1, 2017

I have verified this path and it works on *nix platform, but how about the windows platform? and it seems that the input para of calc_file_md5 is unnecessary.

The debug info as following:
Breakpoint 1, calc_file_md5 (file_name=0x7ffdf4e78515 "./mysqld", digest_str=0x7fcf413084f0 "") at audit_plugin.cc:1277
1277 unsigned char digest[16] = {0};
(gdb) n
1278 bool ret = false;
(gdb)
1281 sprintf(pidFilename, "/proc/%d/exe", getpid());
(gdb)
1282 if ((fd = my_open(pidFilename, O_RDONLY, MYF(MY_WME))) < 0)
(gdb) p pidFilename
$1 = "/proc/24873/exe\000@\314\311\002\000\000\000\000fa\000\000\000\000\000\000\325\031\033\060\317\177\000\000\200\363\321\002\000\000\000\000\060\200\060A\317\177\000\000X\255\337\001\000\000\000\000\000\t\000L\317\177\000\000\000\t\000L\317\177\000\000\200\200\060A\317\177\000\000\263\325\337\001\000\000\000\000p\205\060A".

@aharonrobbins
Copy link

Thanks for checking. I will consider just using the file in /proc instead of the input parameter. Checking it first allows us to print a message.

You ask about Windows. The plugin isn't supported on Windows; we only support Linux.

Thanks.

@RingsC
Copy link
Author

RingsC commented Aug 3, 2017

Okay, Thanks.

@RingsC RingsC closed this as completed Aug 3, 2017
@aharonrobbins
Copy link

The fix for this issue is now pushed to Github and binaries (dev-snapshot) have been uploaded to bintray.com. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants