List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:February 21 2009 10:29am
Subject:bzr commit into mysql-6.0-bugteam branch (alfranio.correia:3072)
Bug#38174
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38174/mysql-6.0-bugteam/ based on revid:mattias.jonsson@stripped

 3072 Alfranio Correia	2009-02-21 [merge]
      BUG#38174 merge 5.1-bugteam --> 6.0-bugteam
added:
  mysql-test/suite/rpl/r/rpl_slave_load_in.result
  mysql-test/suite/rpl/t/rpl_slave_load_in.test
modified:
  sql/log_event.cc
  sql/log_event.h
  sql/rpl_rli.cc
  sql/rpl_rli.h
  sql/sql_load.cc

=== added file 'mysql-test/suite/rpl/r/rpl_slave_load_in.result'
--- a/mysql-test/suite/rpl/r/rpl_slave_load_in.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_in.result	2009-02-21 09:36:07 +0000
@@ -0,0 +1,10 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1(a int not null auto_increment, b int, primary key(a));
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+Comparing tables master:test.t1 and slave:test.t1
+drop table t1;

=== added file 'mysql-test/suite/rpl/t/rpl_slave_load_in.test'
--- a/mysql-test/suite/rpl/t/rpl_slave_load_in.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_in.test	2009-02-21 09:36:07 +0000
@@ -0,0 +1,35 @@
+##########################################################################
+# This test verifies if a slave is able to process a "LOAD DATA INFILE" 
+# event while the "--secure-file-priv" option is set.
+# 
+# The test is divided in two steps:
+#    1 - Creates a table and populates it through "LOAD DATA INFILE".
+#    2 - Compares the master and slave.
+##########################################################################
+source include/master-slave.inc;
+
+##########################################################################
+#                            Loading data
+##########################################################################
+connection master;
+
+create table t1(a int not null auto_increment, b int, primary key(a));
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+
+##########################################################################
+#                       Checking Consistency
+##########################################################################
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+##########################################################################
+#                             Clean up
+##########################################################################
+connection master;
+
+drop table t1;
+
+sync_slave_with_master;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-02-16 21:18:45 +0000
+++ b/sql/log_event.cc	2009-02-21 10:29:05 +0000
@@ -355,7 +355,7 @@ static char *slave_load_file_stem(char *
                                   int event_server_id, const char *ext)
 {
   char *res;
-  fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
+  fn_format(buf,PREFIX_SQL_LOAD,slave_load_tmpdir, "", MY_UNPACK_FILENAME);
   to_unix_path(buf);
 
   buf = strend(buf);
@@ -394,7 +394,7 @@ static void cleanup_load_tmpdir()
      we cannot meet Start_log event in the middle of events from one 
      LOAD DATA.
   */
-  p= strmake(prefbuf, STRING_WITH_LEN("SQL_LOAD-"));
+  p= strmake(prefbuf, STRING_WITH_LEN(PREFIX_SQL_LOAD));
   p= int10_to_str(::server_id, p, 10);
   *(p++)= '-';
   *p= 0;

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2009-02-02 15:58:48 +0000
+++ b/sql/log_event.h	2009-02-21 10:29:05 +0000
@@ -47,6 +47,8 @@
 #include "rpl_reporting.h"
 #endif
 
+#define PREFIX_SQL_LOAD "SQL_LOAD-"
+
 /**
    Either assert or return an error.
 

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2009-02-13 16:30:54 +0000
+++ b/sql/rpl_rli.cc	2009-02-21 10:29:05 +0000
@@ -106,6 +106,12 @@ int init_relay_log_info(Relay_log_info* 
   rli->tables_to_lock= 0;
   rli->tables_to_lock_count= 0;
 
+  fn_format(rli->slave_patternload_file, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
+            MY_PACK_FILENAME | MY_UNPACK_FILENAME |
+            MY_RETURN_REAL_PATH);
+  to_unix_path(rli->slave_patternload_file);
+  rli->slave_patternload_file_size= strlen(rli->slave_patternload_file);
+
   /*
     The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE.
     Note that the I/O thread flushes it to disk after writing every

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2008-08-18 05:43:50 +0000
+++ b/sql/rpl_rli.h	2009-02-21 10:29:05 +0000
@@ -260,6 +260,13 @@ public:
   char ign_master_log_name_end[FN_REFLEN];
   ulonglong ign_master_log_pos_end;
 
+  /* 
+    Indentifies where the SQL Thread should create temporary files for the
+    LOAD DATA INFILE. This is used for security reasons.
+   */ 
+  char slave_patternload_file[FN_REFLEN]; 
+  size_t slave_patternload_file_size;  
+
   Relay_log_info();
   ~Relay_log_info();
 

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2008-12-24 10:48:24 +0000
+++ b/sql/sql_load.cc	2009-02-21 10:29:05 +0000
@@ -20,6 +20,7 @@
 #include "mysql_priv.h"
 #include <my_dir.h>
 #include <m_ctype.h>
+#include "rpl_mi.h"
 #include "sql_repl.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
@@ -324,8 +325,31 @@ int mysql_load(THD *thd,sql_exchange *ex
       (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
 		       MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
 
-      if (opt_secure_file_priv &&
-          strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
+      if (thd->slave_thread)
+      {
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+        if (strncmp(active_mi->rli.slave_patternload_file, name,
+            active_mi->rli.slave_patternload_file_size))
+        {
+          /*
+            LOAD DATA INFILE in the slave SQL Thread can only read from
+            --slave-load-tmpdir". This should never happen. Please, report a bug.
+           */
+
+          sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
+                          "Please, report a bug.");
+          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
+          DBUG_RETURN(TRUE);
+        }
+#else
+        /*
+          This is impossible and should never happen.
+        */
+        DBUG_ASSERT(FALSE);
+#endif
+      }
+      else if (opt_secure_file_priv &&
+               strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
       {
         /* Read only allowed from within dir specified by secure_file_priv */
         my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");

Thread
bzr commit into mysql-6.0-bugteam branch (alfranio.correia:3072)Bug#38174Alfranio Correia21 Feb