#include "apr_fnmatch.h"
#include "apr_hash.h"
#include "apr_thread_proc.h" /* for RLIMIT stuff */
-#include "apr_hooks.h"
#define APR_WANT_IOVEC
#define APR_WANT_STRFUNC
#include "util_filter.h"
#include "util_ebcdic.h"
#include "util_mutex.h"
-#include "mpm.h"
+#include "util_time.h"
#include "mpm_common.h"
#include "scoreboard.h"
#include "mod_core.h"
#if defined(RLIMIT_CPU) || defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) || defined (RLIMIT_NPROC)
#include "unixd.h"
#endif
+#if APR_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
/* LimitRequestBody handling */
#define AP_LIMIT_REQ_BODY_UNSET ((apr_off_t) -1)
#define AP_MAX_INCLUDE_DEPTH (128)
#endif
+/* valid in core-conf, but not in runtime r->used_path_info */
+#define AP_ACCEPT_PATHINFO_UNSET 3
+
+#define AP_CONTENT_MD5_OFF 0
+#define AP_CONTENT_MD5_ON 1
+#define AP_CONTENT_MD5_UNSET 2
+
APR_HOOK_STRUCT(
APR_HOOK_LINK(get_mgmt_items)
)
* server operations, including options and commands which control the
* operation of other modules. Consider this the bureaucracy module.
*
- * The core module also defines handlers, etc., do handle just enough
- * to allow a server with the core module ONLY to actually serve documents
- * (though it slaps DefaultType on all of 'em); this was useful in testing,
- * but may not be worth preserving.
+ * The core module also defines handlers, etc., to handle just enough
+ * to allow a server with the core module ONLY to actually serve documents.
*
* This file could almost be mod_core.c, except for the stuff which affects
* the http_conf_globals.
*/
+/* we know core's module_index is 0 */
+#undef APLOG_MODULE_INDEX
+#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
+
/* Handles for core filters */
AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
+/* Provide ap_document_root_check storage and default value = true */
+AP_DECLARE_DATA int ap_document_root_check = 1;
+
/* magic pointer for ErrorDocument xxx "default" */
static char errordocument_default;
+static apr_array_header_t *saved_server_config_defines = NULL;
+static apr_table_t *server_config_defined_vars = NULL;
+
+AP_DECLARE_DATA int ap_main_state = AP_SQ_MS_INITIAL_STARTUP;
+AP_DECLARE_DATA int ap_run_mode = AP_SQ_RM_UNKNOWN;
+AP_DECLARE_DATA int ap_config_generation = 1;
+
static void *create_core_dir_config(apr_pool_t *a, char *dir)
{
core_dir_config *conf;
/* conf->r and conf->d[_*] are initialized by dirsection() or left NULL */
- conf->opts = dir ? OPT_UNSET : OPT_UNSET|OPT_ALL;
+ conf->opts = dir ? OPT_UNSET : OPT_UNSET|OPT_SYM_LINKS;
conf->opts_add = conf->opts_remove = OPT_NONE;
- conf->override = dir ? OR_UNSET : OR_UNSET|OR_ALL;
- conf->override_opts = OPT_UNSET | OPT_ALL | OPT_INCNOEXEC | OPT_SYM_OWNER
- | OPT_MULTI;
+ conf->override = OR_UNSET|OR_NONE;
+ conf->override_opts = OPT_UNSET | OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
- conf->content_md5 = 2;
- conf->accept_path_info = 3;
+ conf->content_md5 = AP_CONTENT_MD5_UNSET;
+ conf->accept_path_info = AP_ACCEPT_PATHINFO_UNSET;
conf->use_canonical_name = USE_CANONICAL_NAME_UNSET;
conf->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_UNSET;
conf->hostname_lookups = HOSTNAME_LOOKUP_UNSET;
-#ifdef RLIMIT_CPU
- conf->limit_cpu = NULL;
-#endif
-#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
- conf->limit_mem = NULL;
-#endif
-#ifdef RLIMIT_NPROC
- conf->limit_nproc = NULL;
-#endif
+ /*
+ * left as NULL (we use apr_pcalloc):
+ * conf->limit_cpu = NULL;
+ * conf->limit_mem = NULL;
+ * conf->limit_nproc = NULL;
+ * conf->sec_file = NULL;
+ * conf->sec_if = NULL;
+ */
conf->limit_req_body = AP_LIMIT_REQ_BODY_UNSET;
conf->limit_xml_body = AP_LIMIT_UNSET;
- conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
conf->server_signature = srv_sig_unset;
conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
/* Overriding all negotiation
+ * Set NULL by apr_pcalloc:
+ * conf->mime_type = NULL;
+ * conf->handler = NULL;
+ * conf->output_filters = NULL;
+ * conf->input_filters = NULL;
*/
- conf->mime_type = NULL;
- conf->handler = NULL;
- conf->output_filters = NULL;
- conf->input_filters = NULL;
/*
* Flag for use of inodes in ETags.
conf->enable_mmap = ENABLE_MMAP_UNSET;
conf->enable_sendfile = ENABLE_SENDFILE_UNSET;
conf->allow_encoded_slashes = 0;
+ conf->decode_encoded_slashes = 0;
return (void *)conf;
}
-/*
- * Overlay one hash table of ct_output_filters onto another
- */
-static void *merge_ct_filters(apr_pool_t *p,
- const void *key,
- apr_ssize_t klen,
- const void *overlay_val,
- const void *base_val,
- const void *data)
-{
- ap_filter_rec_t *cur;
- const ap_filter_rec_t *overlay_info = (const ap_filter_rec_t *)overlay_val;
- const ap_filter_rec_t *base_info = (const ap_filter_rec_t *)base_val;
-
- cur = NULL;
-
- while (overlay_info) {
- ap_filter_rec_t *new;
-
- new = apr_pcalloc(p, sizeof(ap_filter_rec_t));
- new->name = apr_pstrdup(p, overlay_info->name);
- new->next = cur;
- cur = new;
- overlay_info = overlay_info->next;
- }
-
- while (base_info) {
- ap_filter_rec_t *f;
- int found = 0;
-
- /* We can't have dups. */
- f = cur;
- while (f) {
- if (!strcasecmp(base_info->name, f->name)) {
- found = 1;
- break;
- }
-
- f = f->next;
- }
-
- if (!found) {
- f = apr_pcalloc(p, sizeof(ap_filter_rec_t));
- f->name = apr_pstrdup(p, base_info->name);
- f->next = cur;
- cur = f;
- }
-
- base_info = base_info->next;
- }
-
- return cur;
-}
-
static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
{
core_dir_config *base = (core_dir_config *)basev;
conf->opts_remove = (conf->opts_remove & ~new->opts_add)
| new->opts_remove;
conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
- if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) {
- conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES;
+
+ /* If Includes was enabled with exec in the base config, but
+ * was enabled without exec in the new config, then disable
+ * exec in the merged set. */
+ if (((base->opts & (OPT_INCLUDES|OPT_INC_WITH_EXEC))
+ == (OPT_INCLUDES|OPT_INC_WITH_EXEC))
+ && ((new->opts & (OPT_INCLUDES|OPT_INC_WITH_EXEC))
+ == OPT_INCLUDES)) {
+ conf->opts &= ~OPT_INC_WITH_EXEC;
}
}
else {
conf->override_opts = new->override_opts;
}
- if (new->ap_default_type) {
- conf->ap_default_type = new->ap_default_type;
- }
-
if (conf->response_code_strings == NULL) {
conf->response_code_strings = new->response_code_strings;
}
else if (new->response_code_strings != NULL) {
- /* If we merge, the merge-result must have it's own array
+ /* If we merge, the merge-result must have its own array
*/
conf->response_code_strings = apr_pmemdup(a,
base->response_code_strings,
conf->hostname_lookups = new->hostname_lookups;
}
- if ((new->content_md5 & 2) == 0) {
+ if (new->content_md5 == AP_CONTENT_MD5_UNSET) {
conf->content_md5 = new->content_md5;
}
- if (new->accept_path_info != 3) {
+ if (new->accept_path_info != AP_ACCEPT_PATHINFO_UNSET) {
conf->accept_path_info = new->accept_path_info;
}
conf->sec_file = new->sec_file;
}
else if (new->sec_file) {
- /* If we merge, the merge-result must have it's own array
+ /* If we merge, the merge-result must have its own array
*/
conf->sec_file = apr_array_append(a, base->sec_file, new->sec_file);
}
/* Otherwise we simply use the base->sec_file array
*/
+ if (!conf->sec_if) {
+ conf->sec_if = new->sec_if;
+ }
+ else if (new->sec_if) {
+ /* If we merge, the merge-result must have its own array
+ */
+ conf->sec_if = apr_array_append(a, base->sec_if, new->sec_if);
+ }
+ /* Otherwise we simply use the base->sec_if array
+ */
+
if (new->server_signature != srv_sig_unset) {
conf->server_signature = new->server_signature;
}
conf->input_filters = new->input_filters;
}
- if (conf->ct_output_filters && new->ct_output_filters) {
- conf->ct_output_filters = apr_hash_merge(a,
- new->ct_output_filters,
- conf->ct_output_filters,
- merge_ct_filters,
- NULL);
- }
- else if (new->ct_output_filters) {
- conf->ct_output_filters = apr_hash_copy(a, new->ct_output_filters);
- }
- else if (conf->ct_output_filters) {
- /* That memcpy above isn't enough. */
- conf->ct_output_filters = apr_hash_copy(a, base->ct_output_filters);
- }
-
/*
* Now merge the setting of the FileETag directive.
*/
}
conf->allow_encoded_slashes = new->allow_encoded_slashes;
+ conf->decode_encoded_slashes = new->decode_encoded_slashes;
+
+ if (new->log) {
+ if (!conf->log) {
+ conf->log = new->log;
+ }
+ else {
+ conf->log = ap_new_log_config(a, new->log);
+ ap_merge_log_config(base->log, conf->log);
+ }
+ }
return (void*)conf;
}
if (virt->gprof_dir)
conf->gprof_dir = virt->gprof_dir;
+ if (virt->error_log_format)
+ conf->error_log_format = virt->error_log_format;
+
+ if (virt->error_log_conn)
+ conf->error_log_conn = virt->error_log_conn;
+
+ if (virt->error_log_req)
+ conf->error_log_req = virt->error_log_req;
+
return conf;
}
AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
{
- core_server_config *sconf = ap_get_module_config(s->module_config,
- &core_module);
+ core_server_config *sconf = ap_get_core_module_config(s->module_config);
void **new_space = (void **)apr_array_push(sconf->sec_dir);
*new_space = dir_config;
AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config)
{
- core_server_config *sconf = ap_get_module_config(s->module_config,
- &core_module);
+ core_server_config *sconf = ap_get_core_module_config(s->module_config);
void **new_space = (void **)apr_array_push(sconf->sec_url);
*new_space = url_config;
}
-AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
+AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf,
+ void *url_config)
{
- void **new_space = (void **)apr_array_push(conf->sec_file);
+ void **new_space;
+
+ if (!conf->sec_file)
+ conf->sec_file = apr_array_make(p, 2, sizeof(ap_conf_vector_t *));
+ new_space = (void **)apr_array_push(conf->sec_file);
*new_space = url_config;
}
+AP_CORE_DECLARE(const char *) ap_add_if_conf(apr_pool_t *p,
+ core_dir_config *conf,
+ void *if_config)
+{
+ void **new_space;
+ core_dir_config *new = ap_get_module_config(if_config, &core_module);
+
+ if (!conf->sec_if) {
+ conf->sec_if = apr_array_make(p, 2, sizeof(ap_conf_vector_t *));
+ }
+ if (new->condition_ifelse & AP_CONDITION_ELSE) {
+ int have_if = 0;
+ if (conf->sec_if->nelts > 0) {
+ core_dir_config *last;
+ ap_conf_vector_t *lastelt = APR_ARRAY_IDX(conf->sec_if,
+ conf->sec_if->nelts - 1,
+ ap_conf_vector_t *);
+ last = ap_get_module_config(lastelt, &core_module);
+ if (last->condition_ifelse & AP_CONDITION_IF)
+ have_if = 1;
+ }
+ if (!have_if)
+ return "<Else> or <ElseIf> section without previous <If> or "
+ "<ElseIf> section in same scope";
+ }
+
+ new_space = (void **)apr_array_push(conf->sec_if);
+ *new_space = if_config;
+ return NULL;
+}
+
+
/* We need to do a stable sort, qsort isn't stable. So to make it stable
* we'll be maintaining the original index into the list, and using it
* as the minor key during sorting. The major key is the number of
core_dir_config *core_a;
core_dir_config *core_b;
- core_a = ap_get_module_config(a->elt, &core_module);
- core_b = ap_get_module_config(b->elt, &core_module);
+ core_a = ap_get_core_module_config(a->elt);
+ core_b = ap_get_core_module_config(b->elt);
/* a regex always sorts after a non-regex
*/
int i;
apr_pool_t *tmp;
- sconf = ap_get_module_config(s->module_config, &core_module);
+ sconf = ap_get_core_module_config(s->module_config);
sec_dir = sconf->sec_dir;
nelts = sec_dir->nelts;
elts = (ap_conf_vector_t **)sec_dir->elts;
AP_DECLARE(int) ap_allow_options(request_rec *r)
{
core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+ (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
return conf->opts;
}
AP_DECLARE(int) ap_allow_overrides(request_rec *r)
{
core_dir_config *conf;
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ conf = (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
return conf->override;
}
return SATISFY_NOSPEC;
}
-AP_DECLARE(const char *) ap_default_type(request_rec *r)
+AP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ core_server_config *sconf;
+ core_request_config *rconf = ap_get_core_module_config(r->request_config);
+ if (rconf->document_root)
+ return rconf->document_root;
+ sconf = ap_get_core_module_config(r->server->module_config);
+ return sconf->ap_document_root;
+}
- return conf->ap_default_type
- ? conf->ap_default_type
- : DEFAULT_CONTENT_TYPE;
+AP_DECLARE(const char *) ap_context_prefix(request_rec *r)
+{
+ core_request_config *conf = ap_get_core_module_config(r->request_config);
+ if (conf->context_prefix)
+ return conf->context_prefix;
+ else
+ return "";
}
-AP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
+AP_DECLARE(const char *) ap_context_document_root(request_rec *r)
{
- core_server_config *conf;
+ core_request_config *conf = ap_get_core_module_config(r->request_config);
+ if (conf->context_document_root)
+ return conf->context_document_root;
+ else
+ return ap_document_root(r);
+}
- conf = (core_server_config *)ap_get_module_config(r->server->module_config,
- &core_module);
+AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root)
+{
+ core_request_config *conf = ap_get_core_module_config(r->request_config);
+ conf->document_root = document_root;
+}
- return conf->ap_document_root;
+AP_DECLARE(void) ap_set_context_info(request_rec *r, const char *context_prefix,
+ const char *context_document_root)
+{
+ core_request_config *conf = ap_get_core_module_config(r->request_config);
+ if (context_prefix)
+ conf->context_prefix = context_prefix;
+ if (context_document_root)
+ conf->context_document_root = context_document_root;
}
/* Should probably just get rid of this... the only code that cares is
char *ap_response_code_string(request_rec *r, int error_index)
{
core_dir_config *dirconf;
- core_request_config *reqconf;
+ core_request_config *reqconf = ap_get_core_module_config(r->request_config);
/* check for string registered via ap_custom_response() first */
- reqconf = (core_request_config *)ap_get_module_config(r->request_config,
- &core_module);
if (reqconf->response_code_strings != NULL &&
reqconf->response_code_strings[error_index] != NULL) {
return reqconf->response_code_strings[error_index];
}
/* check for string specified via ErrorDocument */
- dirconf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ dirconf = ap_get_core_module_config(r->per_dir_config);
if (dirconf->response_code_strings == NULL) {
return NULL;
/* If we haven't checked the host name, and we want to */
if (dir_config) {
- hostname_lookups =
- ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
- ->hostname_lookups;
+ hostname_lookups = ((core_dir_config *)ap_get_core_module_config(dir_config))
+ ->hostname_lookups;
if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) {
hostname_lookups = HOSTNAME_LOOKUP_OFF;
core_dir_config *d;
const char *retval;
- d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ d = (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
switch (d->use_canonical_name) {
case USE_CANONICAL_NAME_ON:
* of using in a URL. If the server name is an IPv6 literal
* address, it will be returned in URL format (e.g., "[fe80::1]").
*/
-static const char *get_server_name_for_url(request_rec *r)
+AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r)
{
const char *plain_server_name = ap_get_server_name(r);
{
apr_port_t port;
core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+ (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
switch (d->use_canonical_name) {
case USE_CANONICAL_NAME_OFF:
request_rec *r)
{
unsigned port = ap_get_server_port(r);
- const char *host = get_server_name_for_url(r);
+ const char *host = ap_get_server_name_for_url(r);
if (ap_is_default_port(port, r)) {
return apr_pstrcat(p, ap_http_scheme(r), "://", host, uri, NULL);
AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r)
{
core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+ (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
if (d->limit_req_body == AP_LIMIT_REQ_BODY_UNSET) {
return AP_DEFAULT_LIMIT_REQ_BODY;
const char *arg)
{
void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
+ core_server_config *conf = ap_get_core_module_config(sconf);
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
if (err != NULL) {
return NULL;
}
+AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word)
+{
+# define SMALL_EXPANSION 5
+ struct sll {
+ struct sll *next;
+ const char *string;
+ apr_size_t len;
+ } *result, *current, sresult[SMALL_EXPANSION];
+ char *res_buf, *cp;
+ const char *s, *e, *ep;
+ unsigned spc;
+ apr_size_t outlen;
+
+ s = ap_strchr_c(word, '$');
+ if (!s) {
+ return word;
+ }
+
+ /* well, actually something to do */
+ ep = word + strlen(word);
+ spc = 0;
+ result = current = &(sresult[spc++]);
+ current->next = NULL;
+ current->string = word;
+ current->len = s - word;
+ outlen = current->len;
+
+ do {
+ /* prepare next entry */
+ if (current->len) {
+ current->next = (spc < SMALL_EXPANSION)
+ ? &(sresult[spc++])
+ : (struct sll *)apr_palloc(p,
+ sizeof(*current->next));
+ current = current->next;
+ current->next = NULL;
+ current->len = 0;
+ }
+
+ if (*s == '$') {
+ if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
+ char *name = apr_pstrndup(p, s+2, e-s-2);
+ word = NULL;
+ if (server_config_defined_vars)
+ word = apr_table_get(server_config_defined_vars, name);
+ if (!word)
+ word = getenv(name);
+ if (word) {
+ current->string = word;
+ current->len = strlen(word);
+ outlen += current->len;
+ }
+ else {
+ if (ap_strchr(name, ':') == 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
+ "Config variable ${%s} is not defined",
+ name);
+ current->string = s;
+ current->len = e - s + 1;
+ outlen += current->len;
+ }
+ s = e + 1;
+ }
+ else {
+ current->string = s++;
+ current->len = 1;
+ ++outlen;
+ }
+ }
+ else {
+ word = s;
+ s = ap_strchr_c(s, '$');
+ current->string = word;
+ current->len = s ? s - word : ep - word;
+ outlen += current->len;
+ }
+ } while (s && *s);
+
+ /* assemble result */
+ res_buf = cp = apr_palloc(p, outlen + 1);
+ do {
+ if (result->len) {
+ memcpy(cp, result->string, result->len);
+ cp += result->len;
+ }
+ result = result->next;
+ } while (result);
+ res_buf[outlen] = '\0';
+
+ return res_buf;
+}
+
+static int reset_config_defines(void *dummy)
+{
+ ap_server_config_defines = saved_server_config_defines;
+ server_config_defined_vars = NULL;
+ return OK;
+}
+
+/*
+ * Make sure we can revert the effects of Define/UnDefine when restarting.
+ * This function must be called once per loading of the config, before
+ * ap_server_config_defines is changed. This may be during reading of the
+ * config, which is even before the pre_config hook is run (due to
+ * EXEC_ON_READ for Define/UnDefine).
+ */
+static void init_config_defines(apr_pool_t *pconf)
+{
+ saved_server_config_defines = ap_server_config_defines;
+ /* Use apr_array_copy instead of apr_array_copy_hdr because it does not
+ * protect from the way unset_define removes entries.
+ */
+ ap_server_config_defines = apr_array_copy(pconf, ap_server_config_defines);
+}
static const char *set_define(cmd_parms *cmd, void *dummy,
- const char *optarg)
+ const char *name, const char *value)
{
- char **newv;
+ if (ap_strchr_c(name, ':') != NULL)
+ return "Variable name must not contain ':'";
- const char *err = ap_check_cmd_context(cmd,
- GLOBAL_ONLY);
- if (err != NULL) {
- return err;
+ if (!saved_server_config_defines)
+ init_config_defines(cmd->pool);
+ if (!ap_exists_config_define(name)) {
+ char **newv = (char **)apr_array_push(ap_server_config_defines);
+ *newv = apr_pstrdup(cmd->pool, name);
+ }
+ if (value) {
+ if (!server_config_defined_vars)
+ server_config_defined_vars = apr_table_make(cmd->pool, 5);
+ apr_table_setn(server_config_defined_vars, name, value);
+ }
+
+ return NULL;
+}
+
+static const char *unset_define(cmd_parms *cmd, void *dummy,
+ const char *name)
+{
+ int i;
+ char **defines;
+ if (ap_strchr_c(name, ':') != NULL)
+ return "Variable name must not contain ':'";
+
+ if (!saved_server_config_defines)
+ init_config_defines(cmd->pool);
+
+ defines = (char **)ap_server_config_defines->elts;
+ for (i = 0; i < ap_server_config_defines->nelts; i++) {
+ if (strcmp(defines[i], name) == 0) {
+ defines[i] = apr_array_pop(ap_server_config_defines);
+ break;
+ }
}
- newv = (char **)apr_array_push(ap_server_config_defines);
- *newv = apr_pstrdup(cmd->pool, optarg);
+ if (server_config_defined_vars) {
+ apr_table_unset(server_config_defined_vars, name);
+ }
return NULL;
}
+static const char *generate_error(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ if (!arg || !*arg) {
+ return "The Error directive was used with no message.";
+ }
+
+ if (*arg == '"' || *arg == '\'') { /* strip off quotes */
+ apr_size_t len = strlen(arg);
+ char last = *(arg + len - 1);
+
+ if (*arg == last) {
+ return apr_pstrndup(cmd->pool, arg + 1, len - 2);
+ }
+ }
+
+ return arg;
+}
+
#ifdef GPROF
static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
{
void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
+ core_server_config *conf = ap_get_core_module_config(sconf);
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
if (err != NULL) {
return err;
}
- conf->gprof_dir = apr_pstrdup(cmd->pool, arg);
+ conf->gprof_dir = arg;
return NULL;
}
#endif /*GPROF*/
const char *arg)
{
void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
+ core_server_config *conf = ap_get_core_module_config(sconf);
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
if (err != NULL) {
return err;
}
+ /* When ap_document_root_check is false; skip all the stuff below */
+ if (!ap_document_root_check) {
+ conf->ap_document_root = arg;
+ return NULL;
+ }
+
/* Make it absolute, relative to ServerRoot */
arg = ap_server_root_relative(cmd->pool, arg);
if (arg == NULL) {
return "DocumentRoot must be a directory";
}
- /* TODO: ap_configtestonly && ap_docrootcheck && */
+ /* TODO: ap_configtestonly */
if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS
|| !ap_is_directory(cmd->pool, arg)) {
AP_DECLARE(void) ap_custom_response(request_rec *r, int status,
const char *string)
{
- core_request_config *conf =
- ap_get_module_config(r->request_config, &core_module);
+ core_request_config *conf = ap_get_core_module_config(r->request_config);
int idx;
if (conf->response_code_strings == NULL) {
opt = OPT_INDEXES;
}
else if (!strcasecmp(w, "Includes")) {
- opt = OPT_INCLUDES;
+ /* If Includes is permitted, both Includes and
+ * IncludesNOEXEC may be changed. */
+ opt = (OPT_INCLUDES | OPT_INC_WITH_EXEC);
}
else if (!strcasecmp(w, "IncludesNOEXEC")) {
- opt = (OPT_INCLUDES | OPT_INCNOEXEC);
+ opt = OPT_INCLUDES;
}
else if (!strcasecmp(w, "FollowSymLinks")) {
opt = OPT_SYM_LINKS;
d->override = OR_NONE;
while (l[0]) {
- w = ap_getword_conf(cmd->pool, &l);
+ w = ap_getword_conf(cmd->temp_pool, &l);
k = w;
v = strchr(k, '=');
if (v)
set_allow_opts(cmd, &(d->override_opts), v);
else
- d->override_opts = OPT_ALL;
+ d->override_opts = OPT_SYM_LINKS;
}
else if (!strcasecmp(w, "FileInfo")) {
d->override |= OR_FILEINFO;
core_dir_config *d = d_;
allow_options_t opt;
int first = 1;
+ int merge = 0;
+ int all_none = 0;
char action;
while (l[0]) {
- char *w = ap_getword_conf(cmd->pool, &l);
+ char *w = ap_getword_conf(cmd->temp_pool, &l);
action = '\0';
if (*w == '+' || *w == '-') {
action = *(w++);
+ if (!merge && !first && !all_none) {
+ return "Either all Options must start with + or -, or no Option may.";
+ }
+ merge = 1;
}
else if (first) {
- d->opts = OPT_NONE;
- first = 0;
+ d->opts = OPT_NONE;
+ }
+ else if (merge) {
+ return "Either all Options must start with + or -, or no Option may.";
}
if (!strcasecmp(w, "Indexes")) {
opt = OPT_INDEXES;
}
else if (!strcasecmp(w, "Includes")) {
- opt = OPT_INCLUDES;
+ opt = (OPT_INCLUDES | OPT_INC_WITH_EXEC);
}
else if (!strcasecmp(w, "IncludesNOEXEC")) {
- opt = (OPT_INCLUDES | OPT_INCNOEXEC);
+ opt = OPT_INCLUDES;
}
else if (!strcasecmp(w, "FollowSymLinks")) {
opt = OPT_SYM_LINKS;
opt = OPT_MULTI|OPT_EXECCGI;
}
else if (!strcasecmp(w, "None")) {
+ if (!first) {
+ return "'Options None' must be the first Option given.";
+ }
+ else if (merge) { /* Only works since None may not follow any other option. */
+ return "You may not use 'Options +None' or 'Options -None'.";
+ }
opt = OPT_NONE;
+ all_none = 1;
}
else if (!strcasecmp(w, "All")) {
+ if (!first) {
+ return "'Options All' must be the first option given.";
+ }
+ else if (merge) { /* Only works since All may not follow any other option. */
+ return "You may not use 'Options +All' or 'Options -All'.";
+ }
opt = OPT_ALL;
+ all_none = 1;
}
else {
return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
else {
d->opts |= opt;
}
+
+ first = 0;
+ }
+
+ return NULL;
+}
+
+static const char *set_default_type(cmd_parms *cmd, void *d_,
+ const char *arg)
+{
+ if ((strcasecmp(arg, "off") != 0) && (strcasecmp(arg, "none") != 0)) {
+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
+ "Ignoring deprecated use of DefaultType in line %d of %s.",
+ cmd->directive->line_num, cmd->directive->filename);
}
return NULL;
action = '*';
bit = ETAG_UNSET;
valid = 1;
- token = ap_getword_conf(cmd->pool, &args);
+ token = ap_getword_conf(cmd->temp_pool, &args);
if ((*token == '+') || (*token == '-')) {
action = *token;
token++;
return unclosed_directive(cmd);
}
- limited_methods = apr_pstrndup(cmd->pool, arg, endp - arg);
+ limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (!limited_methods[0]) {
return missing_container_arg(cmd);
}
while (limited_methods[0]) {
- char *method = ap_getword_conf(cmd->pool, &limited_methods);
+ char *method = ap_getword_conf(cmd->temp_pool, &limited_methods);
int methnum;
/* check for builtin or module registered method number */
/* method has not been registered yet, but resorce restriction
* is always checked before method handling, so register it.
*/
- methnum = ap_method_register(cmd->pool, method);
+ methnum = ap_method_register(cmd->pool,
+ apr_pstrdup(cmd->pool, method));
}
limited |= (AP_METHOD_BIT << methnum);
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (!arg[0]) {
return missing_container_arg(cmd);
}
- if (!arg) {
- if (thiscmd->cmd_data)
- return "<DirectoryMatch > block must specify a path";
- else
- return "<Directory > block must specify a path";
- }
-
cmd->path = ap_getword_conf(cmd->pool, &arg);
cmd->override = OR_ALL|ACCESS_CONF;
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (!arg[0]) {
return missing_container_arg(cmd);
core_dir_config *conf;
ap_regex_t *r = NULL;
const command_rec *thiscmd = cmd->cmd;
- core_dir_config *c = mconfig;
ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
const char *err = ap_check_cmd_context(cmd,
NOT_IN_LOCATION | NOT_IN_LIMIT);
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (!arg[0]) {
return missing_container_arg(cmd);
conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
conf->r = r;
- ap_add_file_conf(c, new_file_conf);
+ ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
if (*arg != '\0') {
return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
return NULL;
}
+
+#define COND_IF ((void *)1)
+#define COND_ELSE ((void *)2)
+#define COND_ELSEIF ((void *)3)
+
static const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
{
const char *errmsg;
char *old_path = cmd->path;
core_dir_config *conf;
const command_rec *thiscmd = cmd->cmd;
- core_dir_config *c = mconfig;
- ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_LOCATION | NOT_IN_LIMIT);
+ ap_conf_vector_t *new_if_conf = ap_create_per_dir_config(cmd->pool);
+ const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
const char *condition;
- int expr_err = 0;
+ const char *expr_err;
if (err != NULL) {
return err;
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
- if (!arg[0]) {
- return missing_container_arg(cmd);
- }
- condition = ap_getword_conf(cmd->pool, &arg);
/* Only if not an .htaccess file */
if (!old_path) {
cmd->override = OR_ALL|ACCESS_CONF;
}
/* initialize our config and fetch it */
- conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
+ conf = ap_set_config_vectors(cmd->server, new_if_conf, cmd->path,
&core_module, cmd->pool);
- conf->condition = ap_expr_parse(cmd->pool, condition, &expr_err);
- if (expr_err) {
- return "Cannot parse condition clause";
+ if (cmd->cmd->cmd_data == COND_IF)
+ conf->condition_ifelse = AP_CONDITION_IF;
+ else if (cmd->cmd->cmd_data == COND_ELSEIF)
+ conf->condition_ifelse = AP_CONDITION_ELSEIF;
+ else if (cmd->cmd->cmd_data == COND_ELSE)
+ conf->condition_ifelse = AP_CONDITION_ELSE;
+ else
+ ap_assert(0);
+
+ if (conf->condition_ifelse == AP_CONDITION_ELSE) {
+ if (arg[0])
+ return "<Else> does not take an argument";
+ }
+ else {
+ if (!arg[0])
+ return missing_container_arg(cmd);
+ condition = ap_getword_conf(cmd->pool, &arg);
+ conf->condition = ap_expr_parse_cmd(cmd, condition, &expr_err, NULL);
+ if (expr_err)
+ return apr_psprintf(cmd->pool, "Cannot parse condition clause: %s",
+ expr_err);
+ conf->condition->module_index = APLOG_MODULE_INDEX;
}
- errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
+ errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_if_conf);
if (errmsg != NULL)
return errmsg;
conf->d_is_fnmatch = 0;
conf->r = NULL;
- ap_add_file_conf(c, new_file_conf);
+ errmsg = ap_add_if_conf(cmd->pool, (core_dir_config *)mconfig, new_if_conf);
+ if (errmsg != NULL)
+ return errmsg;
if (*arg != '\0') {
return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
return NULL;
}
-static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
+static module *find_module(server_rec *s, const char *name)
{
- const char *endp = ap_strrchr_c(arg, '>');
- int not = (arg[0] == '!');
- module *found;
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
-
- if (not) {
- arg++;
- }
-
- if (!arg[0]) {
- return missing_container_arg(cmd);
- }
-
- found = ap_find_linked_module(arg);
+ module *found = ap_find_linked_module(name);
/* search prelinked stuff */
if (!found) {
ap_module_symbol_t *current = ap_prelinked_module_symbols;
for (; current->name; ++current) {
- if (!strcmp(current->name, arg)) {
+ if (!strcmp(current->name, name)) {
found = current->modp;
break;
}
APR_RETRIEVE_OPTIONAL_FN(ap_find_loaded_module_symbol);
if (check_symbol) {
- found = check_symbol(cmd->server, arg);
+ /*
+ * There are two phases where calling ap_find_loaded_module_symbol
+ * is problematic:
+ *
+ * During reading of the config, ap_server_conf is invalid but s
+ * points to the main server config, if passed from cmd->server
+ * of an EXEC_ON_READ directive.
+ *
+ * During config parsing, s may be a virtual host that would cause
+ * a segfault in mod_so if passed to ap_find_loaded_module_symbol,
+ * because mod_so's server config for vhosts is initialized later.
+ * But ap_server_conf is already set at this time.
+ *
+ * Therefore we use s if it is not virtual and ap_server_conf if
+ * s is virtual.
+ */
+ found = check_symbol(s->is_virtual ? ap_server_conf : s, name);
}
}
+ return found;
+}
+
+
+static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+ const char *endp = ap_strrchr_c(arg, '>');
+ int not = (arg[0] == '!');
+ module *found;
+
+ if (endp == NULL) {
+ return unclosed_directive(cmd);
+ }
+
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
+
+ if (not) {
+ arg++;
+ }
+
+ if (!arg[0]) {
+ return missing_container_arg(cmd);
+ }
+
+ found = find_module(cmd->server, arg);
+
if ((!not && found) || (not && !found)) {
ap_directive_t *parent = NULL;
ap_directive_t *current = NULL;
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (arg[0] == '!') {
not = 1;
return unclosed_directive(cmd);
}
- arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
if (!arg[0]) {
return missing_container_arg(cmd);
const char *iproto, const char* iaccf)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- core_server_config *conf = ap_get_module_config(cmd->server->module_config,
- &core_module);
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
char* proto;
char* accf;
if (err != NULL) {
ap_str_tolower(proto);
accf = apr_pstrdup(cmd->pool, iaccf);
ap_str_tolower(accf);
- apr_table_set(conf->accf_map, proto, accf);
+ apr_table_setn(conf->accf_map, proto, accf);
return NULL;
}
AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s)
{
- core_server_config *conf = ap_get_module_config(s->module_config,
- &core_module);
+ core_server_config *conf = ap_get_core_module_config(s->module_config);
return conf->protocol;
}
AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto)
{
- core_server_config *conf = ap_get_module_config(s->module_config,
- &core_module);
+ core_server_config *conf = ap_get_core_module_config(s->module_config);
conf->protocol = proto;
}
const char *arg)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
- core_server_config *conf = ap_get_module_config(cmd->server->module_config,
- &core_module);
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
char* proto;
if (err != NULL) {
return err;
}
+ if (apr_fnmatch_test(arg))
+ return apr_pstrcat(cmd->temp_pool, "Invalid ServerName \"", arg,
+ "\" use ServerAlias to set multiple server names.", NULL);
+
part = ap_strstr_c(arg, "://");
if (part) {
if ((apr_filepath_merge((char**)&ap_server_root, NULL, arg,
APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)
- || !ap_is_directory(cmd->pool, ap_server_root)) {
+ || !ap_is_directory(cmd->temp_pool, ap_server_root)) {
return "ServerRoot must be a valid directory";
}
return NULL;
}
-static const char *set_allow2f(cmd_parms *cmd, void *d_, int arg)
+static const char *set_allow2f(cmd_parms *cmd, void *d_, const char *arg)
{
core_dir_config *d = d_;
- d->allow_encoded_slashes = arg != 0;
+ if (0 == strcasecmp(arg, "on")) {
+ d->allow_encoded_slashes = 1;
+ d->decode_encoded_slashes = 1; /* for compatibility with 2.0 & 2.2 */
+ } else if (0 == strcasecmp(arg, "off")) {
+ d->allow_encoded_slashes = 0;
+ d->decode_encoded_slashes = 0;
+ } else if (0 == strcasecmp(arg, "nodecode")) {
+ d->allow_encoded_slashes = 1;
+ d->decode_encoded_slashes = 0;
+ } else {
+ return apr_pstrcat(cmd->pool,
+ cmd->cmd->name, " must be On, Off, or NoDecode",
+ NULL);
+ }
return NULL;
}
{
core_dir_config *d = d_;
- d->content_md5 = arg != 0;
+ d->content_md5 = arg ? AP_CONTENT_MD5_ON : AP_CONTENT_MD5_OFF;
return NULL;
}
return NULL;
}
-
static const char *include_config (cmd_parms *cmd, void *dummy,
const char *name)
{
ap_directive_t *conftree = NULL;
- const char* conffile, *error;
+ const char *conffile, *error;
unsigned *recursion;
+ int optional = cmd->cmd->cmd_data ? 1 : 0;
void *data;
apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool);
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(cmd->server, conffile,
- &conftree, cmd->pool, cmd->temp_pool);
+ error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree,
+ cmd->pool, cmd->temp_pool,
+ optional);
if (error) {
*recursion = 0;
return error;
return NULL;
}
-static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg)
+static const char *set_loglevel(cmd_parms *cmd, void *config_, const char *arg_)
{
- char *str;
-
+ char *level_str;
+ int level;
+ module *module;
+ char *arg = apr_pstrdup(cmd->temp_pool, arg_);
+ struct ap_logconf *log;
+ const char *err;
+
+ /* XXX: what check is necessary here? */
+#if 0
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
if (err != NULL) {
return err;
}
+#endif
- if ((str = ap_getword_conf(cmd->pool, &arg))) {
- if (!strcasecmp(str, "emerg")) {
- cmd->server->loglevel = APLOG_EMERG;
- }
- else if (!strcasecmp(str, "alert")) {
- cmd->server->loglevel = APLOG_ALERT;
- }
- else if (!strcasecmp(str, "crit")) {
- cmd->server->loglevel = APLOG_CRIT;
- }
- else if (!strcasecmp(str, "error")) {
- cmd->server->loglevel = APLOG_ERR;
- }
- else if (!strcasecmp(str, "warn")) {
- cmd->server->loglevel = APLOG_WARNING;
- }
- else if (!strcasecmp(str, "notice")) {
- cmd->server->loglevel = APLOG_NOTICE;
- }
- else if (!strcasecmp(str, "info")) {
- cmd->server->loglevel = APLOG_INFO;
- }
- else if (!strcasecmp(str, "debug")) {
- cmd->server->loglevel = APLOG_DEBUG;
- }
- else {
- return "LogLevel requires level keyword: one of "
- "emerg/alert/crit/error/warn/notice/info/debug";
+ if (cmd->path) {
+ core_dir_config *dconf = config_;
+ if (!dconf->log) {
+ dconf->log = ap_new_log_config(cmd->pool, NULL);
}
+ log = dconf->log;
}
else {
- return "LogLevel requires level keyword";
+ log = &cmd->server->log;
+ }
+
+ if (arg == NULL)
+ return "LogLevel requires level keyword or module loglevel specifier";
+
+ level_str = ap_strrchr(arg, ':');
+
+ if (level_str == NULL) {
+ err = ap_parse_log_level(arg, &log->level);
+ if (err != NULL)
+ return err;
+ ap_reset_module_loglevels(log, APLOG_NO_MODULE);
+ ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
+ "Setting LogLevel for all modules to %s", arg);
+ return NULL;
+ }
+
+ *level_str++ = '\0';
+ if (!*level_str) {
+ return apr_psprintf(cmd->temp_pool, "Module specifier '%s' must be "
+ "followed by a log level keyword", arg);
+ }
+
+ err = ap_parse_log_level(level_str, &level);
+ if (err != NULL)
+ return apr_psprintf(cmd->temp_pool, "%s:%s: %s", arg, level_str, err);
+
+ if ((module = find_module(cmd->server, arg)) == NULL) {
+ char *name = apr_psprintf(cmd->temp_pool, "%s_module", arg);
+ ap_log_error(APLOG_MARK, APLOG_TRACE6, 0, cmd->server,
+ "Cannot find module '%s', trying '%s'", arg, name);
+ module = find_module(cmd->server, name);
}
+ if (module == NULL) {
+ return apr_psprintf(cmd->temp_pool, "Cannot find module %s", arg);
+ }
+
+ ap_set_module_loglevel(cmd->pool, log, module->module_index, level);
+ ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
+ "Setting LogLevel for module %s to %s", module->name,
+ level_str);
+
return NULL;
}
char sport[20];
core_dir_config *conf;
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ conf = (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
if ((conf->server_signature == srv_sig_off)
|| (conf->server_signature == srv_sig_unset)) {
return "";
static char *server_banner = NULL;
static int banner_locked = 0;
-static char *server_description = NULL;
+static const char *server_description = NULL;
enum server_token_type {
- SrvTk_MAJOR, /* eg: Apache/2 */
- SrvTk_MINOR, /* eg. Apache/2.0 */
- SrvTk_MINIMAL, /* eg: Apache/2.0.41 */
- SrvTk_OS, /* eg: Apache/2.0.41 (UNIX) */
- SrvTk_FULL, /* eg: Apache/2.0.41 (UNIX) PHP/4.2.2 FooBar/1.2b */
+ SrvTk_MAJOR, /* eg: Apache/2 */
+ SrvTk_MINOR, /* eg. Apache/2.0 */
+ SrvTk_MINIMAL, /* eg: Apache/2.0.41 */
+ SrvTk_OS, /* eg: Apache/2.0.41 (UNIX) */
+ SrvTk_FULL, /* eg: Apache/2.0.41 (UNIX) PHP/4.2.2 FooBar/1.2b */
SrvTk_PRODUCT_ONLY /* eg: Apache */
};
static enum server_token_type ap_server_tokens = SrvTk_FULL;
}
static const char *set_serv_tokens(cmd_parms *cmd, void *dummy,
- const char *arg)
+ const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return err;
}
- if (!strcasecmp(arg, "OS")) {
+ if (!strcasecmp(arg1, "OS")) {
ap_server_tokens = SrvTk_OS;
}
- else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) {
+ else if (!strcasecmp(arg1, "Min") || !strcasecmp(arg1, "Minimal")) {
ap_server_tokens = SrvTk_MINIMAL;
}
- else if (!strcasecmp(arg, "Major")) {
+ else if (!strcasecmp(arg1, "Major")) {
ap_server_tokens = SrvTk_MAJOR;
}
- else if (!strcasecmp(arg, "Minor") ) {
+ else if (!strcasecmp(arg1, "Minor") ) {
ap_server_tokens = SrvTk_MINOR;
}
- else if (!strcasecmp(arg, "Prod") || !strcasecmp(arg, "ProductOnly")) {
+ else if (!strcasecmp(arg1, "Prod") || !strcasecmp(arg1, "ProductOnly")) {
ap_server_tokens = SrvTk_PRODUCT_ONLY;
}
else {
{
core_dir_config *conf;
- conf = ap_get_module_config(r->per_dir_config, &core_module);
+ conf = ap_get_core_module_config(r->per_dir_config);
if (conf->limit_xml_body == AP_LIMIT_UNSET)
return AP_DEFAULT_LIMIT_XML_BODY;
static const char *set_recursion_limit(cmd_parms *cmd, void *dummy,
const char *arg1, const char *arg2)
{
- core_server_config *conf = ap_get_module_config(cmd->server->module_config,
- &core_module);
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
int limit = atoi(arg1);
if (limit <= 0) {
*/
AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
{
- core_server_config *conf = ap_get_module_config(r->server->module_config,
- &core_module);
+ core_server_config *conf =
+ ap_get_core_module_config(r->server->module_config);
const request_rec *top = r;
int redirects = 0, subreqs = 0;
int rlimit = conf->redirect_limit
return 0;
}
-static const char *add_ct_output_filters(cmd_parms *cmd, void *conf_,
- const char *arg, const char *arg2)
+static const char *set_trace_enable(cmd_parms *cmd, void *dummy,
+ const char *arg1)
{
- core_dir_config *conf = conf_;
- ap_filter_rec_t *old, *new = NULL;
- const char *filter_name;
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
- if (!conf->ct_output_filters) {
- conf->ct_output_filters = apr_hash_make(cmd->pool);
- old = NULL;
+ if (strcasecmp(arg1, "on") == 0) {
+ conf->trace_enable = AP_TRACE_ENABLE;
+ }
+ else if (strcasecmp(arg1, "off") == 0) {
+ conf->trace_enable = AP_TRACE_DISABLE;
+ }
+ else if (strcasecmp(arg1, "extended") == 0) {
+ conf->trace_enable = AP_TRACE_EXTENDED;
}
else {
- old = (ap_filter_rec_t*) apr_hash_get(conf->ct_output_filters, arg2,
- APR_HASH_KEY_STRING);
- /* find last entry */
- if (old) {
- while (old->next) {
- old = old->next;
- }
- }
+ return "TraceEnable must be one of 'on', 'off', or 'extended'";
}
- while (*arg &&
- (filter_name = ap_getword(cmd->pool, &arg, ';')) &&
- strcmp(filter_name, "")) {
- new = apr_pcalloc(cmd->pool, sizeof(ap_filter_rec_t));
- new->name = filter_name;
+ return NULL;
+}
+
+static apr_hash_t *errorlog_hash;
+
+static int log_constant_item(const ap_errorlog_info *info, const char *arg,
+ char *buf, int buflen)
+{
+ char *end = apr_cpystrn(buf, arg, buflen);
+ return end - buf;
+}
+
+static char *parse_errorlog_misc_string(apr_pool_t *p,
+ ap_errorlog_format_item *it,
+ const char **sa)
+{
+ const char *s;
+ char scratch[MAX_STRING_LEN];
+ char *d = scratch;
+ /*
+ * non-leading white space terminates this string to allow the next field
+ * separator to be inserted
+ */
+ int at_start = 1;
+
+ it->func = log_constant_item;
+ s = *sa;
- /* We found something, so let's append it. */
- if (old) {
- old->next = new;
+ while (*s && *s != '%' && (*s != ' ' || at_start) && d < scratch + MAX_STRING_LEN) {
+ if (*s != '\\') {
+ if (*s != ' ') {
+ at_start = 0;
+ }
+ *d++ = *s++;
}
else {
- apr_hash_set(conf->ct_output_filters, arg2,
- APR_HASH_KEY_STRING, new);
+ s++;
+ switch (*s) {
+ case 'r':
+ *d++ = '\r';
+ s++;
+ break;
+ case 'n':
+ *d++ = '\n';
+ s++;
+ break;
+ case 't':
+ *d++ = '\t';
+ s++;
+ break;
+ case '\0':
+ /* handle end of string */
+ *d++ = '\\';
+ break;
+ default:
+ /* copy next char verbatim */
+ *d++ = *s++;
+ break;
+ }
}
- old = new;
- }
-
- if (!new) {
- return "invalid filter name";
}
+ *d = '\0';
+ it->arg = apr_pstrdup(p, scratch);
+ *sa = s;
return NULL;
}
-/*
- * Insert filters requested by the AddOutputFilterByType
- * configuration directive. We cannot add filters based
- * on content-type until after the handler has started
- * to run. Only then do we reliably know the content-type.
- */
-void ap_add_output_filters_by_type(request_rec *r)
+
+static char *parse_errorlog_item(apr_pool_t *p, ap_errorlog_format_item *it,
+ const char **sa)
{
- core_dir_config *conf;
- const char *ctype;
+ const char *s = *sa;
+ ap_errorlog_handler *handler;
+ int i;
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ if (*s != '%') {
+ if (*s == ' ') {
+ it->flags |= AP_ERRORLOG_FLAG_FIELD_SEP;
+ }
+ return parse_errorlog_misc_string(p, it, sa);
+ }
- /* We can't do anything with no content-type or if we don't have a
- * filter configured.
- */
- if (!r->content_type || !conf->ct_output_filters) {
- return;
+ ++s;
+
+ if (*s == ' ') {
+ /* percent-space (% ) is a field separator */
+ it->flags |= AP_ERRORLOG_FLAG_FIELD_SEP;
+ *sa = ++s;
+ /* recurse */
+ return parse_errorlog_item(p, it, sa);
+ }
+ else if (*s == '%') {
+ it->arg = "%";
+ it->func = log_constant_item;
+ *sa = ++s;
+ return NULL;
}
- /* remove c-t decoration */
- ctype = ap_field_noparam(r->pool, r->content_type);
- if (ctype) {
- ap_filter_rec_t *ct_filter;
- ct_filter = apr_hash_get(conf->ct_output_filters, ctype,
- APR_HASH_KEY_STRING);
- while (ct_filter) {
- ap_add_output_filter(ct_filter->name, NULL, r, r->connection);
- ct_filter = ct_filter->next;
+ while (*s) {
+ switch (*s) {
+ case '{':
+ ++s;
+ it->arg = ap_getword(p, &s, '}');
+ break;
+ case '+':
+ ++s;
+ it->flags |= AP_ERRORLOG_FLAG_REQUIRED;
+ break;
+ case '-':
+ ++s;
+ it->flags |= AP_ERRORLOG_FLAG_NULL_AS_HYPHEN;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ i = *s - '0';
+ while (apr_isdigit(*++s))
+ i = i * 10 + (*s) - '0';
+ it->min_loglevel = i;
+ break;
+ case 'M':
+ it->func = NULL;
+ it->flags |= AP_ERRORLOG_FLAG_MESSAGE;
+ *sa = ++s;
+ return NULL;
+ default:
+ handler = (ap_errorlog_handler *)apr_hash_get(errorlog_hash, s, 1);
+ if (!handler) {
+ char dummy[2];
+
+ dummy[0] = *s;
+ dummy[1] = '\0';
+ return apr_pstrcat(p, "Unrecognized error log format directive %",
+ dummy, NULL);
+ }
+ it->func = handler->func;
+ *sa = ++s;
+ return NULL;
}
}
- return;
+ return "Ran off end of error log format parsing args to some directive";
}
-static const char *set_trace_enable(cmd_parms *cmd, void *dummy,
- const char *arg1)
+static apr_array_header_t *parse_errorlog_string(apr_pool_t *p,
+ const char *s,
+ const char **err,
+ int is_main_fmt)
{
- core_server_config *conf = ap_get_module_config(cmd->server->module_config,
- &core_module);
+ apr_array_header_t *a = apr_array_make(p, 30,
+ sizeof(ap_errorlog_format_item));
+ char *res;
+ int seen_msg_fmt = 0;
+
+ while (s && *s) {
+ ap_errorlog_format_item *item =
+ (ap_errorlog_format_item *)apr_array_push(a);
+ memset(item, 0, sizeof(*item));
+ res = parse_errorlog_item(p, item, &s);
+ if (res) {
+ *err = res;
+ return NULL;
+ }
+ if (item->flags & AP_ERRORLOG_FLAG_MESSAGE) {
+ if (!is_main_fmt) {
+ *err = "%M cannot be used in once-per-request or "
+ "once-per-connection formats";
+ return NULL;
+ }
+ seen_msg_fmt = 1;
+ }
+ if (is_main_fmt && item->flags & AP_ERRORLOG_FLAG_REQUIRED) {
+ *err = "The '+' flag cannot be used in the main error log format";
+ return NULL;
+ }
+ if (!is_main_fmt && item->min_loglevel) {
+ *err = "The loglevel cannot be used as a condition in "
+ "once-per-request or once-per-connection formats";
+ return NULL;
+ }
+ if (item->min_loglevel > APLOG_TRACE8) {
+ *err = "The specified loglevel modifier is out of range";
+ return NULL;
+ }
+ }
- if (strcasecmp(arg1, "on") == 0) {
- conf->trace_enable = AP_TRACE_ENABLE;
+ if (is_main_fmt && !seen_msg_fmt) {
+ *err = "main ErrorLogFormat must contain message format string '%M'";
+ return NULL;
}
- else if (strcasecmp(arg1, "off") == 0) {
- conf->trace_enable = AP_TRACE_DISABLE;
+
+ return a;
+}
+
+static const char *set_errorlog_format(cmd_parms *cmd, void *dummy,
+ const char *arg1, const char *arg2)
+{
+ const char *err_string = NULL;
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
+
+ if (!arg2) {
+ conf->error_log_format = parse_errorlog_string(cmd->pool, arg1,
+ &err_string, 1);
+ }
+ else if (!strcasecmp(arg1, "connection")) {
+ if (!conf->error_log_conn) {
+ conf->error_log_conn = apr_array_make(cmd->pool, 5,
+ sizeof(apr_array_header_t *));
+ }
+
+ if (*arg2) {
+ apr_array_header_t **e;
+ e = (apr_array_header_t **) apr_array_push(conf->error_log_conn);
+ *e = parse_errorlog_string(cmd->pool, arg2, &err_string, 0);
+ }
}
- else if (strcasecmp(arg1, "extended") == 0) {
- conf->trace_enable = AP_TRACE_EXTENDED;
+ else if (!strcasecmp(arg1, "request")) {
+ if (!conf->error_log_req) {
+ conf->error_log_req = apr_array_make(cmd->pool, 5,
+ sizeof(apr_array_header_t *));
+ }
+
+ if (*arg2) {
+ apr_array_header_t **e;
+ e = (apr_array_header_t **) apr_array_push(conf->error_log_req);
+ *e = parse_errorlog_string(cmd->pool, arg2, &err_string, 0);
+ }
}
else {
- return "TraceEnable must be one of 'on', 'off', or 'extended'";
+ err_string = "ErrorLogFormat type must be one of request, connection";
}
- return NULL;
+ return err_string;
+}
+
+AP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag,
+ ap_errorlog_handler_fn_t *handler,
+ int flags)
+{
+ ap_errorlog_handler *log_struct = apr_palloc(p, sizeof(*log_struct));
+ log_struct->func = handler;
+ log_struct->flags = flags;
+
+ apr_hash_set(errorlog_hash, tag, 1, (const void *)log_struct);
}
+
/* Note --- ErrorDocument will now work from .htaccess files.
* The AllowOverride of Fileinfo allows webmasters to turn it off
*/
"Container for authentication directives to be applied when any HTTP "
"method other than those specified is used to access the resource"),
AP_INIT_TAKE1("<IfModule", start_ifmod, NULL, EXEC_ON_READ | OR_ALL,
- "Container for directives based on existance of specified modules"),
+ "Container for directives based on existence of specified modules"),
AP_INIT_TAKE1("<IfDefine", start_ifdefine, NULL, EXEC_ON_READ | OR_ALL,
- "Container for directives based on existance of command line defines"),
+ "Container for directives based on existence of command line defines"),
AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
"Container for directives affecting resources located in the "
"specified directories"),
"The name of the default charset to add to any Content-Type without one or 'Off' to disable"),
AP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO,
"Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"),
-AP_INIT_TAKE1("Define", set_define, NULL, RSRC_CONF,
- "Define the existance of a variable. Same as passing -D to the command line."),
-AP_INIT_RAW_ARGS("<If", ifsection, NULL, OR_ALL,
+AP_INIT_TAKE12("Define", set_define, NULL, EXEC_ON_READ|ACCESS_CONF|RSRC_CONF,
+ "Define a variable, optionally to a value. Same as passing -D to the command line."),
+AP_INIT_TAKE1("UnDefine", unset_define, NULL, EXEC_ON_READ|ACCESS_CONF|RSRC_CONF,
+ "Undefine the existence of a variable. Undo a Define."),
+AP_INIT_RAW_ARGS("Error", generate_error, NULL, OR_ALL,
+ "Generate error message from within configuration"),
+AP_INIT_RAW_ARGS("<If", ifsection, COND_IF, OR_ALL,
+ "Container for directives to be conditionally applied"),
+AP_INIT_RAW_ARGS("<ElseIf", ifsection, COND_ELSEIF, OR_ALL,
+ "Container for directives to be conditionally applied"),
+AP_INIT_RAW_ARGS("<Else", ifsection, COND_ELSE, OR_ALL,
"Container for directives to be conditionally applied"),
/* Old resource config file commands */
"config files"),
AP_INIT_RAW_ARGS("Options", set_options, NULL, OR_OPTIONS,
"Set a number of attributes for a given directory"),
-AP_INIT_TAKE1("DefaultType", ap_set_string_slot,
- (void*)APR_OFFSETOF(core_dir_config, ap_default_type),
- OR_FILEINFO, "the default MIME type for untypable files"),
+AP_INIT_TAKE1("DefaultType", set_default_type, NULL, OR_FILEINFO,
+ "the default media type for otherwise untyped files (DEPRECATED)"),
AP_INIT_RAW_ARGS("FileETag", set_etag_bits, NULL, OR_FILEINFO,
"Specify components used to construct a file's ETag"),
AP_INIT_TAKE1("EnableMMAP", set_enable_mmap, NULL, OR_FILEINFO,
AP_INIT_TAKE1("ErrorLog", set_server_string_slot,
(void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF,
"The filename of the error log"),
+AP_INIT_TAKE12("ErrorLogFormat", set_errorlog_format, NULL, RSRC_CONF,
+ "Format string for the ErrorLog"),
AP_INIT_RAW_ARGS("ServerAlias", set_server_alias, NULL, RSRC_CONF,
"A name or names alternately used to access the server"),
AP_INIT_TAKE1("ServerPath", set_serverpath, NULL, RSRC_CONF,
/* TODO: ListenBacklog in MPM */
AP_INIT_TAKE1("Include", include_config, NULL,
(RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
- "Name of the config file to be included"),
-AP_INIT_TAKE1("LogLevel", set_loglevel, NULL, RSRC_CONF,
+ "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 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_ITERATE("LogLevel", set_loglevel, NULL, RSRC_CONF|ACCESS_CONF,
"Level of verbosity in error logging"),
AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,
"A numeric IP address:port, or the name of a host"),
-AP_INIT_TAKE1("ServerTokens", set_serv_tokens, NULL, RSRC_CONF,
- "Determine tokens displayed in the Server: header - Min(imal), OS or Full"),
+AP_INIT_TAKE12("ServerTokens", set_serv_tokens, NULL, RSRC_CONF,
+ "Determine tokens displayed in the Server: header - Min(imal), "
+ "Major, Minor, Prod, OS or Full"),
AP_INIT_TAKE1("LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF,
"Limit on maximum size of an HTTP request line"),
AP_INIT_TAKE1("LimitRequestFieldsize", set_limit_req_fieldsize, NULL,
AP_INIT_TAKE1("LimitXMLRequestBody", set_limit_xml_req_body, NULL, OR_ALL,
"Limit (in bytes) on maximum size of an XML-based request "
"body"),
+AP_INIT_RAW_ARGS("Mutex", ap_set_mutex, NULL, RSRC_CONF,
+ "mutex (or \"default\") and mechanism"),
/* System Resource Controls */
#ifdef RLIMIT_CPU
AP_INIT_TAKE1("SetInputFilter", ap_set_string_slot,
(void *)APR_OFFSETOF(core_dir_config, input_filters), OR_FILEINFO,
"filter (or ; delimited list of filters) to be run on the request body"),
-AP_INIT_ITERATE2("AddOutputFilterByType", add_ct_output_filters,
- (void *)APR_OFFSETOF(core_dir_config, ct_output_filters), OR_FILEINFO,
- "output filter name followed by one or more content-types"),
-AP_INIT_FLAG("AllowEncodedSlashes", set_allow2f, NULL, RSRC_CONF,
+AP_INIT_TAKE1("AllowEncodedSlashes", set_allow2f, NULL, RSRC_CONF,
"Allow URLs containing '/' encoded as '%2F'"),
+/* scoreboard.c directives */
+AP_INIT_TAKE1("ScoreBoardFile", ap_set_scoreboard, NULL, RSRC_CONF,
+ "A file for Apache to maintain runtime process management information"),
+AP_INIT_FLAG("ExtendedStatus", ap_set_extended_status, NULL, RSRC_CONF,
+ "\"On\" to track extended status information, \"Off\" to disable"),
+AP_INIT_FLAG("SeeRequestTail", ap_set_reqtail, NULL, RSRC_CONF,
+ "For extended status, \"On\" to see the last 63 chars of "
+ "the request line, \"Off\" (default) to see the first 63"),
+
/*
* These are default configuration directives that mpms can/should
- * pay attention to. If an mpm wishes to use these, they should
- * #defined them in mpm.h.
+ * pay attention to.
+ * XXX These are not for all platforms, and even some Unix MPMs might not want
+ * some directives.
*/
-#ifdef AP_MPM_WANT_SET_PIDFILE
AP_INIT_TAKE1("PidFile", ap_mpm_set_pidfile, NULL, RSRC_CONF,
"A file for logging the server process ID"),
-#endif
-#ifdef AP_MPM_WANT_SET_SCOREBOARD
-AP_INIT_TAKE1("ScoreBoardFile", ap_mpm_set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-#endif
-#ifdef AP_MPM_WANT_SET_LOCKFILE
-AP_INIT_TAKE1("LockFile", ap_mpm_set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call (deprecated)"),
-#endif
-#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
AP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-#endif
-#ifdef AP_MPM_WANT_SET_COREDUMPDIR
+ "Maximum number of connections a particular child serves before "
+ "dying. (DEPRECATED, use MaxConnectionsPerChild)"),
+AP_INIT_TAKE1("MaxConnectionsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,
+ "Maximum number of connections a particular child serves before dying."),
AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF,
"The location of the directory Apache changes to before dumping core"),
-#endif
-#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
-AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF,
- AP_AVAILABLE_MUTEXES_STRING),
-#endif
-#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF,
"Maximum number of 1k blocks a particular childs allocator may hold."),
-#endif
-#ifdef AP_MPM_WANT_SET_STACKSIZE
AP_INIT_TAKE1("ThreadStackSize", ap_mpm_set_thread_stacksize, NULL, RSRC_CONF,
"Size in bytes of stack used by threads handling client connections"),
-#endif
#if AP_ENABLE_EXCEPTION_HOOK
AP_INIT_TAKE1("EnableExceptionHook", ap_mpm_set_exception_hook, NULL, RSRC_CONF,
"Controls whether exception hook may be called after a crash"),
AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r)
{
void *sconf = r->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
+ core_server_config *conf = ap_get_core_module_config(sconf);
apr_status_t rv;
/* XXX this seems too specific, this should probably become
static int core_override_type(request_rec *r)
{
core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
/* Check for overrides with ForceType / SetHandler
*/
/* Deal with the poor soul who is trying to force path_info to be
* accepted within the core_handler, where they will let the subreq
* address its contents. This is toggled by the user in the very
- * beginning of the fixup phase, so modules should override the user's
+ * beginning of the fixup phase (here!), so modules should override the user's
* discretion in their own module fixup phase. It is tristate, if
- * the user doesn't specify, the result is 2 (which the module may
- * interpret to its own customary behavior.) It won't be touched
- * if the value is no longer undefined (2), so any module changing
- * the value prior to the fixup phase OVERRIDES the user's choice.
+ * the user doesn't specify, the result is AP_REQ_DEFAULT_PATH_INFO.
+ * (which the module may interpret to its own customary behavior.)
+ * It won't be touched if the value is no longer AP_ACCEPT_PATHINFO_UNSET,
+ * so any module changing the value prior to the fixup phase
+ * OVERRIDES the user's choice.
*/
if ((r->used_path_info == AP_REQ_DEFAULT_PATH_INFO)
- && (conf->accept_path_info != 3)) {
+ && (conf->accept_path_info != AP_ACCEPT_PATHINFO_UNSET)) {
+ /* No module knew better, and the user coded AcceptPathInfo */
r->used_path_info = conf->accept_path_info;
}
*/
int bld_content_md5;
- d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- bld_content_md5 = (d->content_md5 & 1)
+ d = (core_dir_config *)ap_get_core_module_config(r->per_dir_config);
+ bld_content_md5 = (d->content_md5 == AP_CONTENT_MD5_ON)
&& r->output_filters->frec->ftype != AP_FTYPE_RESOURCE;
ap_allow_standard_methods(r, MERGE_ALLOW, M_GET, M_OPTIONS, M_POST, -1);
}
if (r->method_number == M_GET || r->method_number == M_POST) {
- if (r->finfo.filetype == 0) {
+ if (r->finfo.filetype == APR_NOFILE) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"File does not exist: %s", r->filename);
return HTTP_NOT_FOUND;
if (r->method_number != M_GET) {
core_request_config *req_cfg;
- req_cfg = ap_get_module_config(r->request_config, &core_module);
+ req_cfg = ap_get_core_module_config(r->request_config);
if (!req_cfg->deliver_script) {
/* The flag hasn't been set for this request. Punt. */
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY
#if APR_HAS_SENDFILE
- | ((d->enable_sendfile == ENABLE_SENDFILE_OFF)
- ? 0 : APR_SENDFILE_ENABLED)
+ | AP_SENDFILE_ENABLED(d->enable_sendfile)
#endif
, 0, r->pool)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
ap_set_etag(r);
apr_table_setn(r->headers_out, "Accept-Ranges", "bytes");
ap_set_content_length(r, r->finfo.size);
+ if (bld_content_md5) {
+ apr_table_setn(r->headers_out, "Content-MD5",
+ ap_md5digest(r->pool, fd));
+ }
bb = apr_brigade_create(r->pool, c->bucket_alloc);
r->status = errstatus;
}
else {
- if (bld_content_md5) {
- apr_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, fd));
- }
-
e = apr_brigade_insert_file(bb, fd, 0, r->finfo.size, r->pool);
#if APR_HAS_MMAP
}
else { /* unusual method (not GET or POST) */
if (r->method_number == M_INVALID) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Invalid method in request %s", r->the_request);
+ /* See if this looks like an undecrypted SSL handshake attempt.
+ * It's safe to look a couple bytes into the_request if it exists, as it's
+ * always allocated at least MIN_LINE_ALLOC (80) bytes.
+ */
+ if (r->the_request
+ && r->the_request[0] == 0x16
+ && (r->the_request[1] == 0x2 || r->the_request[1] == 0x3)) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+ "Invalid method in request %s - possible attempt to establish SSL connection on non-SSL port", r->the_request);
+ } else {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+ "Invalid method in request %s", r->the_request);
+ }
return HTTP_NOT_IMPLEMENTED;
}
sys_privileges += inc;
return sys_privileges;
}
+
+static int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
+{
+ ap_mutex_init(pconf);
+
+ if (!saved_server_config_defines)
+ init_config_defines(pconf);
+ apr_pool_cleanup_register(pconf, NULL, reset_config_defines,
+ apr_pool_cleanup_null);
+
+ mpm_common_pre_config(pconf);
+
+ return OK;
+}
+
static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
ap__logio_add_bytes_out = APR_RETRIEVE_OPTIONAL_FN(ap_logio_add_bytes_out);
static void core_insert_filter(request_rec *r)
{
core_dir_config *conf = (core_dir_config *)
- ap_get_module_config(r->per_dir_config,
- &core_module);
+ ap_get_core_module_config(r->per_dir_config);
const char *filter, *filters = conf->output_filters;
if (filters) {
}
req_cfg = (core_request_config *)
- ap_get_module_config(r->request_config, &core_module);
+ ap_get_core_module_config(r->request_config);
if (!req_cfg) {
return NULL;
if (r->main) {
core_request_config *main_req_cfg = (core_request_config *)
- ap_get_module_config(r->main->request_config, &core_module);
+ ap_get_core_module_config(r->main->request_config);
req_cfg->bb = main_req_cfg->bb;
}
else {
req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
}
- ap_set_module_config(r->request_config, &core_module, req_cfg);
+ ap_set_core_module_config(r->request_config, req_cfg);
return OK;
}
core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
apr_status_t rv;
-#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
/* The Nagle algorithm says that we should delay sending partial
* packets in hopes of getting more data. We don't want to do
* this; we are not telnet. There are bad interactions between
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
"apr_socket_opt_set(APR_TCP_NODELAY)");
}
-#endif
/* The core filter requires the timeout mode to be set, which
* incidentally sets the socket to be nonblocking. If this
net->out_ctx = NULL;
net->client_socket = csd;
- ap_set_module_config(net->c->conn_config, &core_module, csd);
+ ap_set_core_module_config(net->c->conn_config, csd);
ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, net->c);
ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, net->c);
return DONE;
}
+AP_DECLARE(int) ap_state_query(int query)
+{
+ switch (query) {
+ case AP_SQ_MAIN_STATE:
+ return ap_main_state;
+ case AP_SQ_RUN_MODE:
+ return ap_run_mode;
+ case AP_SQ_CONFIG_GEN:
+ return ap_config_generation;
+ default:
+ return AP_SQ_NOT_SUPPORTED;
+ }
+}
+
static void register_hooks(apr_pool_t *p)
{
- /* create_connection and install_transport_filters are
- * hooks that should always be APR_HOOK_REALLY_LAST to give other
- * modules the opportunity to install alternate network transports
- * and stop other functions from being run.
+ errorlog_hash = apr_hash_make(p);
+ ap_register_log_hooks(p);
+ ap_register_config_hooks(p);
+ ap_expr_init(p);
+
+ /* create_connection and pre_connection should always be hooked
+ * APR_HOOK_REALLY_LAST by core to give other modules the opportunity
+ * to install alternate network transports and stop other functions
+ * from being run.
*/
ap_hook_create_connection(core_create_conn, NULL, NULL,
APR_HOOK_REALLY_LAST);
ap_hook_pre_connection(core_pre_connection, NULL, NULL,
APR_HOOK_REALLY_LAST);
+ ap_hook_pre_config(core_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL,
APR_HOOK_MIDDLE);
ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_child_status(ap_core_child_status, NULL, NULL, APR_HOOK_MIDDLE);
/* register the core's insert_filter hook and register core-provided
* filters
NULL, AP_FTYPE_RESOURCE - 10);
}
-AP_DECLARE_DATA module core_module = {
- STANDARD20_MODULE_STUFF,
+AP_DECLARE_MODULE(core) = {
+ MPM20_MODULE_STUFF,
+ AP_PLATFORM_REWRITE_ARGS_HOOK, /* hook to run before apache parses args */
create_core_dir_config, /* create per-directory config structure */
merge_core_dir_configs, /* merge per-directory config structures */
create_core_server_config, /* create per-server config structure */