cvs: /php4 SAPI.h main.c request_info.c request_info.h /php4/sapi/cgi cgi_main.c
| From: | Zeev Suraski | Date: | Thu, 10 Feb 2000 20:03:47 +0000 |
| Subject: | cvs: /php4 SAPI.h main.c request_info.c request_info.h /php4/sapi/cgi cgi_main.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10061@lists.php.net to get a copy of this message | ||
zeev Thu Feb 10 12:03:47 2000 EDT
Modified files:
/php4 SAPI.h main.c request_info.c request_info.h
/php4/sapi/cgi cgi_main.c
Log:
request_info.c is giving up
Index: php4/SAPI.h
diff -u php4/SAPI.h:1.34 php4/SAPI.h:1.35
--- php4/SAPI.h:1.34 Thu Feb 10 10:44:32 2000
+++ php4/SAPI.h Thu Feb 10 12:03:17 2000
@@ -76,6 +76,9 @@
/* for HTTP authentication */
char *auth_user;
char *auth_password;
+
+ /* this is necessary for the CGI SAPI module */
+ char *argv0;
} sapi_request_info;
Index: php4/main.c
diff -u php4/main.c:1.199 php4/main.c:1.200
--- php4/main.c:1.199 Thu Feb 10 10:44:32 2000
+++ php4/main.c Thu Feb 10 12:03:17 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.199 2000/02/10 18:44:32 zeev Exp $ */
+/* $Id: main.c,v 1.200 2000/02/10 20:03:17 zeev Exp $ */
#include <stdio.h>
@@ -831,6 +831,7 @@
PG(header_is_being_sent) = 0;
SG(request_info).headers_only = 0;
+ SG(request_info).argv0 = NULL;
PG(connection_status) = PHP_CONNECTION_NORMAL;
#if HAVE_SETLOCALE
Index: php4/request_info.c
diff -u php4/request_info.c:1.24 php4/request_info.c:1.25
--- php4/request_info.c:1.24 Thu Feb 10 11:41:18 2000
+++ php4/request_info.c Thu Feb 10 12:03:17 2000
@@ -19,79 +19,13 @@
#include "php.h"
#include "SAPI.h"
-#ifndef THREAD_SAFE
PHPAPI php_request_info request_info;
-#endif
-#if CGI_BINARY
-int php_init_request_info(void *conf)
-{
- request_info.script_name = getenv("SCRIPT_NAME");
- request_info.script_filename = getenv("SCRIPT_FILENAME");
- /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
- if (!request_info.script_filename) {
- request_info.script_filename = request_info.php_argv0;
- }
-#if PHP_WIN32
- /* FIXME WHEN APACHE NT IS FIXED */
- /* a hack for apache nt because it does not appear to set argv[1] and sets
- script filename to php.exe thus makes us parse php.exe instead of file.php
- requires we get the info from path translated. This can be removed at
- such a time taht apache nt is fixed */
- else {
- request_info.script_filename = getenv("PATH_TRANSLATED");
- }
-#endif
-
- /* doc_root configuration variable is currently ignored,
- as it is with every other access method currently also. */
-
- /* We always need to emalloc() filename, since it gets placed into
- the include file hash table, and gets freed with that table.
- Notice that this means that we don't need to efree() it in
- php_destroy_request_info()! */
-#if DISCARD_PATH
- if (request_info.script_filename) {
- SLS_FETCH();
- SG(request_info).path_translated = estrdup(request_info.script_filename);
- } else {
- SLS_FETCH();
- SG(request_info).path_translated = NULL;
- }
-#endif
- return SUCCESS;
-}
-
int php_destroy_request_info(void *conf)
{
STR_FREE(request_info.current_user);
return SUCCESS;
}
-#endif
-
-
-#if APACHE
-int php_init_request_info(void *conf)
-{
- request_rec *r;
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
-
- return SUCCESS;
-}
-
-#endif
-
-#if !CGI_BINARY
-int php_destroy_request_info(void *conf)
-{
- /* see above for why we don't want to efree() request_info.filename */
- STR_FREE(request_info.current_user);
- return SUCCESS;
-}
-#endif
-
int php_init_request_info(void *conf)
{
Index: php4/request_info.h
diff -u php4/request_info.h:1.10 php4/request_info.h:1.11
--- php4/request_info.h:1.10 Thu Feb 10 11:41:18 2000
+++ php4/request_info.h Thu Feb 10 12:03:17 2000
@@ -23,7 +23,6 @@
char *current_user;
int current_user_length;
const char *script_filename;
- char *php_argv0;
} php_request_info;
#ifndef THREAD_SAFE
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.26 php4/sapi/cgi/cgi_main.c:1.27
--- php4/sapi/cgi/cgi_main.c:1.26 Thu Feb 10 11:41:20 2000
+++ php4/sapi/cgi/cgi_main.c Thu Feb 10 12:03:17 2000
@@ -166,9 +166,9 @@
static int sapi_cgi_deactivate(SLS_D)
{
fflush(stdout);
- if(request_info.php_argv0) {
- free(request_info.php_argv0);
- request_info.php_argv0 = NULL;
+ if(SG(request_info).argv0) {
+ free(SG(request_info).argv0);
+ SG(request_info).argv0 = NULL;
}
return SUCCESS;
}
@@ -241,7 +241,44 @@
static void init_request_info(SLS_D)
{
char *content_length = getenv("CONTENT_LENGTH");
+ char *script_filename;
+
+ script_filename = getenv("SCRIPT_FILENAME");
+ /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
+ if (!script_filename) {
+ script_filename = SG(request_info).argv0;
+ }
+#if PHP_WIN32
+ /* FIXME WHEN APACHE NT IS FIXED */
+ /* a hack for apache nt because it does not appear to set argv[1] and sets
+ script filename to php.exe thus makes us parse php.exe instead of file.php
+ requires we get the info from path translated. This can be removed at
+ such a time taht apache nt is fixed */
+ if (script_filename) {
+ script_filename = getenv("PATH_TRANSLATED");
+ }
+#endif
+
+ /* doc_root configuration variable is currently ignored,
+ as it is with every other access method currently also. */
+
+ /* We always need to emalloc() filename, since it gets placed into
+ the include file hash table, and gets freed with that table.
+ Notice that this means that we don't need to efree() it in
+ php_destroy_request_info()! */
+#if DISCARD_PATH
+ if (script_filename) {
+ SLS_FETCH();
+
+ SG(request_info).path_translated = estrdup(script_filename);
+ } else {
+ SLS_FETCH();
+
+ SG(request_info).path_translated = NULL;
+ }
+#endif
+
SG(request_info).request_method = getenv("REQUEST_METHOD");
SG(request_info).query_string = getenv("QUERY_STRING");
SG(request_info).request_uri = getenv("PATH_INFO");
@@ -252,6 +289,8 @@
/* CGI does not support HTTP authentication */
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
+
+
}
@@ -283,6 +322,7 @@
int free_path_translated=0;
int orig_optind=ap_php_optind;
char *orig_optarg=ap_php_optarg;
+ char *argv0=NULL;
#if SUPPORT_INTERACTIVE
int interactive=0;
#endif
@@ -322,9 +362,11 @@
|| getenv("GATEWAY_INTERFACE")
|| getenv("REQUEST_METHOD")) {
cgi = 1;
- if (argc > 1)
- request_info.php_argv0 = strdup(argv[1]);
- else request_info.php_argv0 = NULL;
+ if (argc > 1) {
+ argv0 = strdup(argv[1]);
+ } else {
+ argv0 = NULL;
+ }
#if FORCE_CGI_REDIRECT
if (!getenv("REDIRECT_STATUS")) {
PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
@@ -379,8 +421,10 @@
SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
CG(extended_info) = 0;
+ SG(request_info).argv0 = argv0;
+
if (!cgi) { /* never execute the arguments if you are a CGI */
- request_info.php_argv0 = NULL;
+ SG(request_info).argv0 = NULL;
while ((c = ap_php_getopt(argc, argv, "c:d:qvisnaeh?vf:")) != -1) {
switch (c) {
case 'f':