1--TEST-- 2ensure an error is returned when mysqli.allow_local_infile is off 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8 9$link = mysqli_init(); 10if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { 11 die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error())); 12} 13 14require_once('local_infile_tools.inc'); 15if ($msg = check_local_infile_support($link, $engine)) 16 die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error)); 17 18?> 19--INI-- 20mysqli.allow_local_infile=0 21--FILE-- 22<?php 23 require_once("connect.inc"); 24 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 25 printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 26 } 27 if (!$link->query("DROP TABLE IF EXISTS test")) { 28 printf("[002] [%d] %s\n", $link->errno, $link->error); 29 } 30 if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { 31 printf("[003] [%d] %s\n", $link->errno, $link->error); 32 } 33 if (FALSE == file_put_contents('bug77956.data', "waa? meukee!")) 34 printf("[004] Failed to create CVS file\n"); 35 if (!$link->query("SELECT 1 FROM DUAL")) 36 printf("[005] [%d] %s\n", $link->errno, $link->error); 37 if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) { 38 printf("[006] [%d] %s\n", $link->errno, $link->error); 39 echo "done"; 40 } else { 41 echo "bug"; 42 } 43 $link->close(); 44?> 45--CLEAN-- 46<?php 47require_once('connect.inc'); 48if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 49 printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 50 $host, $user, $db, $port, $socket); 51} 52if (!$link->query('DROP TABLE IF EXISTS test')) { 53 printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 54} 55$link->close(); 56unlink('bug77956.data'); 57?> 58--EXPECT-- 59[006] [2000] LOAD DATA LOCAL INFILE is forbidden, check related settings like mysqli.allow_local_infile|mysqli.local_infile_directory or PDO::MYSQL_ATTR_LOCAL_INFILE|PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY 60done 61