pcntl_unshare_01.phpt 600 B

123456789101112131415161718192021222324
  1. --TEST--
  2. pcntl_unshare() with CLONE_NEWUSER
  3. --EXTENSIONS--
  4. pcntl
  5. posix
  6. --SKIPIF--
  7. <?php
  8. if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available");
  9. if (!defined("CLONE_NEWUSER")) die("skip flag unavailable");
  10. if (@pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM) {
  11. die("skip Insufficient privileges to use CLONE_NEWUSER");
  12. }
  13. if (getenv("SKIP_REPEAT")) die("skip cannot be repeated");
  14. ?>
  15. --FILE--
  16. <?php
  17. $olduid = posix_getuid();
  18. pcntl_unshare(CLONE_NEWUSER);
  19. $newuid = posix_getuid();
  20. var_dump($olduid === $newuid);
  21. ?>
  22. --EXPECT--
  23. bool(false)