You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2009/04/17 15:42:03 UTC

svn commit: r765999 - in /httpd/httpd/branches/2.2.x: ./ STATUS docs/ docs/conf/mime.types modules/metadata/mod_mime_magic.c support/ab.c support/suexec.c

Author: jim
Date: Fri Apr 17 13:42:03 2009
New Revision: 765999

URL: http://svn.apache.org/viewvc?rev=765999&view=rev
Log:
Merge r756671, r756675, r756678, r756683 from trunk:

Creation of external gzip process fails, if we
try to set the working directory to r->filename.
Use ap_make_dirstr_parent() instead, like in all
other similar places.


Creating the external gzip process fails, because we
call execve() with "gzip" without full path.
Let's look for it in the PATH instead and drop the
passing of the environment. There seems to be no
reason why gzip should need the httpd environment.


Set the content encoding for compressed content
even if we can't detect the content type of the
uncompressed content.


When trying to detect the content type of the
uncompressed content it is often not enough
to read the same number of bytes, we already
read compressed. Since uncompress() allocates a
new buffer, we can increase the number of bytes
to read to the same size, we use in the case,
where the content isn't compressed.

Furthermore zero-terminate the read data to keep
assumptions consistent with the uncompressed case.

Submitted by: rjung
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.2.x/   (props changed)
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/docs/   (props changed)
    httpd/httpd/branches/2.2.x/docs/conf/mime.types   (props changed)
    httpd/httpd/branches/2.2.x/modules/metadata/mod_mime_magic.c
    httpd/httpd/branches/2.2.x/support/ab.c   (props changed)
    httpd/httpd/branches/2.2.x/support/suexec.c   (props changed)

Propchange: httpd/httpd/branches/2.2.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:42:03 2009
@@ -1 +1 @@
-/httpd/httpd/trunk:451572,611483,639005,639010,647395,657354,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,761329
+/httpd/httpd/trunk:451572,611483,639005,639010,647395,657354,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,756671,756675,756678,756683,761329

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=765999&r1=765998&r2=765999&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Fri Apr 17 13:42:03 2009
@@ -95,25 +95,6 @@
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
- * mod_mime_magic: For compressed content the module sets the
-   content encoding header and also tries to determine the
-   uncompressed content type by using an external gzip.
-   Several bugs break this functionality:
-   - Starting gzip doesn't work because an invalid working
-     directory is used and neither the full path name for gzip
-     nor the PATH variable is used.
-   - When gzip works, but cannot detect the content type, then
-     content encoding is also not set.
-   - Too few bytes are uncompressed so often the content type
-     can not be determined.
-   Patches in trunk (separated to make review easier):
-     http://svn.apache.org/viewvc?rev=756671&view=rev (working dir)
-     http://svn.apache.org/viewvc?rev=756675&view=rev (use PATH)
-     http://svn.apache.org/viewvc?rev=756678&view=rev (content encoding)
-     http://svn.apache.org/viewvc?rev=756683&view=rev (read more bytes)
-   Those patches apply to 2.2.x as well.
-   +1: rjung, rpluem, jim
-
  * mod_substitute: Avoid endless loops in substitution.
    Trunk version of patch:
       http://svn.apache.org/viewvc?rev=755190&view=rev

Propchange: httpd/httpd/branches/2.2.x/docs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:42:03 2009
@@ -1 +1 @@
-/httpd/httpd/trunk/docs:451572,611483,639005,639010,647395,657354,657459,660461,660566,664330,675610,678761,681190,682369,683626,684351,685112,686549,686805,686809,687099,687754,692325,693120,693392,693727-693728,696006,697093,703441,703997,706318,707163,708902,711421,719357,720250,726109,728015,728020,728220,729316-729317,729586,732414,732421,732451,732504,732832,733127,733134,733218-733219,733465,733467,733695,734703,734710,743589,761329
+/httpd/httpd/trunk/docs:451572,611483,639005,639010,647395,657354,657459,660461,660566,664330,675610,678761,681190,682369,683626,684351,685112,686549,686805,686809,687099,687754,692325,693120,693392,693727-693728,696006,697093,703441,703997,706318,707163,708902,711421,719357,720250,726109,728015,728020,728220,729316-729317,729586,732414,732421,732451,732504,732832,733127,733134,733218-733219,733465,733467,733695,734703,734710,743589,756671,756675,756678,756683,761329

