Protection for case where tcp port or unix socket is not set and plugin tries to set default socket name at startup. The tcp port or unix socket may not be set when they are not passed either on the command line or configured in my.cnf. In this case the plugin init function is called before mysql has set the default values for these.

pull/103/head v1.0.7
Guy Lichtman 2014-11-09 12:05:39 +02:00
parent c81adbd7ee
commit 60074c0518
2 changed files with 12 additions and 2 deletions

View File

@ -215,6 +215,16 @@ int Audit_file_handler::open(const char * io_dest, bool log_errors)
//no locks. called by handler_start and when it is time to retry
bool Audit_io_handler::handler_start_internal()
{
if(!m_io_dest || strlen(m_io_dest) == 0)
{
if(m_log_io_errors)
{
sql_print_error(
"%s %s: io destination not set. Not connecting.",
AUDIT_LOG_PREFIX, m_io_type);
}
return false;
}
if (open(m_io_dest, m_log_io_errors) != 0)
{
//open failed
@ -319,7 +329,7 @@ ssize_t Audit_socket_handler::write(const char * data, size_t size)
}
int Audit_socket_handler::open(const char * io_dest, bool log_errors)
{
{
//open the socket
int sock = socket(AF_UNIX,SOCK_STREAM,0);
if (sock < 0)

View File

@ -1223,7 +1223,7 @@ static void json_socket_name_update(THD *thd, struct st_mysql_sys_var *var, void
{
strncpy( json_socket_name_buff , str, buff_len);
}
if(strlen(json_socket_name_buff) == 0) //set default
if(strlen(json_socket_name_buff) == 0 && (mysqld_port > 0 || mysqld_unix_port)) //set default
{
const char * name_prefix = "/tmp/mysql.audit_";