1--TEST--
2mysqli.local_infile_directory access denied
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}/foo/bar
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 - access denied expected\n");
44	}
45
46	$link->close();
47	echo "done";
48?>
49--CLEAN--
50<?php
51require_once 'connect.inc';
52
53if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
54	printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
55		$host, $user, $db, $port, $socket);
56}
57
58if (!$link->query('DROP TABLE IF EXISTS test')) {
59	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
60}
61
62$link->close();
63?>
64--EXPECTF--
65[004] [2068] LOAD DATA LOCAL INFILE %s
66done
67