File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / security / open_basedir_readlink.phpt
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 20:04:03 2014 UTC (10 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29, HEAD
php 5.4.29

    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: chdir(__DIR__);
   41: require_once "open_basedir.inc";
   42: delete_directories();
   43: ?>
   44: --EXPECTF--
   45: *** Testing open_basedir configuration [readlink] ***
   46: bool(true)
   47: bool(true)
   48: bool(true)
   49: bool(true)
   50: bool(true)
   51: 
   52: Warning: readlink(): open_basedir restriction in effect. File(symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   53: bool(false)
   54: 
   55: Warning: readlink(): open_basedir restriction in effect. File(../ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   56: bool(false)
   57: 
   58: Warning: readlink(): open_basedir restriction in effect. File(../ok/./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   59: bool(false)
   60: 
   61: Warning: readlink(): open_basedir restriction in effect. File(./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
   62: bool(false)
   63: 
   64: 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
   65: bool(false)
   66: 
   67: 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
   68: bool(false)
   69: 
   70: 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
   71: bool(false)
   72: *** Finished testing open_basedir configuration [readlink] ***
   73: 

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