Annotation of embedaddon/php/ext/standard/tests/dir/scandir_variation5.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test scandir() function : usage variations - different directory permissions
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if( substr(PHP_OS, 0, 3) == 'WIN') {
        !             6:        die('skip Not for Windows');
        !             7: }
        !             8: // Skip if being run by root (files are always readable, writeable and executable)
        !             9: $filename = dirname(__FILE__)."/dir_root_check.tmp";
        !            10: $fp = fopen($filename, 'w');
        !            11: fclose($fp);
        !            12: if(fileowner($filename) == 0) {
        !            13:        unlink ($filename);
        !            14:        die('skip...cannot be run as root\n');
        !            15: }
        !            16: unlink($filename);
        !            17: ?>
        !            18: --FILE--
        !            19: <?php
        !            20: /* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
        !            21:  * Description: List files & directories inside the specified path 
        !            22:  * Source code: ext/standard/dir.c
        !            23:  */
        !            24: 
        !            25: /*
        !            26:  * remove the execute permission from the parent dir and test scandir() on child dir
        !            27:  * 1. remove write & execute permission from the 1st parent and test scandir()
        !            28:  * 2. remove execute permission from 2nd parent and test scandir()
        !            29:  */
        !            30: 
        !            31: echo "*** Testing scandir() : usage variations ***\n";
        !            32: 
        !            33: /* 
        !            34:  * create the temporary directory :
        !            35:  * scandir_variation5  ( parent )
        !            36:  *  |-> sub_dir     ( sub parent )
        !            37:  *      |-> child_dir  ( child dir)
        !            38:  */
        !            39: 
        !            40: $parent_dir_path = dirname(__FILE__) . "/scandir_variation5";
        !            41: mkdir($parent_dir_path);
        !            42: chmod($parent_dir_path, 0777);
        !            43: 
        !            44: // create sub_dir
        !            45: $sub_dir_path = $parent_dir_path . "/sub_dir";
        !            46: mkdir($sub_dir_path);
        !            47: chmod($sub_dir_path, 0777);
        !            48: 
        !            49: //create sub_sub_dir
        !            50: $child_dir_path = $sub_dir_path."/child_dir";
        !            51: mkdir($child_dir_path);
        !            52: 
        !            53: // remove the write and execute permisson from sub parent
        !            54: chmod($sub_dir_path, 0444);
        !            55: 
        !            56: echo "\n-- After restricting 1st level parent directory --\n";
        !            57: var_dump(scandir($child_dir_path));
        !            58: 
        !            59: // remove the execute permisson from parent dir, allowing all permission for sub dir
        !            60: chmod($sub_dir_path, 0777); // all permisson to sub dir
        !            61: chmod($parent_dir_path, 0666); // restricting parent directory
        !            62: 
        !            63: echo "\n-- After restricting parent directory --\n";
        !            64: var_dump(scandir($child_dir_path));
        !            65: ?>
        !            66: ===DONE===
        !            67: --CLEAN--
        !            68: <?php
        !            69: $parent_dir_path = dirname(__FILE__) . "/scandir_variation5";
        !            70: $sub_dir_path = $parent_dir_path."/sub_dir";
        !            71: $child_dir_path = $sub_dir_path."/child_dir";
        !            72: 
        !            73: // changing permissions for each temporary directory to delete them
        !            74: chmod($parent_dir_path, 0777);
        !            75: chmod($sub_dir_path, 0777);
        !            76: chmod($child_dir_path, 0777);
        !            77: 
        !            78: rmdir($child_dir_path);
        !            79: rmdir($sub_dir_path);
        !            80: rmdir($parent_dir_path);
        !            81: ?>
        !            82: --EXPECTF--
        !            83: *** Testing scandir() : usage variations ***
        !            84: 
        !            85: -- After restricting 1st level parent directory --
        !            86: 
        !            87: Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: %s in %s on line %d
        !            88: 
        !            89: Warning: scandir(): (errno %d): %s in %s on line %d
        !            90: bool(false)
        !            91: 
        !            92: -- After restricting parent directory --
        !            93: 
        !            94: Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: %s in %s on line %d
        !            95: 
        !            96: Warning: scandir(): (errno %d): %s in %s on line %d
        !            97: bool(false)
        !            98: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>