[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard/tests/dir open_basedir.inc open_basedir_dir.phpt open_basedir_opendir.phpt open_basedir_scandir.phpt /ext/standard/tests/file open_basedir.inc open_based

2008-05-09 Thread Ant Phillips
ant Fri May  9 08:39:45 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/tests/security open_basedir_lstat.phpt 
open_basedir_chdir.phpt 
open_basedir_linkinfo.phpt 
open_basedir_link.phpt 
open_basedir_rename.phpt 
open_basedir_is_link.phpt 
open_basedir_realpath.phpt 
open_basedir_filetype.phpt 
open_basedir_disk_free_space.phpt 
open_basedir_fileinode.phpt 
open_basedir_scandir.phpt 
open_basedir_parse_ini_file.phpt 
open_basedir_file_exists.phpt 
open_basedir_chmod.phpt 
open_basedir_is_file.phpt 
open_basedir_file_get_contents.phpt 
open_basedir_is_dir.phpt 
open_basedir_tempnam.phpt 
open_basedir_error_log.phpt 
open_basedir_glob.phpt 
open_basedir_is_readable.phpt 
open_basedir_readlink.phpt 
open_basedir_is_executable.phpt 
open_basedir_opendir.phpt 
open_basedir_fileowner.phpt 
open_basedir_file.phpt 
open_basedir_filectime.phpt 
open_basedir_is_writable.phpt 
open_basedir_touch.phpt 
open_basedir_copy_variation1.phpt 
open_basedir_error_log_variation.phpt 
open_basedir_fileperms.phpt 
open_basedir_rmdir.phpt 
open_basedir_filegroup.phpt 
open_basedir_filemtime.phpt 
open_basedir_glob-win32.phpt 
open_basedir.inc open_basedir_copy.phpt 
open_basedir_mkdir.phpt 
open_basedir_filesize.phpt 
open_basedir_file_put_contents.phpt 
open_basedir_unlink.phpt 
open_basedir_symlink.phpt 
open_basedir_fopen.phpt 
open_basedir_fileatime.phpt 
open_basedir_dir.phpt 
open_basedir_stat.phpt 

  Removed files:   
/php-src/ext/standard/tests/dir open_basedir.inc 
open_basedir_dir.phpt 
open_basedir_scandir.phpt 
open_basedir_opendir.phpt 
/php-src/ext/standard/tests/fileopen_basedir_touch.phpt 
open_basedir_filegroup.phpt 
open_basedir_fileinode.phpt 
open_basedir.inc 
open_basedir_symlink.phpt 
open_basedir_file_get_contents.phpt 
open_basedir_filesize.phpt 
open_basedir_file.phpt 
open_basedir_filemtime.phpt 
open_basedir_filetype.phpt 
open_basedir_chdir.phpt 
open_basedir_disk_free_space.phpt 
open_basedir_tempnam.phpt 
open_basedir_chmod.phpt 
open_basedir_glob-win32.phpt 
open_basedir_readlink.phpt 
open_basedir_linkinfo.phpt 
open_basedir_is_file.phpt 
open_basedir_fileowner.phpt 
open_basedir_link.phpt 
open_basedir_rename.phpt 
open_basedir_filectime.phpt 
open_basedir_rmdir.phpt 
open_basedir_copy_variation1.phpt 
open_basedir_is_link.phpt 
open_basedir_copy.phpt 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard/tests/dir open_basedir.inc open_basedir_dir.phpt open_basedir_opendir.phpt open_basedir_scandir.phpt

2008-05-01 Thread Ant Phillips
ant Thu May  1 11:46:18 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/dir open_basedir_opendir.phpt 
open_basedir.inc 
open_basedir_dir.phpt 
open_basedir_scandir.phpt 
  Log:
  open_basedir tests for directory functions
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/open_basedir_opendir.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/dir/open_basedir_opendir.phpt
+++ php-src/ext/standard/tests/dir/open_basedir_opendir.phpt
--TEST--
Test open_basedir configuration
--INI--
open_basedir=.
--FILE--
?php
require_once open_basedir.inc;
test_open_basedir_before(opendir);
test_open_basedir_error(opendir); 

$directory = dirname(__FILE__);
var_dump(opendir($directory./test/ok/));
var_dump(opendir($directory./test/ok));
var_dump(opendir($directory./test/ok/../ok));

test_open_basedir_after(opendir);?
--CLEAN--
?php
require_once open_basedir.inc;
delete_directories();
?
--EXPECTF--
*** Testing open_basedir configuration [opendir] ***
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Warning: opendir(): open_basedir restriction in effect. File(../bad) is not 
within the allowed path(s): (.) in %s on line %d

Warning: opendir(../bad): failed to open dir: Operation not permitted in %s on 
line %d
bool(false)

Warning: opendir(): open_basedir restriction in effect. File(../bad/bad.txt) is 
not within the allowed path(s): (.) in %s on line %d

Warning: opendir(../bad/bad.txt): failed to open dir: Operation not permitted 
in %s on line %d
bool(false)

Warning: opendir(): open_basedir restriction in effect. File(..) is not within 
the allowed path(s): (.) in %s on line %d

Warning: opendir(..): failed to open dir: Operation not permitted in %s on line 
%d
bool(false)

Warning: opendir(): open_basedir restriction in effect. File(../) is not within 
the allowed path(s): (.) in %s on line %d

Warning: opendir(../): failed to open dir: Operation not permitted in %s on 
line %d
bool(false)

Warning: opendir(): open_basedir restriction in effect. File(/) is not within 
the allowed path(s): (.) in %s on line %d

Warning: opendir(/): failed to open dir: Operation not permitted in %s on line 
%d
bool(false)

Warning: opendir(): open_basedir restriction in effect. File(../bad/.) is not 
within the allowed path(s): (.) in %s on line %d

Warning: opendir(../bad/.): failed to open dir: Operation not permitted in %s 
on line %d
bool(false)

Warning: opendir(): open_basedir restriction in effect. 
File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line 
%d

Warning: opendir(%s/test/bad/bad.txt): failed to open dir: Operation not 
permitted in %s on line %d
bool(false)

Warning: opendir(): open_basedir restriction in effect. 
File(%s/test/bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s 
on line %d

Warning: opendir(%s/test/bad/../bad/bad.txt): failed to open dir: Operation not 
permitted in %s on line %d
bool(false)
resource(8) of type (stream)
resource(9) of type (stream)
resource(10) of type (stream)
*** Finished testing open_basedir configuration [opendir] ***


http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/open_basedir.inc?view=markuprev=1.1
Index: php-src/ext/standard/tests/dir/open_basedir.inc
+++ php-src/ext/standard/tests/dir/open_basedir.inc
?php

// This file contains helper functions for testing open_basedir configuration
// Care must be taken with where the directories are created because different
// SAPIs set the working directory differently. So simply creating a directory
// relative to the current working directory like this: mkdir(blah) might 
// actually create it in several different places depending on the SAPI..!
//
// Note also depending on the version of php being tested, so the open_basedir
// configuration may or may not be changeable from a script (PHP_INI_SYSTEM).
//
// For this reason we set the open_basedir to . (current directory) and then
// move around to various directories for testing using chdir(). This is NOT
// recommended for production use as . bypasses all semblence of security..!
//
// Although safe mode has been removed in php 6.0, open_basedir is still valid.
//  See http://www.php.net/features.safe-mode for more information

function recursive_delete_directory($directory) {

// Remove any trailing slash first
if (substr($directory, -1) == '/') {
$directory = substr($directory, 0, -1);
}

// Make sure the directory is valid
if (is_dir($directory) == FALSE) {
return FALSE;
} 

// Check we can access the directory
if (is_readable($directory) == FALSE) {
return FALSE;
}

$handle = opendir($directory);

// Scan through the directory contents
while (FALSE !== ($item = readdir($handle))) {
if ($item != '.') {
 if ($item != '..') {