processing is completed, avoiding orphaned callback pointers.
[Brett Gervasoni <brettg senseofsecurity.com>, Jeff Trawick]
+ *) core: Introduce the IncludeStrict directive, which explicitly fails
+ server startup if no files or directories match a wildcard path.
+ [Graham Leggett]
+
*) htcacheclean: Report additional statistics about entries deleted.
PR 48944. [Mark Drayton mark markdrayton.info]
<name>Include</name>
<description>Includes other configuration files from within
the server configuration files</description>
-<syntax>Include <var>file-path</var>|<var>directory-path</var></syntax>
+<syntax>Include <var>file-path</var>|<var>directory-path</var>|
+<var>wildcard</var></syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context>
</contextlist>
for placeholder files to exist so that at least one file or directory is
found by the wildcard.</p>
+ <p>Under certain circumstances, it may be required for the server to fail
+ explicitly when no files or directories match a specific wildcard. In these
+ cases, use the <directive module="code">IncludeStrict</directive>
+ directive instead.</p>
+
<p>The file path specified may be an absolute path, or may be relative
to the <directive module="core">ServerRoot</directive> directory.</p>
<seealso><program>apachectl</program></seealso>
</directivesynopsis>
+<directivesynopsis>
+<name>IncludeStrict</name>
+<description>Includes other configuration files from within the server
+configuration files, throwing an error if no files or directories match
+a wildcard
+</description>
+<syntax>IncludeStrict <var>file-path</var>|<var>directory-path</var>|
+<var>wildcard</var></syntax>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context>
+</contextlist>
+<compatibility>Available in 2.3.6 and later</compatibility>
+
+<usage>
+ <p>This directive allows inclusion of other configuration files
+ from within the server configuration files.</p>
+
+ <p>It is functionally equivalent to the
+ <directive module="core">Include</directive> directive, with the additional
+ restriction that any wildcards are required to match at least one file or
+ directory.</p>
+
+ <p>The file path specified may be an absolute path, or may be relative
+ to the <directive module="core">ServerRoot</directive> directory.</p>
+
+ <p>Example:</p>
+
+ <p>The server will fail to load if the wildcard path
+ <var>/usr/local/apache2/conf/vhosts/*.conf</var> does not match at least
+ one file or directory.</p>
+
+ <example>
+ IncludeStrict /usr/local/apache2/conf/ssl.conf<br />
+ IncludeStrict /usr/local/apache2/conf/vhosts/*.conf
+ </example>
+
+</usage>
+
+<seealso><program>apachectl</program></seealso>
+</directivesynopsis>
+
<directivesynopsis>
<name>KeepAlive</name>
<description>Enables HTTP persistent connections</description>
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp,
- unsigned depth)
+ unsigned depth,
+ int strict)
{
cmd_parms parms;
ap_configfile_t *cfp;
fnew = &((fnames *) candidates->elts)[current];
error = process_resource_config_nofnmatch(s, fnew->fname,
conftree, p, ptemp,
- depth);
+ depth, strict);
if (error) {
return error;
}
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp,
- unsigned depth)
+ unsigned depth,
+ int strict)
{
const char *rest;
apr_status_t rv;
if (!rest) {
return process_resource_config_nofnmatch(s, path,
conftree, p,
- ptemp, 0);
+ ptemp, 0, strict);
}
else {
return process_resource_config_fnmatch(s, path, rest,
conftree, p,
- ptemp, 0);
+ ptemp, 0, strict);
}
}
if (!rest) {
error = process_resource_config_nofnmatch(s, fnew->fname,
conftree, p,
- ptemp, 0);
+ ptemp, 0, strict);
}
else {
error = process_resource_config_fnmatch(s, fnew->fname, rest,
conftree, p,
- ptemp, 0);
+ ptemp, 0, strict);
}
if (error) {
return error;
}
}
}
+ else if (strict) {
+ return apr_psprintf(p, "No matches for the wildcard '%s' in %s",
+ fname, path);
+ }
return NULL;
}
-AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
- const char *fname,
- ap_directive_t **conftree,
- apr_pool_t *p,
- apr_pool_t *ptemp)
+AP_DECLARE(const char *) ap_process_resource_config_ex(server_rec *s,
+ const char *fname,
+ ap_directive_t **conftree,
+ apr_pool_t *p,
+ apr_pool_t *ptemp,
+ int strict)
{
/* XXX: lstat() won't work on the wildcard pattern...
*/
if (!apr_fnmatch_test(fname)) {
return process_resource_config_nofnmatch(s, fname, conftree, p, ptemp,
- 0);
+ 0, strict);
}
else {
apr_status_t status;
/* walk the filepath */
return process_resource_config_fnmatch(s, rootpath, filepath, conftree, p, ptemp,
- 0);
+ 0, strict);
}
return NULL;
}
+AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
+ const char *fname,
+ ap_directive_t **conftree,
+ apr_pool_t *p,
+ apr_pool_t *ptemp)
+{
+ return ap_process_resource_config_ex(s, fname, conftree, p, ptemp, 0);
+}
+
AP_DECLARE(int) ap_process_config_tree(server_rec *s,
ap_directive_t *conftree,
apr_pool_t *p,
return NULL;
}
-
static const char *include_config (cmd_parms *cmd, void *dummy,
- const char *name)
+ const char *name, int strict)
{
ap_directive_t *conftree = NULL;
const char* conffile, *error;
name, NULL);
}
- error = ap_process_resource_config(cmd->server, conffile,
- &conftree, cmd->pool, cmd->temp_pool);
+ error = ap_process_resource_config_ex(cmd->server, conffile,
+ &conftree, cmd->pool, cmd->temp_pool, strict);
if (error) {
*recursion = 0;
return error;
return NULL;
}
+static const char *include_regular_config(cmd_parms *cmd, void *dummy,
+ const char *name)
+{
+ return include_config(cmd, dummy, name, 0);
+}
+
+static const char *include_strict_config(cmd_parms *cmd, void *dummy,
+ const char *name)
+{
+ return include_config(cmd, dummy, name, 1);
+}
+
static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg)
{
char *str;
"Whether to use the physical Port when constructing URLs"),
/* TODO: RlimitFoo should all be part of mod_cgi, not in the core */
/* TODO: ListenBacklog in MPM */
-AP_INIT_TAKE1("Include", include_config, NULL,
+AP_INIT_TAKE1("Include", include_regular_config, NULL,
+ (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
+ "Name of the config file to be included, ignore wildcards with no match"),
+AP_INIT_TAKE1("IncludeStrict", include_strict_config, NULL,
(RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
- "Name of the config file to be included"),
+ "Name of the config file to be included, fail if wildcards don't match"),
AP_INIT_TAKE1("LogLevel", set_loglevel, NULL, RSRC_CONF,
"Level of verbosity in error logging"),
AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,