1--TEST-- 2pcntl_unshare() with CLONE_NEWPID 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_NEWPID")) die("skip flag unavailable"); 9if (getenv("SKIP_ASAN")) die("skip asan chokes on this"); 10if (posix_getuid() !== 0 && 11 (!defined("CLONE_NEWUSER") || 12 (@pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) { 13 die("skip Insufficient privileges for CLONE_NEWUSER"); 14} 15if (@pcntl_unshare(CLONE_NEWPID) == false && pcntl_get_last_error() == PCNTL_EPERM) { 16 die("skip Insufficient privileges for CLONE_NEWPID"); 17} 18?> 19--FILE-- 20<?php 21 22if(posix_getuid() !== 0) { 23 pcntl_unshare(CLONE_NEWUSER); 24} 25 26var_dump(getmypid()); 27pcntl_unshare(CLONE_NEWPID); 28if(!pcntl_fork()) { 29 var_dump(getmypid()); 30 exit(); 31} 32?> 33--EXPECTF-- 34int(%d) 35int(1) 36