summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/fopen_wrappers.c2
-rw-r--r--main/php.h10
-rw-r--r--main/php_realpath.c6
-rw-r--r--main/safe_mode.c2
4 files changed, 15 insertions, 5 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index f4081ce7f7..9ab09104e1 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -970,7 +970,7 @@ PHPAPI char *expand_filepath(char *filepath)
if (filepath[0] == '.') {
char *cwd = malloc(MAXPATHLEN + 1);
- if (getcwd(cwd, MAXPATHLEN)) {
+ if (PHP_GETCWD(cwd, MAXPATHLEN)) {
char *cwd_end = cwd + strlen(cwd);
if (filepath[1] == '.') { /* parent directory - .. */
diff --git a/main/php.h b/main/php.h
index 4bbb694b5f..484d8af81f 100644
--- a/main/php.h
+++ b/main/php.h
@@ -284,6 +284,16 @@ PHPAPI int cfg_get_string(char *varname, char **result);
#define PUTS_H(str) php_header_write((str), strlen((str)))
#define PUTC_H(c) (php_header_write(&(c), 1), (c))
+/* Virtual current directory support */
+#ifdef VIRTUAL_DIR
+#define PHP_GETCWD(buff, size) virtual_getcwd(buff,size)
+#define PHP_FOPEN(path, mode) virtual_fopen(path, mode)
+#define PHP_CHDIR(path) virtual_chdir(path)
+#else
+#define PHP_GETCWD(buff, size) getcwd(buff,size)
+#define PHP_FOPEN(path, mode) fopen(path, mode)
+#define PHP_CHDIR(path) chdir(path)
+#endif
#include "zend_constants.h"
diff --git a/main/php_realpath.c b/main/php_realpath.c
index 9ced9b4030..b134b3fce3 100644
--- a/main/php_realpath.c
+++ b/main/php_realpath.c
@@ -63,7 +63,7 @@ char *php_realpath(char *path, char resolved_path []) {
if ((*workpos == '\\') || (*workpos == '/')) {
/* We start at the root of the current drive */
/* Get the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
+ if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
/* Unable to get cwd */
resolved_path[0] = 0;
return NULL;
@@ -79,7 +79,7 @@ char *php_realpath(char *path, char resolved_path []) {
workpos++;
} else {
/* Use the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
+ if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
/* Unable to get cwd */
resolved_path[0] = 0;
return NULL;
@@ -94,7 +94,7 @@ char *php_realpath(char *path, char resolved_path []) {
workpos++;
} else {
/* Use the current directory */
- if (getcwd(path_construction, MAXPATHLEN-1) == NULL) {
+ if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
/* Unable to get cwd */
resolved_path[0] = 0;
return NULL;
diff --git a/main/safe_mode.c b/main/safe_mode.c
index ab026376ba..b072552787 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -88,7 +88,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) {
duid = sb.st_uid;
} else {
s = emalloc(MAXPATHLEN+1);
- if (!getcwd(s,MAXPATHLEN)) {
+ if (!PHP_GETCWD(s,MAXPATHLEN)) {
php_error(E_WARNING, "Unable to access current working directory");
return(0);
}