CVS update: php31/main

From: Date: Fri, 14 Aug 1998 23:57:42 +0000
Subject: CVS update: php31/main
Groups: php.dev 
Request: Send a blank email to php-dev+get-252@lists.php.net to get a copy of this message
Date: Friday August 14, 1998 @ 19:57 Author: steffann Update of /repository/php31/main In directory asf:/tmp/cvs-serv14398/main Modified Files: fopen-wrappers.c fopen-wrappers.h main.c php3_ini.h Log Message: Change the name of fopen_basedir here too Index: php31/main/fopen-wrappers.c diff -c php31/main/fopen-wrappers.c:2.1 php31/main/fopen-wrappers.c:2.2 *** php31/main/fopen-wrappers.c:2.1 Thu Aug 13 19:23:27 1998 --- php31/main/fopen-wrappers.c Fri Aug 14 19:57:41 1998 *************** *** 27,33 **** | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.c,v 2.1 1998/08/13 23:23:27 shane Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 27,33 ---- | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.c,v 2.2 1998/08/14 23:57:41 steffann Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 99,137 **** int _php3_getftpresult(int socketd); /* ! When fopen_basedir is not NULL, check if the given filename is located in ! fopen_basedir. Returns -1 if error or not in the fopen_basedir, else 0 ! When fopen_basedir is NULL, always return 0 */ ! int _php3_check_fopen_basedir(char *path) { char resolved_name[MAXPATHLEN]; TLS_VARS; ! /* Only check when fopen_basedir is available */ ! if (GLOBAL(php3_ini)->fopen_basedir && *GLOBAL(php3_ini)->fopen_basedir) { /* Resolve the real path into resolved_name */ if (_php3_realpath(path, resolved_name) != NULL) { /* Check the path */ #if WIN32|WINNT ! if (strncmp(GLOBAL(php3_ini)->fopen_basedir, resolved_name, strlen(GLOBAL(php3_ini)->fopen_basedir)) == 0) { #else ! if (strncasecmp(GLOBAL(php3_ini)->fopen_basedir, resolved_name, strlen(GLOBAL(php3_ini)->fopen_basedir)) == 0) { #endif /* File is in the right directory */ return 0; } else { ! php3_error(E_WARNING, "fopen_basedir restriction in effect. File is in wrong directory."); return -1; } } else { /* Unable to resolve the real path, return -1 */ ! php3_error(E_WARNING, "fopen_basedir restriction in effect. Unable to verify location of file."); return -1; } } else { ! /* fopen_basedir is not available, return 0 */ return 0; } } --- 99,137 ---- int _php3_getftpresult(int socketd); /* ! When open_basedir is not NULL, check if the given filename is located in ! open_basedir. Returns -1 if error or not in the open_basedir, else 0 ! When open_basedir is NULL, always return 0 */ ! PHPAPI int _php3_check_open_basedir(char *path) { char resolved_name[MAXPATHLEN]; TLS_VARS; ! /* Only check when open_basedir is available */ ! if (GLOBAL(php3_ini)->open_basedir && *GLOBAL(php3_ini)->open_basedir) { /* Resolve the real path into resolved_name */ if (_php3_realpath(path, resolved_name) != NULL) { /* Check the path */ #if WIN32|WINNT ! if (strncmp(GLOBAL(php3_ini)->open_basedir, resolved_name, strlen(GLOBAL(php3_ini)->open_basedir)) == 0) { #else ! if (strncasecmp(GLOBAL(php3_ini)->open_basedir, resolved_name, strlen(GLOBAL(php3_ini)->open_basedir)) == 0) { #endif /* File is in the right directory */ return 0; } else { ! php3_error(E_WARNING, "open_basedir restriction in effect. File is in wrong directory."); return -1; } } else { /* Unable to resolve the real path, return -1 */ ! php3_error(E_WARNING, "open_basedir restriction in effect. Unable to verify location of file."); return -1; } } else { ! /* open_basedir is not available, return 0 */ return 0; } } *************** *** 268,274 **** php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_fopen_basedir(filename)) return NULL; fp = fopen(filename, mode); if (fp && opened_path) { *opened_path = expand_filepath(filename); --- 268,274 ---- php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_open_basedir(filename)) return NULL; fp = fopen(filename, mode); if (fp && opened_path) { *opened_path = expand_filepath(filename); *************** *** 287,300 **** php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_fopen_basedir(trypath)) return NULL; fp = fopen(trypath, mode); if (fp && opened_path) { *opened_path = expand_filepath(trypath); } return fp; } else { ! if (_php3_check_fopen_basedir(filename)) return NULL; return fopen(filename, mode); } } --- 287,300 ---- php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_open_basedir(trypath)) return NULL; fp = fopen(trypath, mode); if (fp && opened_path) { *opened_path = expand_filepath(trypath); } return fp; } else { ! if (_php3_check_open_basedir(filename)) return NULL; return fopen(filename, mode); } } *************** *** 303,309 **** php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_fopen_basedir(filename)) return NULL; fp = fopen(filename, mode); if (fp && opened_path) { *opened_path = strdup(filename); --- 303,309 ---- php3_error(E_WARNING, "SAFE MODE Restriction in effect. Invalid owner."); return NULL; } ! if (_php3_check_open_basedir(filename)) return NULL; fp = fopen(filename, mode); if (fp && opened_path) { *opened_path = strdup(filename); *************** *** 333,339 **** } } if ((fp = fopen(trypath, mode)) != NULL) { ! if (_php3_check_fopen_basedir(trypath)) { fclose(fp); efree(pathbuf); return NULL; --- 333,339 ---- } } if ((fp = fopen(trypath, mode)) != NULL) { ! if (_php3_check_open_basedir(trypath)) { fclose(fp); efree(pathbuf); return NULL; Index: php31/main/fopen-wrappers.h diff -c php31/main/fopen-wrappers.h:2.1 php31/main/fopen-wrappers.h:2.2 *** php31/main/fopen-wrappers.h:2.1 Thu Aug 13 19:23:28 1998 --- php31/main/fopen-wrappers.h Fri Aug 14 19:57:41 1998 *************** *** 26,32 **** | Authors: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.h,v 2.1 1998/08/13 23:23:28 shane Exp $ */ #ifndef _FOPEN_WRAPPERS_H #define _FOPEN_WRAPPERS_H --- 26,32 ---- | Authors: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.h,v 2.2 1998/08/14 23:57:41 steffann Exp $ */ #ifndef _FOPEN_WRAPPERS_H #define _FOPEN_WRAPPERS_H *************** *** 78,84 **** extern PHPAPI int php3_write(void *buf, int size); extern PHPAPI char *expand_filepath(char *filepath); ! extern int _php3_check_fopen_basedir(char *path); #endif /* * Local variables: --- 78,84 ---- extern PHPAPI int php3_write(void *buf, int size); extern PHPAPI char *expand_filepath(char *filepath); ! extern PHPAPI int _php3_check_open_basedir(char *path); #endif /* * Local variables: Index: php31/main/main.c diff -c php31/main/main.c:2.7 php31/main/main.c:2.8 *** php31/main/main.c:2.7 Thu Aug 13 18:48:59 1998 --- php31/main/main.c Fri Aug 14 19:57:41 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.7 1998/08/13 22:48:59 shane Exp $ */ /* #define CRASH_DETECTION */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.8 1998/08/14 23:57:41 steffann Exp $ */ /* #define CRASH_DETECTION */ *************** *** 994,1001 **** if (cfg_get_string("gpc_order", &php3_ini_master.gpc_order) == FAILURE) { php3_ini_master.gpc_order = "GPC"; } ! if (cfg_get_string("fopen_basedir", &php3_ini_master.fopen_basedir) == FAILURE) { ! php3_ini_master.fopen_basedir = NULL; } if (cfg_get_long("enable_dl", &php3_ini_master.enable_dl) == FAILURE) { php3_ini_master.enable_dl = 1; --- 994,1001 ---- if (cfg_get_string("gpc_order", &php3_ini_master.gpc_order) == FAILURE) { php3_ini_master.gpc_order = "GPC"; } ! if (cfg_get_string("open_basedir", &php3_ini_master.open_basedir) == FAILURE) { ! php3_ini_master.open_basedir = NULL; } if (cfg_get_long("enable_dl", &php3_ini_master.enable_dl) == FAILURE) { php3_ini_master.enable_dl = 1; Index: php31/main/php3_ini.h diff -c php31/main/php3_ini.h:2.2 php31/main/php3_ini.h:2.3 *** php31/main/php3_ini.h:2.2 Thu Aug 13 18:49:00 1998 --- php31/main/php3_ini.h Fri Aug 14 19:57:42 1998 *************** *** 86,92 **** long define_syslog_variables; char *error_prepend_string; char *error_append_string; ! char *fopen_basedir; long enable_dl; } php3_ini_structure; --- 86,92 ---- long define_syslog_variables; char *error_prepend_string; char *error_append_string; ! char *open_basedir; long enable_dl; } php3_ini_structure; -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#252) next »