1--TEST-- 2Bug #68077 (LOAD DATA LOCAL INFILE / open_basedir restriction) 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7if (!$IS_MYSQLND) { 8 die("skip: test applies only to mysqlnd"); 9} 10if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 11 die("skip Cannot connect to MySQL"); 12 13include_once("local_infile_tools.inc"); 14if ($msg = check_local_infile_support($link, $engine)) 15 die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error)); 16 17mysqli_close($link); 18?> 19--INI-- 20mysqli.allow_local_infile=1 21mysqli.allow_persistent=1 22mysqli.max_persistent=1 23open_basedir= 24--FILE-- 25<?php 26 require_once("connect.inc"); 27 28 ini_set("open_basedir", __DIR__); 29 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 30 printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 31 } 32 33 if (!$link->query("DROP TABLE IF EXISTS test")) { 34 printf("[002] [%d] %s\n", $link->errno, $link->error); 35 } 36 37 if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { 38 printf("[003] [%d] %s\n", $link->errno, $link->error); 39 } 40 41 if (FALSE == file_put_contents(__DIR__ . '/bug53503.data', "1\n2\n3\n")) 42 printf("[004] Failed to create CVS file\n"); 43 44 if (!$link->query("SELECT 1 FROM DUAL")) 45 printf("[005] [%d] %s\n", $link->errno, $link->error); 46 47 if (!$link->query("LOAD DATA LOCAL INFILE '" . str_replace("\\", "/", __DIR__) . "/bug53503.data' INTO TABLE test")) { 48 printf("[006] [%d] %s\n", $link->errno, $link->error); 49 echo "bug\n"; 50 } else { 51 echo "done\n"; 52 } 53 54 ini_set("open_basedir", __DIR__ . "/dummy"); 55 if (!$link->query("LOAD DATA LOCAL INFILE '" . __DIR__ . "/bug53503.data' INTO TABLE test")) { 56 printf("[006] [%d] %s\n", $link->errno, $link->error); 57 echo "done\n"; 58 } else { 59 echo "bug\n"; 60 } 61 $link->close(); 62?> 63--CLEAN-- 64<?php 65require_once('connect.inc'); 66 67if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 68 printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 69 $host, $user, $db, $port, $socket); 70} 71 72if (!$link->query($link, 'DROP TABLE IF EXISTS test')) { 73 printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 74} 75 76$link->close(); 77 78unlink('bug53503.data'); 79?> 80--EXPECT-- 81done 82[006] [2000] open_basedir restriction in effect. Unable to open file 83done 84