diff options
Diffstat (limited to 'ext/pcntl/tests')
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_01.phpt | 21 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_02.phpt | 30 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_03.phpt | 28 |
3 files changed, 79 insertions, 0 deletions
diff --git a/ext/pcntl/tests/pcntl_unshare_01.phpt b/ext/pcntl/tests/pcntl_unshare_01.phpt new file mode 100644 index 0000000000..d914723dc1 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_01.phpt @@ -0,0 +1,21 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWUSER +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWUSER")) die("skip flag unavailable"); +if (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM) { + die("skip Insufficient previleges to use CLONE_NEWUSER"); +} + +--FILE-- +<?php + +$olduid = posix_getuid(); +pcntl_unshare(CLONE_NEWUSER); +$newuid = posix_getuid(); +var_dump($olduid === $newuid); +--EXPECT-- +bool(false) diff --git a/ext/pcntl/tests/pcntl_unshare_02.phpt b/ext/pcntl/tests/pcntl_unshare_02.phpt new file mode 100644 index 0000000000..a046759730 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_02.phpt @@ -0,0 +1,30 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWPID +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWPID")) die("skip flag unavailable"); +if (posix_getuid() !== 0 && + (!defined("CLONE_NEWUSER") || + (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) { + die("skip Insufficient previleges to run test"); +} + +--FILE-- +<?php + +if(posix_getuid() !== 0) { + pcntl_unshare(CLONE_NEWUSER); +} + +var_dump(getmypid()); +pcntl_unshare(CLONE_NEWPID); +if(!pcntl_fork()) { + var_dump(getmypid()); + exit(); +} +--EXPECTF-- +int(%d) +int(1) diff --git a/ext/pcntl/tests/pcntl_unshare_03.phpt b/ext/pcntl/tests/pcntl_unshare_03.phpt new file mode 100644 index 0000000000..d69bd40d40 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_03.phpt @@ -0,0 +1,28 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWNET +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWNET")) die("skip flag unavailable"); +if (posix_getuid() !== 0 && + (!defined("CLONE_NEWUSER") || + (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) { + die("skip Insufficient previleges to run test"); +} +if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); + +--FILE-- +<?php + +if(posix_getuid() !== 0) { + pcntl_unshare(CLONE_NEWUSER); +} + +var_dump(gethostbyname('php.net')); +pcntl_unshare(CLONE_NEWNET); +var_dump(gethostbyname('php.net')); +--EXPECTF-- +string(%d) %s +string(7) "php.net" |
