1--TEST--
2pcntl_unshare() with CLONE_NEWNET
3--SKIPIF--
4<?php
5if (!extension_loaded("pcntl")) die("skip");
6if (!extension_loaded("posix")) die("skip posix extension not available");
7if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available");
8if (!defined("CLONE_NEWNET")) die("skip flag unavailable");
9if (posix_getuid() !== 0 &&
10    (!defined("CLONE_NEWUSER") ||
11    (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) {
12    die("skip Insufficient previleges to run test");
13}
14if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
15
16--FILE--
17<?php
18
19if(posix_getuid() !== 0) {
20    pcntl_unshare(CLONE_NEWUSER);
21}
22
23var_dump(gethostbyname('php.net'));
24pcntl_unshare(CLONE_NEWNET);
25var_dump(gethostbyname('php.net'));
26--EXPECTF--
27string(%d) %s
28string(7) "php.net"
29