1--TEST--
2mysqli.local_infile_directory vs open_basedir
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'connect.inc';
8
9if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
10    die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
11}
12
13include_once "local_infile_tools.inc";
14if ($msg = check_local_infile_allowed_by_server($link))
15    die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
16
17mysqli_close($link);
18?>
19--INI--
20open_basedir={PWD}
21mysqli.allow_local_infile=0
22mysqli.local_infile_directory={PWD}/../
23--FILE--
24<?php
25	require_once 'connect.inc';
26
27	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
28		printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
29	}
30
31	if (!$link->query("DROP TABLE IF EXISTS test")) {
32		printf("[002] [%d] %s\n", $link->errno, $link->error);
33	}
34
35	if (!$link->query("CREATE TABLE test (id INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
36		printf("[003] [%d] %s\n", $link->errno, $link->error);
37	}
38
39	$filepath = str_replace('\\', '/', __DIR__.'/foo/foo.data');
40	if (!$link->query("LOAD DATA LOCAL INFILE '".$filepath."' INTO TABLE test")) {
41		printf("[004] [%d] %s\n", $link->errno, $link->error);
42	} else {
43		printf("[005] bug! should not happen - operation not permitted expected\n");
44	}
45
46	echo "done";
47?>
48--CLEAN--
49<?php
50require_once 'connect.inc';
51
52if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
53	printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
54		$host, $user, $db, $port, $socket);
55}
56
57if (!$link->query('DROP TABLE IF EXISTS test')) {
58	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
59}
60
61$link->close();
62?>
63--EXPECTF--
64Warning: mysqli_connect(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
65[004] [2068] LOAD DATA LOCAL INFILE %s
66done
67