summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2017-12-21 18:50:38 +0000
committerJim Jagielski <jim@apache.org>2017-12-21 18:50:38 +0000
commita1926e67ef860210c033401e1a44a6e4c37bd5fd (patch)
tree4bb158fb581a8a08599300e6c366e8fbb58dfe52
parentb1102a1ca550e7b35b1bd5f904f12da0b8a4ad9a (diff)
downloadhttpd-a1926e67ef860210c033401e1a44a6e4c37bd5fd.tar.gz
Merge r1814968 from trunk:
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. Submitted by: elukey Reviewed by: elukey, jim, niq git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1818964 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES3
-rw-r--r--docs/manual/mod/core.xml11
-rw-r--r--server/config.c15
3 files changed, 24 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 3a0f27bafd..95a7dda78e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ Changes with Apache 2.4.30
the workers when the latter fails to add a connection to the pollset.
[Yann Ylavic]
+ *) core: silently ignore a not existent file path when IncludeOptional
+ is used. PR 57585. [Alberto Murillo Silva <powerbsd yahoo.com>, Luca Toscano]
+
*) mod_macro: fix usability of globally defined macros in .htaccess files.
PR 57525. [Jose Kahan <jose w3.org>, Yann Ylavic]
diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml
index a1c10e7718..24401d6ef4 100644
--- a/docs/manual/mod/core.xml
+++ b/docs/manual/mod/core.xml
@@ -2404,15 +2404,16 @@ the server configuration files</description>
<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>
diff --git a/server/config.c b/server/config.c
index 983c7dfae3..30bd6d66bd 100644
--- a/server/config.c
+++ b/server/config.c
@@ -1951,6 +1951,15 @@ static const char *process_resource_config_nofnmatch(server_rec *s,
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 @@ static const char *process_resource_config_fnmatch(server_rec *s,
*/
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);
}