* 20100208.0 (2.3.6-dev) ap_socache_provider_t API changes to store and iterate
* 20100208.1 (2.3.6-dev) Added forward member to proxy_conn_rec
* 20100208.2 (2.3.7-dev) Added ap_log_command_line().
- * 20100223.1 (2.3.7-dev) LDAP client_certs per-server moved to per-dir
- *
+ * 20100208.3 (2.3.7-dev) LDAP client_certs per-server moved to per-dir
+ * 20100208.4 (2.3.7-dev) Added ap_process_fnmatch_configs().
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20100223
+#define MODULE_MAGIC_NUMBER_MAJOR 20100208
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
TAKE_ARGV /**< an argc and argv are passed */
};
-enum strict_how {
- AP_OPTIONAL, /* directory and file wildcards succeed on no-match */
- AP_MIXED, /* directory wildcards fail, file wildcards succeed on no match */
- AP_STRICT /* directory and file wildcards fail on no-match */
-};
-
/**
* This structure is passed to a command which is being invoked,
* to carry a large variety of miscellaneous data which is all of
server_rec **ps);
/**
- * Process the config file for Apache
+ * Process a config file for Apache
* @param s The server rec to use for the command parms
* @param fname The name of the config file
* @param conftree The root node of the created config tree
* @param p Pool for general allocation
* @param ptemp Pool for temporary allocation
- * @param strict Whether a no-match wildcard should be fatal
*/
-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,
- enum strict_how strict);
+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);
/**
- * Process the config file for Apache
+ * Process all matching files as Apache configs
* @param s The server rec to use for the command parms
- * @param fname The name of the config file
+ * @param fname The filename pattern of the config file
* @param conftree The root node of the created config tree
* @param p Pool for general allocation
* @param ptemp Pool for temporary allocation
+ * @param optional Whether a no-match wildcard is allowed
+ * @see apr_fnmatch for pattern handling
*/
-AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
+AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
- apr_pool_t *ptemp);
+ apr_pool_t *ptemp,
+ int optional);
/**
* Process all directives in the config tree
return strcmp(f1->fname,f2->fname);
}
+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_configfile_t *cfp;
+ cmd_parms parms;
+ apr_status_t rv;
+ const char *error;
+
+ parms = default_parms;
+ parms.pool = p;
+ parms.temp_pool = ptemp;
+ parms.server = s;
+ parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
+ parms.override_opts = OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
+
+ rv = ap_pcfg_openfile(&cfp, p, fname);
+ if (rv != APR_SUCCESS) {
+ char errmsg[120];
+ return apr_psprintf(p, "Could not open configuration file %s: %s",
+ fname, apr_strerror(rv, errmsg, sizeof errmsg));
+ }
+
+ parms.config_file = cfp;
+ error = ap_build_config(&parms, p, ptemp, conftree);
+ ap_cfg_closefile(cfp);
+
+ if (error) {
+ return apr_psprintf(p, "Syntax error on line %d of %s: %s",
+ parms.err_directive->line_num,
+ parms.err_directive->filename, error);
+ }
+
+ return NULL;
+}
+
static const char *process_resource_config_nofnmatch(server_rec *s,
const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp,
unsigned depth,
- enum strict_how strict)
+ int optional)
{
- cmd_parms parms;
- ap_configfile_t *cfp;
const char *error;
apr_status_t rv;
fnew = &((fnames *) candidates->elts)[current];
error = process_resource_config_nofnmatch(s, fnew->fname,
conftree, p, ptemp,
- depth, strict);
+ depth, optional);
if (error) {
return error;
}
return NULL;
}
- /* GCC's initialization extensions are soooo nice here... */
- parms = default_parms;
- parms.pool = p;
- parms.temp_pool = ptemp;
- parms.server = s;
- parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
- parms.override_opts = OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
-
- rv = ap_pcfg_openfile(&cfp, p, fname);
- if (rv != APR_SUCCESS) {
- char errmsg[120];
- return apr_psprintf(p, "Could not open configuration file %s: %s",
- fname, apr_strerror(rv, errmsg, sizeof errmsg));
- }
-
- parms.config_file = cfp;
- error = ap_build_config(&parms, p, ptemp, conftree);
- ap_cfg_closefile(cfp);
-
- if (error) {
- return apr_psprintf(p, "Syntax error on line %d of %s: %s",
- parms.err_directive->line_num,
- parms.err_directive->filename, error);
- }
-
- return NULL;
+ return ap_process_resource_config(s, fname, conftree, p, ptemp);
}
static const char *process_resource_config_fnmatch(server_rec *s,
apr_pool_t *p,
apr_pool_t *ptemp,
unsigned depth,
- enum strict_how strict)
+ int optional)
{
const char *rest;
apr_status_t rv;
if (!rest) {
return process_resource_config_nofnmatch(s, path,
conftree, p,
- ptemp, 0, strict);
+ ptemp, 0, optional);
}
else {
return process_resource_config_fnmatch(s, path, rest,
conftree, p,
- ptemp, 0, strict);
+ ptemp, 0, optional);
}
}
if (!rest) {
error = process_resource_config_nofnmatch(s, fnew->fname,
conftree, p,
- ptemp, 0, strict);
+ ptemp, 0, optional);
}
else {
error = process_resource_config_fnmatch(s, fnew->fname, rest,
conftree, p,
- ptemp, 0, strict);
+ ptemp, 0, optional);
}
if (error) {
return error;
}
else {
- /* Support for the three states of strictness:
- *
- * AP_OPTIONAL - directory and file wildcards succeed on no-match, we don't
- * need to do anything here for this case.
- * AP_MIXED - directory wildcards fail on no match, file wildcards succeed
- * on no match. Use rest to tell between the two.
- * AP_STRICT - both directory and file wildcards fail on no-match.
- */
- if (AP_STRICT == strict) {
- return apr_psprintf(p, "No matches for the wildcard '%s' in '%s' with "
- "strict wildcard matching, failing", fname, path);
- }
- else if (AP_MIXED == strict && rest) {
+ if (!optional) {
return apr_psprintf(p, "No matches for the wildcard '%s' in '%s', failing "
- "(use Include optional if required)", fname, path);
+ "(use IncludeOptional if required)", fname, path);
}
}
return NULL;
}
-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,
- enum strict_how strict)
+AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
+ const char *fname,
+ ap_directive_t **conftree,
+ apr_pool_t *p,
+ apr_pool_t *ptemp,
+ int optional)
{
/* 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, strict);
+ return ap_process_resource_config(s, fname, conftree, p, ptemp);
}
else {
apr_status_t status;
/* walk the filepath */
return process_resource_config_fnmatch(s, rootpath, filepath, conftree, p, ptemp,
- 0, strict);
+ 0, optional);
}
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, AP_MIXED);
-}
-
AP_DECLARE(int) ap_process_config_tree(server_rec *s,
ap_directive_t *conftree,
apr_pool_t *p,
}
static const char *include_config (cmd_parms *cmd, void *dummy,
- const char *arg1, const char *arg2)
+ const char *name)
{
ap_directive_t *conftree = NULL;
- const char *name;
- enum strict_how strict;
const char *conffile, *error;
unsigned *recursion;
+ int optional = (int)cmd->cmd->cmd_data;
void *data;
- if (arg2) {
- name = arg2;
- if (!strcmp(arg1, "optional")) {
- strict = AP_OPTIONAL;
- }
- else if (!strcmp(arg1, "strict")) {
- strict = AP_STRICT;
- }
- else {
- return apr_pstrcat(cmd->pool, "Invalid Include modifier '",
- arg1, "', should be 'optional' or 'strict'", NULL);
- }
- }
- else {
- name = arg1;
- strict = AP_MIXED;
- }
-
apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool);
if (data) {
recursion = data;
if (++*recursion > AP_MAX_INCLUDE_DEPTH) {
*recursion = 0;
- return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u. "
- "You have probably a recursion somewhere.",
+ return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u, "
+ "There appears to be a recursion.",
AP_MAX_INCLUDE_DEPTH);
}
name, NULL);
}
- error = ap_process_resource_config_ex(cmd->server, conffile,
- &conftree, cmd->pool, cmd->temp_pool, strict);
+ error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree,
+ cmd->pool, cmd->temp_pool,
+ optional);
if (error) {
*recursion = 0;
return error;
"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_TAKE12("Include", include_config, NULL,
+AP_INIT_TAKE1("Include", include_config, NULL,
+ (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
+ "Name(s) of the config file(s) to be included; fails if the wildcard does "
+ "not match at least one file"),
+AP_INIT_TAKE1("IncludeOptional", include_config, (void*)1,
(RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
- "Name of the config file to be included, ignore file wildcards with no "
- "matching files, fail directory wildcards with no matching directories"),
+ "Name or pattern of the config file(s) to be included; ignored if the file "
+ "does not exist or the pattern does not match any files"),
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,