cvs: /php4 SAPI.c fopen-wrappers.c php.h php_realpath.c php_virtual_cwd.c php_virtual_cwd.h safe_mode.c

From: Date: Thu, 20 Apr 2000 16:38:38 +0000
Subject: cvs: /php4 SAPI.c fopen-wrappers.c php.h php_realpath.c php_virtual_cwd.c php_virtual_cwd.h safe_mode.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-13807@lists.php.net to get a copy of this message
andi Thu Apr 20 09:38:38 2000 EDT Modified files: /php4 SAPI.c fopen-wrappers.c php.h php_realpath.c php_virtual_cwd.c php_virtual_cwd.h safe_mode.c Log: - Add missing V_STAT() Index: php4/SAPI.c diff -u php4/SAPI.c:1.71 php4/SAPI.c:1.72 --- php4/SAPI.c:1.71 Sun Apr 2 13:26:06 2000 +++ php4/SAPI.c Thu Apr 20 09:38:08 2000 @@ -534,7 +534,7 @@ if (sapi_module.get_stat) { return sapi_module.get_stat(SLS_C); } else { - if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &SG(global_stat))==-1)) { + if (!SG(request_info).path_translated || (V_STAT(SG(request_info).path_translated, &SG(global_stat))==-1)) { return NULL; } return &SG(global_stat); Index: php4/fopen-wrappers.c diff -u php4/fopen-wrappers.c:1.55 php4/fopen-wrappers.c:1.56 --- php4/fopen-wrappers.c:1.55 Sat Apr 15 07:19:58 2000 +++ php4/fopen-wrappers.c Thu Apr 20 09:38:08 2000 @@ -16,7 +16,7 @@ | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: fopen-wrappers.c,v 1.55 2000/04/15 14:19:58 andi Exp $ */ +/* $Id: fopen-wrappers.c,v 1.56 2000/04/20 16:38:08 andi Exp $ */ #include "php.h" #include "php_globals.h" @@ -408,7 +408,7 @@ } snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); if (PG(safe_mode)) { - if (stat(trypath, &sb) == 0 && (!php_checkuid(trypath, cm))) { + if (V_STAT(trypath, &sb) == 0 && (!php_checkuid(trypath, cm))) { efree(pathbuf); return NULL; } Index: php4/php.h diff -u php4/php.h:1.82 php4/php.h:1.83 --- php4/php.h:1.82 Sat Apr 15 07:19:58 2000 +++ php4/php.h Thu Apr 20 09:38:08 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.82 2000/04/15 14:19:58 andi Exp $ */ +/* $Id: php.h,v 1.83 2000/04/20 16:38:08 andi Exp $ */ #ifndef _PHP_H #define _PHP_H @@ -294,12 +294,14 @@ #define V_CHDIR(path) virtual_chdir(path) #define V_CHDIR_FILE(path) virtual_chdir_file(path) #define V_GETWD(buf) +#define V_STAT(path, buff) virtual_stat(path, buff) #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) #define V_CHDIR(path) chdir(path) #define V_CHDIR_FILE(path) chdir_file(path) #define V_GETWD(buf) getwd(buf) +#define V_STAT(path, buff) stat(path, buff) #endif #include "zend_constants.h" Index: php4/php_realpath.c diff -u php4/php_realpath.c:1.7 php4/php_realpath.c:1.8 --- php4/php_realpath.c:1.7 Sat Apr 15 07:19:58 2000 +++ php4/php_realpath.c Thu Apr 20 09:38:08 2000 @@ -251,7 +251,7 @@ } /* Check if the resolved path is a directory */ - if (stat(path_construction, &filestat) != 0) return NULL; + if (V_STAT(path_construction, &filestat) != 0) return NULL; if (S_ISDIR(filestat.st_mode)) { /* It's a directory, append a / if needed */ if (*(writepos-1) != '/') { Index: php4/php_virtual_cwd.c diff -u php4/php_virtual_cwd.c:1.31 php4/php_virtual_cwd.c:1.32 --- php4/php_virtual_cwd.c:1.31 Mon Apr 10 10:39:11 2000 +++ php4/php_virtual_cwd.c Thu Apr 20 09:38:08 2000 @@ -7,6 +7,7 @@ #include <stdlib.h> #include <ctype.h> + #include "php_virtual_cwd.h" #ifdef ZTS @@ -364,6 +365,21 @@ f = fopen(new_state.cwd, mode); CWD_STATE_FREE(&new_state); return f; +} + +CWD_API int virtual_stat(const char *path, struct stat *buf) +{ + cwd_state new_state; + int retval; + CWDLS_FETCH(); + + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + + virtual_file_ex(&new_state, path, NULL); + + retval = stat(new_state.cwd, buf); + CWD_STATE_FREE(&new_state); + return retval; } #if 0 Index: php4/php_virtual_cwd.h diff -u php4/php_virtual_cwd.h:1.12 php4/php_virtual_cwd.h:1.13 --- php4/php_virtual_cwd.h:1.12 Mon Apr 10 10:39:11 2000 +++ php4/php_virtual_cwd.h Thu Apr 20 09:38:08 2000 @@ -4,6 +4,14 @@ #include "zend.h" #include "zend_API.h" +#include <sys/types.h> +#include <sys/stat.h> + +#ifndef ZEND_WIN32 +#include <unistd.h> +#endif + + #ifdef PHP_EXPORTS #define CWD_EXPORTS #endif @@ -34,6 +42,7 @@ CWD_API int virtual_chdir_file(char *path); CWD_API int virtual_filepath(char *path, char **filepath); CWD_API FILE *virtual_fopen(const char *path, const char *mode); +CWD_API int virtual_stat(const char *path, struct stat *buf); CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path); ZEND_BEGIN_MODULE_GLOBALS(cwd) Index: php4/safe_mode.c diff -u php4/safe_mode.c:1.18 php4/safe_mode.c:1.19 --- php4/safe_mode.c:1.18 Sat Apr 15 07:19:58 2000 +++ php4/safe_mode.c Thu Apr 20 09:38:08 2000 @@ -15,7 +15,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: safe_mode.c,v 1.18 2000/04/15 14:19:58 andi Exp $ */ +/* $Id: safe_mode.c,v 1.19 2000/04/20 16:38:08 andi Exp $ */ #include "php.h" @@ -57,7 +57,7 @@ } if (mode<3) { - ret = stat(fn,&sb); + ret = V_STAT(fn,&sb); if (ret<0 && mode < 2) { php_error(E_WARNING,"Unable to access %s",fn); return(mode); @@ -79,7 +79,7 @@ if (s) { *s='\0'; - ret = stat(fn,&sb); + ret = V_STAT(fn,&sb); *s='/'; if (ret<0) { php_error(E_WARNING, "Unable to access %s",fn); @@ -92,7 +92,7 @@ php_error(E_WARNING, "Unable to access current working directory"); return(0); } - ret = stat(s,&sb); + ret = V_STAT(s,&sb); efree(s); if (ret<0) { php_error(E_WARNING, "Unable to access %s",s);

« previous php.version4 (#13807) next »