summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2002-03-04 20:20:36 +0000
committerDerick Rethans <derick@php.net>2002-03-04 20:20:36 +0000
commitc5f773baf1a285b73228d418efc31b1fe435efcc (patch)
tree11ad507678e47340c6cd4cd221855f74a3186b94
parent7a3cb1e135cfe8db07364e3dc9235263f4100592 (diff)
downloadphp-git-c5f773baf1a285b73228d418efc31b1fe435efcc.tar.gz
- MFH for:
fix force redirect crash under multithreaded compile should be discused: fix redirect detection to only work with apache or netscape, where we know they set an environment variable regarding redirect. IIS has no security issue here. Don't know about other windows web servers.
-rw-r--r--sapi/cgi/cgi_main.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index c80581ca50..d03dffa169 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -441,8 +441,19 @@ int main(int argc, char *argv[])
ap_php_optarg = orig_optarg;
}
+#ifdef ZTS
+ compiler_globals = ts_resource(compiler_globals_id);
+ executor_globals = ts_resource(executor_globals_id);
+ core_globals = ts_resource(core_globals_id);
+ sapi_globals = ts_resource(sapi_globals_id);
+ tsrm_ls = ts_resource(0);
+#endif
+
/* startup after we get the above ini override se we get things right */
if (php_module_startup(&cgi_sapi_module)==FAILURE) {
+#ifdef ZTS
+ tsrm_shutdown();
+#endif
return FAILURE;
}
@@ -455,8 +466,14 @@ int main(int argc, char *argv[])
* http://www.koehntopp.de/php.
* -- kk@netuse.de
*/
- if (!getenv("REDIRECT_STATUS") && !getenv ("HTTP_REDIRECT_STATUS")) {
- PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
+ if (!getenv("REDIRECT_STATUS") && !getenv ("HTTP_REDIRECT_STATUS")
+#ifdef PHP_WIN32
+ /* IIS doesn't set anything, look to see if php.exe is in the script_name */
+ && (strstr(getenv("SERVER_SOFTWARE"),"Apache") ||
+ strstr(getenv("SERVER_SOFTWARE"),"iPlanet"))
+#endif
+ ) {
+ PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
\n\
<P>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
@@ -472,20 +489,15 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
\n");
/* remove that detailed explanation some time */
+#ifdef ZTS
+ tsrm_shutdown();
+#endif
return FAILURE;
}
}
#endif /* FORCE_CGI_REDIRECT */
-#ifdef ZTS
- compiler_globals = ts_resource(compiler_globals_id);
- executor_globals = ts_resource(executor_globals_id);
- core_globals = ts_resource(core_globals_id);
- sapi_globals = ts_resource(sapi_globals_id);
- tsrm_ls = ts_resource(0);
-#endif
-
zend_first_try {
if (!cgi) {
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {