* Get rid of another request_info element (filename)

* CGI through Apache should work now
This commit is contained in:
Zeev Suraski 1999-06-26 19:14:26 +00:00
parent 320541430b
commit d4f24f19ad
6 changed files with 27 additions and 36 deletions

View file

@ -178,8 +178,7 @@ int main(int argc, char *argv[])
zend_file_handle file_handle; zend_file_handle file_handle;
char *s; char *s;
/* temporary locals */ /* temporary locals */
char *_cgi_filename=NULL; int cgi_started=0;
int _cgi_started=0;
int behavior=PHP_MODE_STANDARD; int behavior=PHP_MODE_STANDARD;
int no_headers=0; int no_headers=0;
#if SUPPORT_INTERACTIVE #if SUPPORT_INTERACTIVE
@ -206,6 +205,8 @@ int main(int argc, char *argv[])
sapi_startup(&sapi_module); sapi_startup(&sapi_module);
SG(request_info).path_translated = NULL;
#if WIN32|WINNT #if WIN32|WINNT
_fmode = _O_BINARY; /*sets default for file streams to binary */ _fmode = _O_BINARY; /*sets default for file streams to binary */
setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
@ -270,7 +271,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
while ((c = getopt(argc, argv, "c:qvisnaeh?vf:")) != -1) { while ((c = getopt(argc, argv, "c:qvisnaeh?vf:")) != -1) {
switch (c) { switch (c) {
case 'f': case 'f':
if (!_cgi_started){ if (!cgi_started){
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
php_module_shutdown(); php_module_shutdown();
return FAILURE; return FAILURE;
@ -279,14 +280,14 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
if (no_headers) { if (no_headers) {
SG(headers_sent) = 1; SG(headers_sent) = 1;
} }
_cgi_started=1; cgi_started=1;
_cgi_filename = estrdup(optarg); SG(request_info).path_translated = estrdup(optarg);
/* break missing intentionally */ /* break missing intentionally */
case 'q': case 'q':
no_headers = 1; no_headers = 1;
break; break;
case 'v': case 'v':
if (!_cgi_started) { if (!cgi_started) {
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
php_module_shutdown(); php_module_shutdown();
return FAILURE; return FAILURE;
@ -299,7 +300,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
exit(1); exit(1);
break; break;
case 'i': case 'i':
if (!_cgi_started) { if (!cgi_started) {
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
php_module_shutdown(); php_module_shutdown();
return FAILURE; return FAILURE;
@ -308,7 +309,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
if (no_headers) { if (no_headers) {
SG(headers_sent) = 1; SG(headers_sent) = 1;
} }
_cgi_started=1; cgi_started=1;
php3_TreatHeaders(); php3_TreatHeaders();
_php3_info(); _php3_info();
exit(1); exit(1);
@ -350,7 +351,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
EG(interactive) = interactive; EG(interactive) = interactive;
#endif #endif
if (!_cgi_started) { if (!cgi_started) {
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) { if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
php_module_shutdown(); php_module_shutdown();
return FAILURE; return FAILURE;
@ -362,9 +363,6 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
file_handle.filename = "-"; file_handle.filename = "-";
file_handle.type = ZEND_HANDLE_FP; file_handle.type = ZEND_HANDLE_FP;
file_handle.handle.fp = stdin; file_handle.handle.fp = stdin;
if (_cgi_filename) {
request_info.filename = _cgi_filename;
}
php3_TreatHeaders(); php3_TreatHeaders();
@ -383,19 +381,18 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
} }
SG(request_info).query_string = s; SG(request_info).query_string = s;
} }
if (!request_info.filename && argc > optind) if (!SG(request_info).path_translated && argc > optind)
request_info.filename = argv[optind]; SG(request_info).path_translated = argv[optind];
} }
/* If for some reason the CGI interface is not setting the /* If for some reason the CGI interface is not setting the
PATH_TRANSLATED correctly, request_info.filename is NULL. PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL.
We still call php3_fopen_for_parser, because if you set doc_root We still call php3_fopen_for_parser, because if you set doc_root
or user_dir configuration directives, PATH_INFO is used to construct or user_dir configuration directives, PATH_INFO is used to construct
the filename as a side effect of php3_fopen_for_parser. the filename as a side effect of php3_fopen_for_parser.
*/ */
if (cgi || request_info.filename) { if (cgi || SG(request_info).path_translated) {
file_handle.filename = request_info.filename;
file_handle.handle.fp = php3_fopen_for_parser(); file_handle.handle.fp = php3_fopen_for_parser();
SG(request_info).path_translated = file_handle.filename; file_handle.filename = SG(request_info).path_translated;
} }
if (cgi && !file_handle.handle.fp) { if (cgi && !file_handle.handle.fp) {

View file

@ -78,7 +78,7 @@ static void _php3_statpage(void)
page_mtime = r->finfo.st_mtime; page_mtime = r->finfo.st_mtime;
#else #else
if (page_uid == -1) { if (page_uid == -1) {
path = request_info.filename; path = SG(request_info).path_translated;
if (path != NULL) { if (path != NULL) {
if (stat(path, &sb) == -1) { if (stat(path, &sb) == -1) {
php3_error(E_WARNING, "Unable to find file: '%s'", path); php3_error(E_WARNING, "Unable to find file: '%s'", path);

View file

@ -228,7 +228,7 @@ PHPAPI FILE *php3_fopen_for_parser(void)
PLS_FETCH(); PLS_FETCH();
SLS_FETCH(); SLS_FETCH();
fn = request_info.filename; fn = SG(request_info).path_translated;
path_info = SG(request_info).request_uri; path_info = SG(request_info).request_uri;
#if HAVE_PWD_H #if HAVE_PWD_H
if (PG(user_dir) && *PG(user_dir) if (PG(user_dir) && *PG(user_dir)
@ -256,8 +256,8 @@ PHPAPI FILE *php3_fopen_for_parser(void)
strcat(fn, PG(user_dir)); /* safe */ strcat(fn, PG(user_dir)); /* safe */
strcat(fn, "/"); /* safe */ strcat(fn, "/"); /* safe */
strcat(fn, s + 1); /* safe (shorter than path_info) */ strcat(fn, s + 1); /* safe (shorter than path_info) */
STR_FREE(request_info.filename); STR_FREE(SG(request_info).path_translated);
request_info.filename = fn; SG(request_info).path_translated = fn;
} }
} }
} }
@ -279,17 +279,17 @@ PHPAPI FILE *php3_fopen_for_parser(void)
if ('/' == path_info[0]) if ('/' == path_info[0])
l--; l--;
strcpy(fn + l, path_info); strcpy(fn + l, path_info);
STR_FREE(request_info.filename); STR_FREE(SG(request_info).path_translated);
request_info.filename = fn; SG(request_info).path_translated = fn;
} }
} /* if doc_root && path_info */ } /* if doc_root && path_info */
if (!fn) { if (!fn) {
/* we have to free request_info.filename here because /* we have to free SG(request_info).path_translated here because
php3_destroy_request_info assumes that it will get php3_destroy_request_info assumes that it will get
freed when the include_names hash is emptied, but freed when the include_names hash is emptied, but
we're not adding it in this case */ we're not adding it in this case */
STR_FREE(request_info.filename); STR_FREE(SG(request_info).path_translated);
request_info.filename = NULL; SG(request_info).path_translated = NULL;
return NULL; return NULL;
} }
fp = fopen(fn, "r"); fp = fopen(fn, "r");
@ -301,7 +301,7 @@ PHPAPI FILE *php3_fopen_for_parser(void)
} }
if (!fp) { if (!fp) {
php3_error(E_CORE_ERROR, "Unable to open %s", fn); php3_error(E_CORE_ERROR, "Unable to open %s", fn);
STR_FREE(request_info.filename); /* for same reason as above */ STR_FREE(SG(request_info).path_translated); /* for same reason as above */
return NULL; return NULL;
} }
@ -311,6 +311,7 @@ PHPAPI FILE *php3_fopen_for_parser(void)
chdir(temp); chdir(temp);
} }
efree(temp); efree(temp);
SG(request_info).path_translated = fn;
return fp; return fp;
} }

