#- This can be usefull when using PHP in a shell environment, or when PHP
# runs as CGI which needs a little more security
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)
}
}
+/* }}} */
+/* {{{ 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;
+}
+
/* }}} */
/* {{{ proto int chdir(string directory)
Change the current directory */
PHP_FUNCTION(opendir);
PHP_FUNCTION(closedir);
PHP_FUNCTION(chdir);
+PHP_FUNCTION(chroot);
PHP_FUNCTION(getcwd);
PHP_FUNCTION(rewinddir);
PHP_NAMED_FUNCTION(php_if_readdir);