List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:February 5 2009 9:01pm
Subject:bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)
Bug#38174
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38174/mysql-5.1-bugteam/ based on revid:matthias.leich@stripped

 2768 Alfranio Correia	2009-02-05
      BUG#38174 secure-file-priv breaks LOAD DATA INFILE replication in statement mode
      
      If secure-file-priv was set on slave, it became unable to execute
      LOAD DATA INFILE statements sent from master using mixed or
      statement-based replication.
      
      This patch fixes the issue by ignoring this security restriction
      while executing the SQL Thread.
added:
  mysql-test/suite/bugs/r/rpl_bug38174.result
  mysql-test/suite/bugs/t/rpl_bug38174-slave.opt
  mysql-test/suite/bugs/t/rpl_bug38174.test
modified:
  sql/sql_load.cc

=== added file 'mysql-test/suite/bugs/r/rpl_bug38174.result'
--- a/mysql-test/suite/bugs/r/rpl_bug38174.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug38174.result	2009-02-05 21:01:40 +0000
@@ -0,0 +1,84 @@
+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;
+drop table if exists t1;
+stop slave;
+CREATE TABLE t1 (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`int_key` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+`datetime_key` datetime NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(1) NOT NULL,
+`varchar_nokey` varchar(1) NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `int_key` (`int_key`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`),
+KEY `varchar_key` (`varchar_key`)
+);
+INSERT INTO t1 VALUES (1,8,5,'0000-00-00','0000-00-00','10:37:38','10:37:38','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),
+(2,1,6,'2005-12-23','2005-12-23','02:24:28','02:24:28','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),
+(3,0,3,'2009-09-14','2009-09-14','00:00:00','00:00:00','2000-01-30 16:39:40','2000-01-30 16:39:40','q','q'),
+(4,1,4,'2002-12-03','2002-12-03','20:34:58','20:34:58','2009-10-28 09:46:21','2009-10-28 09:46:21','g','g'),
+(5,1,6,'2007-03-29','2007-03-29','15:49:00','15:49:00','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
+(6,4,0,'2002-12-04','2002-12-04','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
+(7,9,0,'2005-01-28','2005-01-28','00:00:00','00:00:00','2001-05-18 00:00:00','2001-05-18 00:00:00','w','w'),
+(8,6,0,'0000-00-00','0000-00-00','06:57:25','06:57:25','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
+(9,0,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','z','z'),
+(10,4,6,'2006-08-15','2006-08-15','00:00:00','00:00:00','2002-04-12 14:44:25','2002-04-12 14:44:25','j','j'),
+(11,0,5,'2006-12-20','2006-12-20','10:13:53','10:13:53','2008-07-22 00:00:00','2008-07-22 00:00:00','y','y'),
+(12,9,7,'0000-00-00','0000-00-00','00:00:00','00:00:00','2004-07-05 00:00:00','2004-07-05 00:00:00','{','{'),
+(13,4,3,'2007-01-26','2007-01-26','23:00:51','23:00:51','2001-05-16 00:00:00','2001-05-16 00:00:00','f','f'),
+(14,7,0,'2004-03-27','2004-03-27','00:00:00','00:00:00','2005-01-24 03:30:37','2005-01-24 03:30:37','',''),
+(15,6,0,'2006-07-26','2006-07-26','18:43:57','18:43:57','0000-00-00 00:00:00','0000-00-00 00:00:00','{','{'),
+(16,0,6,'2000-01-14','2000-01-14','00:00:00','00:00:00','2000-09-21 00:00:00','2000-09-21 00:00:00','o','o'),
+(17,9,8,'0000-00-00','0000-00-00','21:15:08','21:15:08','0000-00-00 00:00:00','0000-00-00 00:00:00','a','a'),
+(18,2,0,'2004-10-27','2004-10-27','00:00:00','00:00:00','2004-03-24 22:13:43','2004-03-24 22:13:43','',''),
+(19,7,4,'0000-00-00','0000-00-00','08:38:27','08:38:27','2002-03-18 19:51:44','2002-03-18 19:51:44','t','t'),
+(20,5,3,'2008-03-07','2008-03-07','03:29:07','03:29:07','2007-12-01 18:44:44','2007-12-01 18:44:44','t','t'),
+(77,6,0,'2009-05-19','2009-05-19','14:56:44','14:56:44','2007-09-09 22:47:39','2007-09-09 22:47:39','',''),
+(35,6,3,'0000-00-00','0000-00-00','09:38:22','09:38:22','0000-00-00 00:00:00','0000-00-00 00:00:00','i','i'),
+(39,8,8,'0000-00-00','0000-00-00','10:25:31','10:25:31','2003-01-24 10:45:23','2003-01-24 10:45:23','',''),
+(29,5,6,'0000-00-00','0000-00-00','00:21:35','00:21:35','0000-00-00 00:00:00','0000-00-00 00:00:00','y','y'),
+(53,3,5,'0000-00-00','0000-00-00','00:00:00','00:00:00','2007-11-05 23:51:21','2007-11-05 23:51:21','p','p'),
+(60,0,2,'2009-09-11','2009-09-11','23:56:26','23:56:26','2003-12-24 04:28:32','2003-12-24 04:28:32','n','n'),
+(93,7,2,'2007-08-18','2007-08-18','00:00:00','00:00:00','2009-02-01 00:00:00','2009-02-01 00:00:00','y','y');
+SELECT * FROM t1 ORDER BY RAND () INTO OUTFILE "/home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38174/mysql-5.1-bugteam/mysql-test/var/tmp/bug38174-1.test";
+drop table if exists t1;
+start slave;
+CREATE TABLE t1 (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`int_key` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+`datetime_key` datetime NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(1) NOT NULL,
+`varchar_nokey` varchar(1) NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `int_key` (`int_key`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`),
+KEY `varchar_key` (`varchar_key`)
+);
+LOAD DATA INFILE "/home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38174/mysql-5.1-bugteam/mysql-test/var/tmp/bug38174-1.test" REPLACE INTO TABLE t1;
+select count(*) from t1;
+count(*)
+27
+select count(*) from t1;
+count(*)
+27
+drop table t1;

