Fix for Bug#32748: Inconsistent handling of assignments to

general_log_file/slow_query_log_file.

The problem was that log file path was rejected if directory
path was empty. The fix is to reject log file path only if it
is entirely empty.
parent d02459cb
...@@ -249,4 +249,25 @@ set global slow_query_log_file= NULL; ...@@ -249,4 +249,25 @@ set global slow_query_log_file= NULL;
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL' ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL'
set global general_log_file= @old_general_log_file; set global general_log_file= @old_general_log_file;
set global slow_query_log_file= @old_slow_query_log_file; set global slow_query_log_file= @old_slow_query_log_file;
# --
# -- Bug#32748: Inconsistent handling of assignments to
# -- general_log_file/slow_query_log_file.
# --
SET @general_log_file_saved = @@global.general_log_file;
SET @slow_query_log_file_saved = @@global.slow_query_log_file;
SET GLOBAL general_log_file = 'bug32748.query.log';
SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
SHOW VARIABLES LIKE '%log_file';
Variable_name Value
general_log_file bug32748.query.log
slow_query_log_file bug32748.slow.log
SET GLOBAL general_log_file = @general_log_file_saved;
SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;
# -- End of Bug#32748.
End of 5.1 tests End of 5.1 tests
...@@ -231,6 +231,34 @@ set global slow_query_log_file= NULL; ...@@ -231,6 +231,34 @@ set global slow_query_log_file= NULL;
set global general_log_file= @old_general_log_file; set global general_log_file= @old_general_log_file;
set global slow_query_log_file= @old_slow_query_log_file; set global slow_query_log_file= @old_slow_query_log_file;
###########################################################################
--echo
--echo # --
--echo # -- Bug#32748: Inconsistent handling of assignments to
--echo # -- general_log_file/slow_query_log_file.
--echo # --
--echo
SET @general_log_file_saved = @@global.general_log_file;
SET @slow_query_log_file_saved = @@global.slow_query_log_file;
--echo
SET GLOBAL general_log_file = 'bug32748.query.log';
SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
--echo
SHOW VARIABLES LIKE '%log_file';
--echo
SET GLOBAL general_log_file = @general_log_file_saved;
SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;
--echo
--echo # -- End of Bug#32748.
###########################################################################
--echo End of 5.1 tests --echo End of 5.1 tests
--enable_ps_protocol --enable_ps_protocol
......
...@@ -2399,6 +2399,7 @@ static int sys_check_log_path(THD *thd, set_var *var) ...@@ -2399,6 +2399,7 @@ static int sys_check_log_path(THD *thd, set_var *var)
MY_STAT f_stat; MY_STAT f_stat;
String str(buff, sizeof(buff), system_charset_info), *res; String str(buff, sizeof(buff), system_charset_info), *res;
const char *log_file_str; const char *log_file_str;
size_t path_length;
if (!(res= var->value->val_str(&str))) if (!(res= var->value->val_str(&str)))
goto err; goto err;
...@@ -2406,25 +2407,43 @@ static int sys_check_log_path(THD *thd, set_var *var) ...@@ -2406,25 +2407,43 @@ static int sys_check_log_path(THD *thd, set_var *var)
log_file_str= res->c_ptr(); log_file_str= res->c_ptr();
bzero(&f_stat, sizeof(MY_STAT)); bzero(&f_stat, sizeof(MY_STAT));
(void) unpack_filename(path, log_file_str); path_length= unpack_filename(path, log_file_str);
if (!path_length)
{
/* File name is empty. */
goto err;
}
if (my_stat(path, &f_stat, MYF(0))) if (my_stat(path, &f_stat, MYF(0)))
{ {
/* Check if argument is a file and we have 'write' permission */ /*
A file system object exists. Check if argument is a file and we have
'write' permission.
*/
if (!MY_S_ISREG(f_stat.st_mode) || if (!MY_S_ISREG(f_stat.st_mode) ||
!(f_stat.st_mode & MY_S_IWRITE)) !(f_stat.st_mode & MY_S_IWRITE))
goto err; goto err;
return 0;
} }
else
{ /* Get dirname of the file path. */
size_t path_length; (void) dirname_part(path, log_file_str, &path_length);
/* Dirname is empty if file path is relative. */
if (!path_length)
return 0;
/* /*
Check if directory exists and Check if directory exists and we have permission to create file and
we have permission to create file & write to file write to file.
*/ */
(void) dirname_part(path, log_file_str, &path_length);
if (my_access(path, (F_OK|W_OK))) if (my_access(path, (F_OK|W_OK)))
goto err; goto err;
}
return 0; return 0;
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment