File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / security / open_basedir_readlink.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:34 2012 UTC (12 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    1: --TEST--
    2: Test open_basedir configuration
    3: --SKIPIF--
    4: <?php
    5: if (substr(PHP_OS, 0, 3) == 'WIN') {
    6:     die('skip no symlinks on Windows');
    7: }
    8: ?>
    9: --FILE--
   10: <?php
   11: chdir(__DIR__);
   12: ini_set("open_basedir", ".");
   13: require_once "open_basedir.inc";
   14: $initdir = getcwd();
   15: test_open_basedir_before("readlink", FALSE);
   16: 
   17: chdir($initdir);
   18: 
   19: $target = ($initdir."/test/bad/bad.txt");
   20: $symlink = ($initdir."/test/ok/symlink.txt");
   21: var_dump(symlink($target, $symlink));
   22: 
   23: chdir($initdir."/test/ok");
   24: 
   25: var_dump(readlink("symlink.txt"));
   26: var_dump(readlink("../ok/symlink.txt"));
   27: var_dump(readlink("../ok/./symlink.txt"));
   28: var_dump(readlink("./symlink.txt"));
   29: var_dump(readlink($initdir."/test/ok/symlink.txt"));
   30: 
   31: $target = ($initdir."/test/ok/ok.txt");
   32: $symlink = ($initdir."/test/ok/symlink.txt");
   33: var_dump(symlink($target, $symlink));
   34: var_dump(readlink($symlink));
   35: 
   36: test_open_basedir_after("readlink");
   37: ?>
   38: --CLEAN--
   39: <?php
   40: require_once "open_basedir.inc";
   41: delete_directories();
   42: ?>
   43: --EXPECTF--
   44: *** Testing open_basedir configuration [readlink] ***
   45: bool(true)
   46: bool(true)
   47: bool(true)
   48: bool(true)
   49: bool(true)
   50: 
   51: Warning: readlink(): open_basedir restriction in effect. File(symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   52: bool(false)
   53: 
   54: Warning: readlink(): open_basedir restriction in effect. File(../ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   55: bool(false)
   56: 
   57: Warning: readlink(): open_basedir restriction in effect. File(../ok/./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   58: bool(false)
   59: 
   60: Warning: readlink(): open_basedir restriction in effect. File(./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   61: bool(false)
   62: 
   63: Warning: readlink(): open_basedir restriction in effect. File(%s/test/ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   64: bool(false)
   65: 
   66: Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
   67: bool(false)
   68: 
   69: Warning: readlink(): open_basedir restriction in effect. File(%s/test/ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   70: bool(false)
   71: *** Finished testing open_basedir configuration [readlink] ***
   72: 

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