cvs: php4 /ext/standard basic_functions.c dir.c php_dir.h

From: Date: Wed, 14 Feb 2001 10:48:49 +0000
Subject: cvs: php4 /ext/standard basic_functions.c dir.c php_dir.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4015@lists.php.net to get a copy of this message
derick Wed Feb 14 02:48:49 2001 EDT Modified files: /php4/ext/standard basic_functions.c dir.c php_dir.h Log: - Added the chroot function for changing root in a script. #- This can be usefull when using PHP in a shell environment, or when PHP # runs as CGI which needs a little more security Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.302 php4/ext/standard/basic_functions.c:1.303 --- php4/ext/standard/basic_functions.c:1.302 Mon Feb 5 13:59:16 2001 +++ php4/ext/standard/basic_functions.c Wed Feb 14 02:48:48 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.302 2001/02/05 21:59:16 zeev Exp $ */ +/* $Id: basic_functions.c,v 1.303 2001/02/14 10:48:48 derick Exp $ */ #include "php.h" #include "php_main.h" @@ -465,6 +465,7 @@ PHP_FE(opendir, NULL) PHP_FE(closedir, NULL) PHP_FE(chdir, NULL) + PHP_FE(chroot, NULL) PHP_FE(getcwd, NULL) PHP_FE(rewinddir, NULL) PHP_STATIC_FE("readdir", php_if_readdir, NULL) Index: php4/ext/standard/dir.c diff -u php4/ext/standard/dir.c:1.52 php4/ext/standard/dir.c:1.53 --- php4/ext/standard/dir.c:1.52 Sat Dec 16 12:52:43 2000 +++ php4/ext/standard/dir.c Wed Feb 14 02:48:48 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dir.c,v 1.52 2000/12/16 20:52:43 andi Exp $ */ +/* $Id: dir.c,v 1.53 2001/02/14 10:48:48 derick Exp $ */ /* {{{ includes/startup/misc */ @@ -219,6 +219,30 @@ if (dirp->id == DIRG(default_dir)) { php_set_default_dir(-1 DIRLS_CC); } +} + +/* }}} */ +/* {{{ proto int chroot(string directory) + Change root directory */ + +PHP_FUNCTION(chroot) +{ + pval **arg; + int ret; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(arg); + + ret = chroot((*arg)->value.str.val); + + if (ret != 0) { + php_error(E_WARNING, "chroot: %s (errno %d)", strerror(errno), errno); + RETURN_FALSE; + } + + RETURN_TRUE; } /* }}} */ Index: php4/ext/standard/php_dir.h diff -u php4/ext/standard/php_dir.h:1.11 php4/ext/standard/php_dir.h:1.12 --- php4/ext/standard/php_dir.h:1.11 Thu Dec 7 04:09:38 2000 +++ php4/ext/standard/php_dir.h Wed Feb 14 02:48:48 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dir.h,v 1.11 2000/12/07 12:09:38 sas Exp $ */ +/* $Id: php_dir.h,v 1.12 2001/02/14 10:48:48 derick Exp $ */ #ifndef PHP_DIR_H #define PHP_DIR_H @@ -28,6 +28,7 @@ PHP_FUNCTION(opendir); PHP_FUNCTION(closedir); PHP_FUNCTION(chdir); +PHP_FUNCTION(chroot); PHP_FUNCTION(getcwd); PHP_FUNCTION(rewinddir); PHP_NAMED_FUNCTION(php_if_readdir);

« previous php.cvs (#4015) next »