Propchange: httpd/httpd/branches/2.2.x/docs/conf/mime.types
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:42:03 2009
@@ -1 +1 @@
-/httpd/httpd/trunk/docs/conf/mime.types:83749-721972,726109,728015,728020,728220,729316-729317,729586,732414,732421,732451,732504,732832,733127,733134,733218-733219,733465,733467,733695,734703,734710,743589,761329
+/httpd/httpd/trunk/docs/conf/mime.types:83749-721972,726109,728015,728020,728220,729316-729317,729586,732414,732421,732451,732504,732832,733127,733134,733218-733219,733465,733467,733695,734703,734710,743589,756671,756675,756678,756683,761329

Modified: httpd/httpd/branches/2.2.x/modules/metadata/mod_mime_magic.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/metadata/mod_mime_magic.c?rev=765999&r1=765998&r2=765999&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/metadata/mod_mime_magic.c (original)
+++ httpd/httpd/branches/2.2.x/modules/metadata/mod_mime_magic.c Fri Apr 17 13:42:03 2009
@@ -2099,13 +2099,15 @@
     if (i == ncompr)
         return 0;
 
-    if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
+    if ((newsize = uncompress(r, i, &newbuf, HOWMANY)) > 0) {
+        /* set encoding type in the request record */
+        r->content_encoding = compr[i].encoding;
+
+        newbuf[newsize-1] = '\0';  /* null-terminate uncompressed data */
+        /* Try to detect the content type of the uncompressed data */
         if (tryit(r, newbuf, newsize, 0) != OK) {
             return 0;
         }
-
-        /* set encoding type in the request record */
-        r->content_encoding = compr[i].encoding;
     }
     return 1;
 }
@@ -2121,7 +2123,6 @@
 {
     int rc = 1;
     const char *new_argv[4];
-    const char *const *env;
     request_rec *r = parm->r;
     apr_pool_t *child_context = cntxt;
     apr_procattr_t *procattr;
@@ -2133,13 +2134,12 @@
      * Should we create the err pipe, read it, and copy to the log?
      */
 
-    env = (const char *const *)ap_create_environment(child_context, r->subprocess_env);
-
     if ((apr_procattr_create(&procattr, child_context) != APR_SUCCESS) ||
         (apr_procattr_io_set(procattr, APR_FULL_BLOCK,
                            APR_FULL_BLOCK, APR_NO_PIPE)   != APR_SUCCESS) ||
-        (apr_procattr_dir_set(procattr, r->filename)        != APR_SUCCESS) ||
-        (apr_procattr_cmdtype_set(procattr, APR_PROGRAM)    != APR_SUCCESS)) {
+        (apr_procattr_dir_set(procattr,
+                              ap_make_dirstr_parent(r->pool, r->filename)) != APR_SUCCESS) ||
+        (apr_procattr_cmdtype_set(procattr, APR_PROGRAM_PATH) != APR_SUCCESS)) {
         /* Something bad happened, tell the world. */
         ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_ENOPROC, r,
                "couldn't setup child process: %s", r->filename);
@@ -2152,7 +2152,7 @@
 
         procnew = apr_pcalloc(child_context, sizeof(*procnew));
         rc = apr_proc_create(procnew, compr[parm->method].argv[0],
-                               new_argv, env, procattr, child_context);
+                               new_argv, NULL, procattr, child_context);
 
         if (rc != APR_SUCCESS) {
             /* Bad things happened. Everyone should have cleaned up. */
@@ -2473,5 +2473,3 @@
     mime_magic_cmds,           /* command apr_table_t */
     register_hooks              /* register hooks */
 };
-
-

Propchange: httpd/httpd/branches/2.2.x/support/ab.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:42:03 2009
@@ -1 +1 @@
-/httpd/httpd/trunk/support/ab.c:83751-655654,657354,657433,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,761329
+/httpd/httpd/trunk/support/ab.c:83751-655654,657354,657433,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,756671,756675,756678,756683,761329

Propchange: httpd/httpd/branches/2.2.x/support/suexec.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:42:03 2009
@@ -1 +1 @@
-/httpd/httpd/trunk/support/suexec.c:451572,611483,639005,639010,647395,655711,657354,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,761329
+/httpd/httpd/trunk/support/suexec.c:451572,611483,639005,639010,647395,655711,657354,657459,660461,660566,664330,678761,681190,682369,683626,685112,686805,686809,687099,687754,693120,693392,693727-693728,696006,697093,706318,707163,708902,711421,719357,720250,729316-729317,729586,732414,732504,732832,733127,733134,733218-733219,734710,743589,756671,756675,756678,756683,761329