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} 20?> 21--INI-- 22safe_mode = 1 23--FILE-- 24<?php 25var_dump(posix_mkfifo('/tmp/foobar', 0644)); 26 27$dir = dirname(__FILE__) . '/foo'; 28mkdir ($dir); 29var_dump(posix_mkfifo($dir . '/bar', 0644)); 30?> 31===DONE=== 32--CLEAN-- 33<?php 34$dir = dirname(__FILE__) . '/foo'; 35unlink($dir . '/bar'); 36rmdir($dir); 37?> 38--EXPECTF-- 39Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d 40 41Warning: 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 42bool(false) 43bool(true) 44===DONE=== 45