summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <gluh@eagle.(none)>2008-02-29 14:05:38 +0400
committerunknown <gluh@eagle.(none)>2008-02-29 14:05:38 +0400
commit8bdb243fd7a9ef7dee3eeafdc1dd7050e816cbeb (patch)
treedab52058ac84180fe00c686fe1fd5406f707b803 /sql/sql_parse.cc
parent7f572871ad24e293f60fde3c4ee597de7a581516 (diff)
parentab6042590186ad14bbd73a64f5d1f3f77223bdb3 (diff)
downloadmariadb-git-8bdb243fd7a9ef7dee3eeafdc1dd7050e816cbeb.tar.gz
Merge mysql.com:/home/gluh/MySQL/Merge/4.1-opt
into mysql.com:/home/gluh/MySQL/Merge/5.0-opt sql/mysql_priv.h: Auto merged mysql-test/r/symlink.result: manual merge mysql-test/t/symlink.test: manual merge sql/mysqld.cc: manual merge sql/sql_parse.cc: manual merge
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 45dac4d5127..9e2a4bb77ac 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -76,6 +76,9 @@ static void remove_escape(char *name);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name);
static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
+static TABLE_LIST* get_table_by_alias(TABLE_LIST* tl, const char* db,
+ const char* alias);
+static bool test_if_data_home_dir(const char *dir);
const char *any_db="*any*"; // Special symbol for check_access
@@ -3055,6 +3058,20 @@ mysql_execute_command(THD *thd)
"INDEX DIRECTORY option ignored");
create_info.data_file_name= create_info.index_file_name= NULL;
#else
+
+ if (test_if_data_home_dir(lex->create_info.data_file_name))
+ {
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"DATA DIRECORY");
+ res= -1;
+ break;
+ }
+ if (test_if_data_home_dir(lex->create_info.index_file_name))
+ {
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"INDEX DIRECORY");
+ res= -1;
+ break;
+ }
+
/* Fix names if symlinked tables */
if (append_file_to_dir(thd, &create_info.data_file_name,
create_table->table_name) ||
@@ -7898,3 +7915,48 @@ bool check_string_length(LEX_STRING *str, const char *err_msg,
return TRUE;
}
+
+
+/*
+ Check if path does not contain mysql data home directory
+
+ SYNOPSIS
+ test_if_data_home_dir()
+ dir directory
+ conv_home_dir converted data home directory
+ home_dir_len converted data home directory length
+
+ RETURN VALUES
+ 0 ok
+ 1 error
+*/
+
+static bool test_if_data_home_dir(const char *dir)
+{
+ char path[FN_REFLEN], conv_path[FN_REFLEN];
+ uint dir_len, home_dir_len= strlen(mysql_unpacked_real_data_home);
+ DBUG_ENTER("test_if_data_home_dir");
+
+ if (!dir)
+ DBUG_RETURN(0);
+
+ (void) fn_format(path, dir, "", "",
+ (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
+ dir_len= unpack_dirname(conv_path, dir);
+
+ if (home_dir_len <= dir_len)
+ {
+ if (lower_case_file_system)
+ {
+ if (!my_strnncoll(default_charset_info, (const uchar*) conv_path,
+ home_dir_len,
+ (const uchar*) mysql_unpacked_real_data_home,
+ home_dir_len))
+ DBUG_RETURN(1);
+ }
+ else if (!memcmp(conv_path, mysql_unpacked_real_data_home, home_dir_len))
+ DBUG_RETURN(1);
+ }
+ DBUG_RETURN(0);
+}
+