httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elu...@apache.org
Subject svn commit: r1814968 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/core.xml server/config.c
Date Sat, 11 Nov 2017 19:20:01 GMT
Author: elukey
Date: Sat Nov 11 19:20:01 2017
New Revision: 1814968

URL: http://svn.apache.org/viewvc?rev=1814968&view=rev
Log:
core: silently ignore a not existent file path when IncludeOptional
     is used.

In https://bz.apache.org/bugzilla/show_bug.cgi?id=57585 some use cases
were reported in which IncludeOptional seems to be too strict in its
sanity checks.

This change is a proposal to relax IncludeOptional checks to silently
fail when a file path is not existent rather than returning SyntaxError.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/core.xml
    httpd/httpd/trunk/server/config.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1814968&r1=1814967&r2=1814968&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Nov 11 19:20:01 2017
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) core: silently ignore a not existent file path when IncludeOptional
+     is used. PR 57585. [Alberto Murillo Silva <powerbsd yahoo.com>, Luca Toscano]
+
   *) mod_noloris: complete build setup.  [Rainer Jung]
 
   *) mod_md: fix static compilation.  [Rainer Jung]

Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=1814968&r1=1814967&r2=1814968&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/core.xml Sat Nov 11 19:20:01 2017
@@ -2580,15 +2580,16 @@ the server configuration files</descript
 <contextlist><context>server config</context><context>virtual host</context>
 <context>directory</context>
 </contextlist>
-<compatibility>Available in 2.3.6 and later</compatibility>
+<compatibility>Available in 2.3.6 and later. Not existent file paths without wildcards
+               do not cause SyntaxError after 2.4.30</compatibility>
 
 <usage>
     <p>This directive allows inclusion of other configuration files
     from within the server configuration files. It works identically to the
-    <directive module="core">Include</directive> directive, with the
-    exception that if wildcards do not match any file or directory, the
-    <directive module="core">IncludeOptional</directive> directive will be
-    silently ignored instead of causing an error.</p>
+    <directive module="core">Include</directive> directive, but it will be
+    silently ignored (instead of causing an error) if wildcards are used and
+    they do not match any file or directory or if a file path does not exist
+    on the file system.</p>
 </usage>
 
 <seealso><directive module="core">Include</directive></seealso>

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=1814968&r1=1814967&r2=1814968&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Sat Nov 11 19:20:01 2017
@@ -1971,6 +1971,15 @@ static const char *process_resource_conf
 
         return NULL;
     }
+    else if (optional) {
+        /* If the optinal flag is set (like for IncludeOptional) we can
+         * tolerate that no file or directory is present and bail out.
+         */
+        apr_finfo_t finfo;
+        if (apr_stat(&finfo, fname, APR_FINFO_TYPE, ptemp) != APR_SUCCESS
+            || finfo.filetype == APR_NOFILE)
+            return NULL;
+    }
 
     return ap_process_resource_config(s, fname, conftree, p, ptemp);
 }
@@ -2021,6 +2030,12 @@ static const char *process_resource_conf
      */
     rv = apr_dir_open(&dirp, path, ptemp);
     if (rv != APR_SUCCESS) {
+        /* If the directory doesn't exist and the optional flag is set
+         * there is no need to return an error.
+         */
+        if (rv == APR_ENOENT && optional) {
+            return NULL;
+        }
         return apr_psprintf(p, "Could not open config directory %s: %pm",
                             path, &rv);
     }



Mime
View raw message