1--TEST-- 2Test posix_mkfifo() with safe_mode. 3--DESCRIPTION-- 4The test attempts to enable safe_mode, catches all the relevant E_WARNING's and tries to create a fifo in /tmp. 5 6The first attempt (writing to /tmp) should effectively fail because /tmp is owned by root. 7 8The second attempt (writing to a local created file) works. 9--CREDITS-- 10Till Klampaeckel, till@php.net 11TestFest Berlin 2009 12--SKIPIF-- 13<?php 14if (!extension_loaded('posix')) { 15 die('SKIP The posix extension is not loaded.'); 16} 17if (posix_geteuid() == 0) { 18 die('SKIP Cannot run test as root.'); 19} 20if (PHP_VERSION_ID < 503099) { 21 die('SKIP Safe mode is no longer available.'); 22} 23?> 24--FILE-- 25<?php 26var_dump(posix_mkfifo('/tmp/foobar', 0644)); 27 28$dir = dirname(__FILE__) . '/foo'; 29mkdir ($dir); 30var_dump(posix_mkfifo($dir . '/bar', 0644)); 31?> 32===DONE=== 33--CLEAN-- 34<?php 35$dir = dirname(__FILE__) . '/foo'; 36unlink($dir . '/bar'); 37rmdir($dir); 38?> 39--EXPECTF-- 40Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d 41 42Warning: posix_mkfifo(): SAFE MODE Restriction in effect. The script whose uid is %d is not allowed to access /tmp owned by uid %d in %s on line %d 43bool(false) 44bool(true) 45===DONE=== 46