From 0eb1498fa865601db3c61c77513046c3eba79d39 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Fri, 28 May 1999 22:41:48 +0000 Subject: [PATCH] * Get Apache module to compile again with the regex stuff. * Get Apache to propertly work with POST, and some SAPI fixes --- configure.in.in | 14 +++++++------- ext/pcre/config.m4 | 4 ++-- ext/pcre/config0.m4 | 4 ++-- main/SAPI.c | 11 ++++++++++- main/rfc1867.c | 3 +++ mod_php4.c | 9 ++++++++- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/configure.in.in b/configure.in.in index 29b474ef8b..89b3414e48 100644 --- a/configure.in.in +++ b/configure.in.in @@ -298,6 +298,12 @@ fi divert(2) +abs_srcdir=`(cd $srcdir; pwd)` +abs_builddir=`pwd` +AC_SUBST(abs_srcdir) +AC_SUBST(abs_builddir) + +AC_MSG_CHECKING(for Apache module support via DSO through APACI) AC_MSG_CHECKING(whether to use bundled regex library) AC_ARG_WITH(system-regex, [ --with-system-regex Do not use the bundled regex library], @@ -308,7 +314,7 @@ AC_ARG_WITH(system-regex, AC_DEFINE(REGEX,0) ],[ REGEX_LIB=regex/libregex.a - EXTRA_LIBS="-Lregex -lregex $EXTRA_LIBS" + EXTRA_LIBS="-L$abs_builddir/regex -lregex $EXTRA_LIBS" HSREGEX=yes AC_MSG_RESULT(yes) AC_DEFINE(HSREGEX) @@ -354,12 +360,6 @@ AC_ARG_WITH(apxs, APACHE_INSTALL_FILES="$srcdir/mod_php4.* libphp4.module" -abs_srcdir=`(cd $srcdir; pwd)` -abs_builddir=`pwd` -AC_SUBST(abs_srcdir) -AC_SUBST(abs_builddir) - -AC_MSG_CHECKING(for Apache module support via DSO through APACI) AC_ARG_WITH(shared-apache, [ --with-shared-apache[=DIR] Build shared Apache module. DIR is the top-level Apache build directory, defaults to /usr/local/etc/httpd. diff --git a/ext/pcre/config.m4 b/ext/pcre/config.m4 index 2f25c86803..e2a903178f 100644 --- a/ext/pcre/config.m4 +++ b/ext/pcre/config.m4 @@ -8,7 +8,7 @@ AC_MSG_CHECKING(whether to include PCRE support) AC_ARG_WITH(pcre-regex, [ --with-pcre-regex[=DIR] Include Perl Compatible Regular Expressions support],[ if test "$withval" = "yes"; then - EXTRA_LIBS="-Lext/pcre/pcrelib -lpcre $EXTRA_LIBS" + EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS" PCRE_SUBDIR="pcrelib" AC_DEFINE(HAVE_PCRE, 1) AC_MSG_RESULT(yes) @@ -17,7 +17,7 @@ AC_ARG_WITH(pcre-regex, AC_MSG_RESULT(no) fi ],[ - EXTRA_LIBS="-Lext/pcre/pcrelib -lpcre $EXTRA_LIBS" + EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS" PCRE_SUBDIR="pcrelib" AC_DEFINE(HAVE_PCRE, 1) AC_MSG_RESULT(yes) diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4 index 2f25c86803..e2a903178f 100644 --- a/ext/pcre/config0.m4 +++ b/ext/pcre/config0.m4 @@ -8,7 +8,7 @@ AC_MSG_CHECKING(whether to include PCRE support) AC_ARG_WITH(pcre-regex, [ --with-pcre-regex[=DIR] Include Perl Compatible Regular Expressions support],[ if test "$withval" = "yes"; then - EXTRA_LIBS="-Lext/pcre/pcrelib -lpcre $EXTRA_LIBS" + EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS" PCRE_SUBDIR="pcrelib" AC_DEFINE(HAVE_PCRE, 1) AC_MSG_RESULT(yes) @@ -17,7 +17,7 @@ AC_ARG_WITH(pcre-regex, AC_MSG_RESULT(no) fi ],[ - EXTRA_LIBS="-Lext/pcre/pcrelib -lpcre $EXTRA_LIBS" + EXTRA_LIBS="-L$abs_builddir/ext/pcre/pcrelib -lpcre $EXTRA_LIBS" PCRE_SUBDIR="pcrelib" AC_DEFINE(HAVE_PCRE, 1) AC_MSG_RESULT(yes) diff --git a/main/SAPI.c b/main/SAPI.c index 97af485ce9..5712113c96 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -74,6 +74,12 @@ SAPI_API void sapi_startup(sapi_module_struct *sf) } +SAPI_API void sapi_shutdown() +{ + zend_hash_destroy(&known_post_content_types); +} + + static void sapi_free_header(sapi_header_struct *sapi_header) { efree(sapi_header->header); @@ -167,6 +173,9 @@ SAPI_API void sapi_activate(SLS_D) if (SG(server_context)) { if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "POST")) { + if (!SG(request_info).content_type) { + sapi_module.sapi_error(E_COMPILE_ERROR, "No content-type in POST request"); + } sapi_read_post_data(SLS_C); } SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C); @@ -291,4 +300,4 @@ SAPI_API int sapi_register_post_reader(sapi_post_content_type_reader *post_conte SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_content_type_reader) { zend_hash_del(&known_post_content_types, post_content_type_reader->content_type, post_content_type_reader->content_type_len+1); -} \ No newline at end of file +} diff --git a/main/rfc1867.c b/main/rfc1867.c index aba13d1b60..f7eea421f1 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -7,6 +7,9 @@ SAPI_POST_READER_FUNC(rfc1867_post_reader) char input_buffer[FILE_UPLOAD_INPUT_BUFFER_SIZE]; uint read_bytes; + sapi_module.sapi_error(E_COMPILE_ERROR, "File upload is not yet supported"); + return; + boundary = strstr(content_type_dup, "boundary"); if (!boundary || !(boundary=strchr(boundary, '='))) { sapi_module.sapi_error(E_COMPILE_ERROR, "Missing boundary in multipart/form-data POST data"); diff --git a/mod_php4.c b/mod_php4.c index 6adee9f3c5..73c27ba717 100644 --- a/mod_php4.c +++ b/mod_php4.c @@ -208,7 +208,9 @@ static void init_request_info(SLS_D) SG(request_info).path_translated = r->filename; SG(request_info).request_uri = r->uri; SG(request_info).request_method = (char *)r->method; + printf("Obtaining content type...\n"); SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE"); + printf("Obtained content type: %s\n", SG(request_info).content_type); SG(request_info).content_length = (content_length ? atoi(content_length) : 0); if (r->headers_in) { @@ -238,6 +240,9 @@ int send_php(request_rec *r, int display_source_mode, char *filename) int fd, retval; SLS_FETCH(); + if (setjmp(EG(bailout))!=0) { + return OK; + } /* We don't accept OPTIONS requests, but take everything else */ if (r->method_number == M_OPTIONS) { r->allowed |= (1 << METHODS) - 1; @@ -291,12 +296,13 @@ int send_php(request_rec *r, int display_source_mode, char *filename) hard_timeout("send", r); SG(server_context) = r; - init_request_info(SLS_C); php_save_umask(); chdir_file(filename); add_common_vars(r); add_cgi_vars(r); + + init_request_info(SLS_C); apache_php_module_main(r, fd, display_source_mode SLS_CC); /* Done, restore umask, turn off timeout, close file and return */ @@ -382,6 +388,7 @@ int php_xbithack_handler(request_rec * r) void php_init_handler(server_rec *s, pool *p) { register_cleanup(p, NULL, php_module_shutdown, php_module_shutdown_for_exec); + sapi_startup(&sapi_module); php_module_startup(&sapi_module); #if MODULE_MAGIC_NUMBER >= 19980527 ap_add_version_component("PHP/" PHP_VERSION); -- 2.50.1