Description: silently ignore a not existent file path with IncludeOptional
 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.
Origin: backport, https://github.com/apache/httpd/commit/a17ce7dd5e6277867ca48659f70c4bb8a11add56
Bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=57585
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1766186
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=878920
Last-Update: 2018-06-07

--- a/server/config.c
+++ b/server/config.c
@@ -1951,6 +1951,15 @@
 
         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);
 }
@@ -2001,6 +2010,12 @@
      */
     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);
     }
--- a/docs/manual/mod/core.html.en
+++ b/docs/manual/mod/core.html.en
@@ -2383,10 +2383,10 @@
 </table>
     <p>This directive allows inclusion of other configuration files
     from within the server configuration files. It works identically to the
-    <code class="directive"><a href="#include">Include</a></code> directive, with the
-    exception that if wildcards do not match any file or directory, the
-    <code class="directive"><a href="#includeoptional">IncludeOptional</a></code> directive will be
-    silently ignored instead of causing an error.</p>
+    <code class="directive"><a href="#include">Include</a></code> 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>
 
 <h3>See also</h3>
 <ul>
