1--TEST--
2chroot()
3--SKIPIF--
4<?php
5if (!function_exists("chroot")) {
6    die("skip chroot() not available");
7}
8// Skip if not being run by root (files are always readable, writeable and executable)
9$filename = @tempnam(__DIR__, 'root_check_');
10if (!file_exists($filename)) {
11    die('WARN Unable to create the "root check" file');
12}
13
14$isRoot = fileowner($filename) == 0;
15
16unlink($filename);
17
18if (!$isRoot) {
19    die('SKIP Must be run as root');
20}
21?>
22--FILE--
23<?php
24mkdir("chroot_001_x");
25var_dump(is_dir("chroot_001_x"));
26var_dump(chroot("chroot_001_x"));
27var_dump(is_dir("chroot_001_x"));
28var_dump(realpath("."));
29?>
30--CLEAN--
31<?php
32rmdir("chroot_001_x");
33?>
34--EXPECT--
35bool(true)
36bool(true)
37bool(false)
38string(1) "/"
39