iliaa Tue Nov 5 09:50:17 2002 EDT Modified files: /TSRM tsrm_virtual_cwd.h tsrm_virtual_cwd.c /php4/main fopen_wrappers.c Log: Added 4th argument to virtual_file_ex() that specifies whether or not realpath() should be used during path resolving. In a number of functions we do not want to use realpath(), since realpath() will resolve symlinks. Index: TSRM/tsrm_virtual_cwd.h diff -u TSRM/tsrm_virtual_cwd.h:1.23 TSRM/tsrm_virtual_cwd.h:1.24 --- TSRM/tsrm_virtual_cwd.h:1.23 Mon Nov 4 18:24:15 2002 +++ TSRM/tsrm_virtual_cwd.h Tue Nov 5 09:50:16 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.h,v 1.23 2002/11/04 23:24:15 iliaa Exp $ */ +/* $Id: tsrm_virtual_cwd.h,v 1.24 2002/11/05 14:50:16 iliaa Exp $ */ #ifndef VIRTUAL_CWD_H #define VIRTUAL_CWD_H @@ -163,7 +163,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group TSRMLS_DC); #endif -CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path); +CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func +verify_path, int use_realpath); typedef struct _virtual_cwd_globals { cwd_state cwd; Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.39 TSRM/tsrm_virtual_cwd.c:1.40 --- TSRM/tsrm_virtual_cwd.c:1.39 Mon Nov 4 18:24:15 2002 +++ TSRM/tsrm_virtual_cwd.c Tue Nov 5 09:50:16 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.c,v 1.39 2002/11/04 23:24:15 iliaa Exp $ */ +/* $Id: tsrm_virtual_cwd.c,v 1.40 2002/11/05 14:50:16 iliaa Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -284,7 +284,7 @@ /* Resolve path relatively to state and put the real path into state */ /* returns 0 for ok, 1 for error */ -CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path) +CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func +verify_path, int use_realpath) { int path_length = strlen(path); char *ptr, *path_copy; @@ -304,7 +304,7 @@ #if !defined(TSRM_WIN32) && !defined(NETWARE) if (IS_ABSOLUTE_PATH(path, path_length)) { - if (realpath(path, resolved_path)) { + if (use_realpath && realpath(path, resolved_path)) { path = resolved_path; path_length = strlen(path); } @@ -322,7 +322,7 @@ memcpy(ptr, path, path_length); ptr += path_length; *ptr = '\0'; - if (realpath(tmp, resolved_path)) { + if (use_realpath && realpath(tmp, resolved_path)) { path = resolved_path; path_length = strlen(path); } @@ -439,7 +439,7 @@ CWD_API int virtual_chdir(const char *path TSRMLS_DC) { - return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0; + return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, 1)?-1:0; } CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) @@ -480,7 +480,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - retval = virtual_file_ex(&new_state, path, NULL); + retval = virtual_file_ex(&new_state, path, NULL, 1); if (!retval) { int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length; @@ -498,7 +498,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - retval = virtual_file_ex(&new_state, path, verify_path); + retval = virtual_file_ex(&new_state, path, verify_path, 1); *filepath = new_state.cwd; @@ -521,7 +521,7 @@ } CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 1); f = fopen(new_state.cwd, mode); @@ -536,7 +536,7 @@ int ret; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, pathname, NULL); + virtual_file_ex(&new_state, pathname, NULL, 1); ret = access(new_state.cwd, mode); @@ -554,7 +554,7 @@ int ret; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, filename, NULL); + virtual_file_ex(&new_state, filename, NULL, 0); ret = utime(new_state.cwd, buf); @@ -569,7 +569,7 @@ int ret; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, filename, NULL); + virtual_file_ex(&new_state, filename, NULL, 1); ret = chmod(new_state.cwd, mode); @@ -584,7 +584,7 @@ int ret; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, filename, NULL); + virtual_file_ex(&new_state, filename, NULL, 0); ret = chown(new_state.cwd, owner, group); @@ -599,7 +599,7 @@ int f; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 1); if (flags & O_CREAT) { mode_t mode; @@ -623,7 +623,7 @@ int f; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 1); f = creat(new_state.cwd, mode); @@ -638,11 +638,11 @@ int retval; CWD_STATE_COPY(&old_state, &CWDG(cwd)); - virtual_file_ex(&old_state, oldname, NULL); + virtual_file_ex(&old_state, oldname, NULL, 0); oldname = old_state.cwd; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, newname, NULL); + virtual_file_ex(&new_state, newname, NULL, 0); newname = new_state.cwd; retval = rename(oldname, newname); @@ -660,7 +660,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 1); retval = stat(new_state.cwd, buf); @@ -674,7 +674,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 1); retval = stat(new_state.cwd, (struct stat*)buf); @@ -690,7 +690,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 0); retval = lstat(new_state.cwd, buf); @@ -705,7 +705,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, path, NULL); + virtual_file_ex(&new_state, path, NULL, 0); retval = unlink(new_state.cwd); @@ -719,7 +719,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, pathname, NULL); + virtual_file_ex(&new_state, pathname, NULL, 1); #ifdef TSRM_WIN32 retval = mkdir(new_state.cwd); @@ -736,7 +736,7 @@ int retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, pathname, NULL); + virtual_file_ex(&new_state, pathname, NULL, 0); retval = rmdir(new_state.cwd); @@ -754,7 +754,7 @@ DIR *retval; CWD_STATE_COPY(&new_state, &CWDG(cwd)); - virtual_file_ex(&new_state, pathname, NULL); + virtual_file_ex(&new_state, pathname, NULL, 1); retval = opendir(new_state.cwd); Index: php4/main/fopen_wrappers.c diff -u php4/main/fopen_wrappers.c:1.151 php4/main/fopen_wrappers.c:1.152 --- php4/main/fopen_wrappers.c:1.151 Fri Oct 4 18:16:16 2002 +++ php4/main/fopen_wrappers.c Tue Nov 5 09:50:17 2002 @@ -16,7 +16,7 @@ | Jim Winstead <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.151 2002/10/04 22:16:16 bfrance Exp $ */ +/* $Id: fopen_wrappers.c,v 1.152 2002/11/05 14:50:17 iliaa Exp $ */ /* {{{ includes */ @@ -536,7 +536,7 @@ new_state.cwd = strdup(cwd); new_state.cwd_length = strlen(cwd); - if(virtual_file_ex(&new_state, filepath, NULL)) { + if(virtual_file_ex(&new_state, filepath, NULL, 1)) { free(new_state.cwd); return NULL; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php