=== added file 'mysql-test/suite/bugs/t/rpl_bug38174-slave.opt'
--- a/mysql-test/suite/bugs/t/rpl_bug38174-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug38174-slave.opt	2009-02-05 21:01:40 +0000
@@ -0,0 +1,2 @@
+--secure-file-priv=/tmp
+

=== added file 'mysql-test/suite/bugs/t/rpl_bug38174.test'
--- a/mysql-test/suite/bugs/t/rpl_bug38174.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug38174.test	2009-02-05 21:01:40 +0000
@@ -0,0 +1,129 @@
+# This test verifies if it is possible to execute LOAD DATA INFILE 
+# in while using the secure-file-priv option on slave.
+# 
+# The test is divide in three steps:
+#    1 - Stops replication and then creates a file in the master from which 
+#    a table should be populate.
+#    2 - Starts replication, creates a table and populates it through
+#    "LOAD DATA INFILE".
+#    3 - Compares the master and slave.
+#
+source include/master-slave.inc;
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+##########################################################################
+
+connection slave;
+
+stop slave;
+source include/wait_for_slave_to_stop.inc;
+
+connection master;
+
+
+CREATE TABLE t1 (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `int_nokey` int(11) NOT NULL,
+  `int_key` int(11) NOT NULL,
+  `date_key` date NOT NULL,
+  `date_nokey` date NOT NULL,
+  `time_key` time NOT NULL,
+  `time_nokey` time NOT NULL,
+  `datetime_key` datetime NOT NULL,
+  `datetime_nokey` datetime NOT NULL,
+  `varchar_key` varchar(1) NOT NULL,
+  `varchar_nokey` varchar(1) NOT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `int_key` (`int_key`),
+  KEY `date_key` (`date_key`),
+  KEY `time_key` (`time_key`),
+  KEY `datetime_key` (`datetime_key`),
+  KEY `varchar_key` (`varchar_key`)
+);
+
+INSERT INTO t1 VALUES (1,8,5,'0000-00-00','0000-00-00','10:37:38','10:37:38','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'),
+(2,1,6,'2005-12-23','2005-12-23','02:24:28','02:24:28','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'),
+(3,0,3,'2009-09-14','2009-09-14','00:00:00','00:00:00','2000-01-30 16:39:40','2000-01-30 16:39:40','q','q'),
+(4,1,4,'2002-12-03','2002-12-03','20:34:58','20:34:58','2009-10-28 09:46:21','2009-10-28 09:46:21','g','g'),
+(5,1,6,'2007-03-29','2007-03-29','15:49:00','15:49:00','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
+(6,4,0,'2002-12-04','2002-12-04','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'),
+(7,9,0,'2005-01-28','2005-01-28','00:00:00','00:00:00','2001-05-18 00:00:00','2001-05-18 00:00:00','w','w'),
+(8,6,0,'0000-00-00','0000-00-00','06:57:25','06:57:25','0000-00-00 00:00:00','0000-00-00 00:00:00','m','m'),
+(9,0,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','z','z'),
+(10,4,6,'2006-08-15','2006-08-15','00:00:00','00:00:00','2002-04-12 14:44:25','2002-04-12 14:44:25','j','j'),
+(11,0,5,'2006-12-20','2006-12-20','10:13:53','10:13:53','2008-07-22 00:00:00','2008-07-22 00:00:00','y','y'),
+(12,9,7,'0000-00-00','0000-00-00','00:00:00','00:00:00','2004-07-05 00:00:00','2004-07-05 00:00:00','{','{'),
+(13,4,3,'2007-01-26','2007-01-26','23:00:51','23:00:51','2001-05-16 00:00:00','2001-05-16 00:00:00','f','f'),
+(14,7,0,'2004-03-27','2004-03-27','00:00:00','00:00:00','2005-01-24 03:30:37','2005-01-24 03:30:37','',''),
+(15,6,0,'2006-07-26','2006-07-26','18:43:57','18:43:57','0000-00-00 00:00:00','0000-00-00 00:00:00','{','{'),
+(16,0,6,'2000-01-14','2000-01-14','00:00:00','00:00:00','2000-09-21 00:00:00','2000-09-21 00:00:00','o','o'),
+(17,9,8,'0000-00-00','0000-00-00','21:15:08','21:15:08','0000-00-00 00:00:00','0000-00-00 00:00:00','a','a'),
+(18,2,0,'2004-10-27','2004-10-27','00:00:00','00:00:00','2004-03-24 22:13:43','2004-03-24 22:13:43','',''),
+(19,7,4,'0000-00-00','0000-00-00','08:38:27','08:38:27','2002-03-18 19:51:44','2002-03-18 19:51:44','t','t'),
+(20,5,3,'2008-03-07','2008-03-07','03:29:07','03:29:07','2007-12-01 18:44:44','2007-12-01 18:44:44','t','t'),
+(77,6,0,'2009-05-19','2009-05-19','14:56:44','14:56:44','2007-09-09 22:47:39','2007-09-09 22:47:39','',''),
+(35,6,3,'0000-00-00','0000-00-00','09:38:22','09:38:22','0000-00-00 00:00:00','0000-00-00 00:00:00','i','i'),
+(39,8,8,'0000-00-00','0000-00-00','10:25:31','10:25:31','2003-01-24 10:45:23','2003-01-24 10:45:23','',''),
+(29,5,6,'0000-00-00','0000-00-00','00:21:35','00:21:35','0000-00-00 00:00:00','0000-00-00 00:00:00','y','y'),
+(53,3,5,'0000-00-00','0000-00-00','00:00:00','00:00:00','2007-11-05 23:51:21','2007-11-05 23:51:21','p','p'),
+(60,0,2,'2009-09-11','2009-09-11','23:56:26','23:56:26','2003-12-24 04:28:32','2003-12-24 04:28:32','n','n'),
+(93,7,2,'2007-08-18','2007-08-18','00:00:00','00:00:00','2009-02-01 00:00:00','2009-02-01 00:00:00','y','y');
+
+--eval SELECT * FROM t1 ORDER BY RAND () INTO OUTFILE "$MYSQL_TEST_DIR/var/tmp/bug38174-1.test"
+
+drop table if exists t1;
+
+##########################################################################
+
+connection slave;
+
+start slave;
+source include/wait_for_slave_to_start.inc;
+
+connection master;
+
+CREATE TABLE t1 (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `int_nokey` int(11) NOT NULL,
+  `int_key` int(11) NOT NULL,
+  `date_key` date NOT NULL,
+  `date_nokey` date NOT NULL,
+  `time_key` time NOT NULL,
+  `time_nokey` time NOT NULL,
+  `datetime_key` datetime NOT NULL,
+  `datetime_nokey` datetime NOT NULL,
+  `varchar_key` varchar(1) NOT NULL,
+  `varchar_nokey` varchar(1) NOT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `int_key` (`int_key`),
+  KEY `date_key` (`date_key`),
+  KEY `time_key` (`time_key`),
+  KEY `datetime_key` (`datetime_key`),
+  KEY `varchar_key` (`varchar_key`)
+);
+
+--eval LOAD DATA INFILE "$MYSQL_TEST_DIR/var/tmp/bug38174-1.test" REPLACE INTO TABLE t1
+
+##########################################################################
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+connection master;
+select count(*) from t1;
+connection slave;
+select count(*) from t1;
+
+connection master;
+--remove_file $MYSQL_TEST_DIR/var/tmp/bug38174-1.test
+
+drop table t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2008-09-17 12:54:50 +0000
+++ b/sql/sql_load.cc	2009-02-05 21:01:40 +0000
@@ -310,7 +310,7 @@ int mysql_load(THD *thd,sql_exchange *ex
 	is_fifo = 1;
 #endif
 
-      if (opt_secure_file_priv &&
+      if (!thd->slave_thread && 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 */

Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)Bug#38174Alfranio Correia5 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch(alfranio.correia:2768) Bug#38174Sergei Golubchik5 Feb
    • Re: bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)Bug#38174Alfranio Correia6 Feb
      • Re: bzr commit into mysql-5.1-bugteam branch(alfranio.correia:2768) Bug#38174Sergei Golubchik6 Feb