View file

@ -136,7 +136,7 @@ PHPAPI char *_php3_get_current_user()
USE_SAPI is defined, because cgi will also be USE_SAPI is defined, because cgi will also be
interfaced in USE_SAPI */ interfaced in USE_SAPI */
#if CGI_BINARY || USE_SAPI || FHTTPD #if CGI_BINARY || USE_SAPI || FHTTPD
if (!request_info.filename || (stat(request_info.filename,&statbuf)==-1)) { if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated,&statbuf)==-1)) {
return empty_string; return empty_string;
} }
uid = statbuf.st_uid; uid = statbuf.st_uid;

View file

@ -71,12 +71,6 @@ int php3_init_request_info(void *conf)
} else { } else {
request_info.filename = NULL; request_info.filename = NULL;
} }
#else
if (SG(request_info).path_translated) {
request_info.filename = estrdup(SG(request_info).path_translated);
} else {
request_info.filename = NULL;
}
#endif #endif
return SUCCESS; return SUCCESS;
} }

View file

@ -31,7 +31,6 @@
#define _REQUEST_INFO_H_ #define _REQUEST_INFO_H_
typedef struct { typedef struct {
char *filename;
char *script_name; char *script_name;
char *current_user; char *current_user;
int current_user_length; int current_user_length;