From: Alexander Nozdrin Date: March 28 2008 6:46pm Subject: bk commit into 5.1 tree (anozdrin:1.2579) BUG#32748 List-Archive: http://lists.mysql.com/commits/44616 X-Bug: 32748 Message-Id: <20080328184622.A2DC41D5C89@quad.opbmk> Below is the list of changes that have just been committed into a local 5.1 repository of anozdrin. When anozdrin does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2008-03-28 21:46:18+03:00, anozdrin@stripped +3 -0 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. mysql-test/r/log_state.result@stripped, 2008-03-28 21:46:17+03:00, anozdrin@stripped +21 -0 Update result file. mysql-test/t/log_state.test@stripped, 2008-03-28 21:46:17+03:00, anozdrin@stripped +28 -0 A test case for Bug#32748: Inconsistent handling of assignments to general_log_file/slow_query_log_file. sql/set_var.cc@stripped, 2008-03-28 21:46:17+03:00, anozdrin@stripped +32 -13 Accept file path if dirname is empty. Reject file path if it is empty. diff -Nrup a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result --- a/mysql-test/r/log_state.result 2007-12-05 22:33:34 +03:00 +++ b/mysql-test/r/log_state.result 2008-03-28 21:46:17 +03:00 @@ -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' set global general_log_file= @old_general_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 diff -Nrup a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test --- a/mysql-test/t/log_state.test 2007-12-05 22:11:57 +03:00 +++ b/mysql-test/t/log_state.test 2008-03-28 21:46:17 +03:00 @@ -231,6 +231,34 @@ set global slow_query_log_file= NULL; set global general_log_file= @old_general_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 --enable_ps_protocol diff -Nrup a/sql/set_var.cc b/sql/set_var.cc --- a/sql/set_var.cc 2008-03-28 18:10:02 +03:00 +++ b/sql/set_var.cc 2008-03-28 21:46:17 +03:00 @@ -2399,32 +2399,51 @@ static int sys_check_log_path(THD *thd, MY_STAT f_stat; String str(buff, sizeof(buff), system_charset_info), *res; const char *log_file_str; - + size_t path_length; + if (!(res= var->value->val_str(&str))) goto err; log_file_str= res->c_ptr(); bzero(&f_stat, sizeof(MY_STAT)); - (void) unpack_filename(path, log_file_str); - if (my_stat(path, &f_stat, MYF(0))) + path_length= unpack_filename(path, log_file_str); + + if (!path_length) { - /* Check if argument is a file and we have 'write' permission */ - if (!MY_S_ISREG(f_stat.st_mode) || - !(f_stat.st_mode & MY_S_IWRITE)) - goto err; + /* File name is empty. */ + + goto err; } - else + + if (my_stat(path, &f_stat, MYF(0))) { - size_t path_length; /* - Check if directory exists and - we have permission to create file & write to file + A file system object exists. Check if argument is a file and we have + 'write' permission. */ - (void) dirname_part(path, log_file_str, &path_length); - if (my_access(path, (F_OK|W_OK))) + + if (!MY_S_ISREG(f_stat.st_mode) || + !(f_stat.st_mode & MY_S_IWRITE)) goto err; + + return 0; } + + /* Get dirname of the file path. */ + (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 we have permission to create file and + write to file. + */ + if (my_access(path, (F_OK|W_OK))) + goto err; + return 0; err: