1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000 The Apache Software Foundation. All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
60 * http_config.c: once was auxillary functions for reading httpd's config
61 * file and converting filenames into a namespace
65 * Wall-to-wall rewrite for Apache... commands which are part of the
66 * server core can now be found next door in "http_core.c". Now contains
67 * general command loop, and functions which do bookkeeping for the new
68 * Apache config stuff (modules and configuration vectors).
76 #include "ap_config.h"
77 #include "apr_portable.h"
78 #include "apr_strings.h"
79 #include "apr_file_io.h"
81 #include "http_config.h"
82 #include "http_core.h"
83 #include "http_log.h" /* for errors in parse_htaccess */
84 #include "http_request.h" /* for default_handler (see invoke_handler) */
85 #include "http_main.h"
86 #include "http_vhost.h"
87 #include "util_cfgtree.h"
88 #ifdef HAVE_ARPA_INET_H
89 #include <arpa/inet.h>
95 API_VAR_EXPORT const char *ap_server_argv0;
97 API_VAR_EXPORT const char *ap_server_root;
99 API_VAR_EXPORT apr_array_header_t *ap_server_pre_read_config;
100 API_VAR_EXPORT apr_array_header_t *ap_server_post_read_config;
101 API_VAR_EXPORT apr_array_header_t *ap_server_config_defines;
104 AP_HOOK_LINK(header_parser)
105 AP_HOOK_LINK(pre_config)
106 AP_HOOK_LINK(post_config)
107 AP_HOOK_LINK(open_logs)
108 AP_HOOK_LINK(child_init)
111 AP_IMPLEMENT_HOOK_RUN_ALL(int,header_parser,
112 (request_rec *r),(r),OK,DECLINED)
113 AP_IMPLEMENT_HOOK_VOID(pre_config,
114 (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp),
116 AP_IMPLEMENT_HOOK_VOID(post_config,
117 (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp,
118 server_rec *s),(pconf,plog,ptemp,s))
119 AP_IMPLEMENT_HOOK_VOID(open_logs,
120 (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp,
121 server_rec *s),(pconf,plog,ptemp,s))
122 AP_IMPLEMENT_HOOK_VOID(child_init,
123 (apr_pool_t *pchild, server_rec *s),(pchild,s))
125 /****************************************************************
127 * We begin with the functions which deal with the linked list
128 * of modules which control just about all of the server operation.
131 /* total_modules is the number of modules that have been linked
134 static int total_modules = 0;
135 /* dynamic_modules is the number of modules that have been added
136 * after the pre-loaded ones have been set up. It shouldn't be larger
137 * than DYNAMIC_MODULE_LIMIT.
139 static int dynamic_modules = 0;
140 API_VAR_EXPORT module *top_module = NULL;
141 API_VAR_EXPORT module **ap_loaded_modules=NULL;
143 typedef int (*handler_func) (request_rec *);
144 typedef void *(*dir_maker_func) (apr_pool_t *, char *);
145 typedef void *(*merger_func) (apr_pool_t *, void *, void *);
147 /* Dealing with config vectors. These are associated with per-directory,
148 * per-server, and per-request configuration, and have a void* pointer for
149 * each modules. The nature of the structure pointed to is private to the
150 * module in question... the core doesn't (and can't) know. However, there
151 * are defined interfaces which allow it to create instances of its private
152 * per-directory and per-server structures, and to merge the per-directory
153 * structures of a directory and its subdirectory (producing a new one in
154 * which the defaults applying to the base directory have been properly
158 #ifndef ap_get_module_config
159 API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
161 void **confv = (void **) conf_vector;
162 return confv[m->module_index];
166 #ifndef ap_set_module_config
167 API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
169 void **confv = (void **) conf_vector;
170 confv[m->module_index] = val;
174 static void *create_empty_config(apr_pool_t *p)
176 void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) *
177 (total_modules + DYNAMIC_MODULE_LIMIT));
178 return (void *) conf_vector;
181 static void *create_default_per_dir_config(apr_pool_t *p)
183 void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
186 for (modp = top_module; modp; modp = modp->next) {
187 dir_maker_func df = modp->create_dir_config;
190 conf_vector[modp->module_index] = (*df) (p, NULL);
193 return (void *) conf_vector;
197 ap_merge_per_dir_configs(apr_pool_t *p, void *base, void *new)
199 void **conf_vector = (void **) apr_palloc(p, sizeof(void *) * total_modules);
200 void **base_vector = (void **) base;
201 void **new_vector = (void **) new;
204 for (modp = top_module; modp; modp = modp->next) {
205 merger_func df = modp->merge_dir_config;
206 int i = modp->module_index;
208 if (df && new_vector[i])
209 conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
211 conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
214 return (void *) conf_vector;
217 static void *create_server_config(apr_pool_t *p, server_rec *s)
219 void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
222 for (modp = top_module; modp; modp = modp->next) {
223 if (modp->create_server_config)
224 conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
227 return (void *) conf_vector;
230 static void merge_server_configs(apr_pool_t *p, void *base, void *virt)
232 /* Can reuse the 'virt' vector for the spine of it, since we don't
233 * have to deal with the moral equivalent of .htaccess files here...
236 void **base_vector = (void **) base;
237 void **virt_vector = (void **) virt;
240 for (modp = top_module; modp; modp = modp->next) {
241 merger_func df = modp->merge_server_config;
242 int i = modp->module_index;
245 virt_vector[i] = base_vector[i];
247 virt_vector[i] = (*df) (p, base_vector[i], virt_vector[i]);
251 void *ap_create_request_config(apr_pool_t *p)
253 return create_empty_config(p);
256 void *ap_create_conn_config(apr_pool_t *p)
258 return create_empty_config(p);
261 CORE_EXPORT(void *) ap_create_per_dir_config(apr_pool_t *p)
263 return create_empty_config(p);
267 * For speed/efficiency we generate a compact list of all the handlers
268 * and wildcard handlers. This means we won't have to scan the entire
269 * module list looking for handlers... where we'll find a whole whack
277 static fast_handler_rec *handlers;
278 static fast_handler_rec *wildhandlers;
280 static void init_handlers(apr_pool_t *p)
284 int nwildhandlers = 0;
285 const handler_rec *handp;
286 fast_handler_rec *ph, *pw;
289 for (modp = top_module; modp; modp = modp->next) {
292 for (handp = modp->handlers; handp->content_type; ++handp) {
293 if (ap_strchr_c(handp->content_type, '*')) {
300 ph = handlers = apr_palloc(p, sizeof(*ph)*(nhandlers + 1));
301 pw = wildhandlers = apr_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
302 for (modp = top_module; modp; modp = modp->next) {
305 for (handp = modp->handlers; handp->content_type; ++handp) {
306 if ((starp = ap_strchr_c(handp->content_type, '*'))) {
307 pw->hr.content_type = handp->content_type;
308 pw->hr.handler = handp->handler;
309 pw->len = starp - handp->content_type;
312 ph->hr.content_type = handp->content_type;
313 ph->hr.handler = handp->handler;
314 ph->len = strlen(handp->content_type);
319 pw->hr.content_type = NULL;
320 pw->hr.handler = NULL;
321 ph->hr.content_type = NULL;
322 ph->hr.handler = NULL;
325 int ap_invoke_handler(request_rec *r)
327 fast_handler_rec *handp;
331 int result = HTTP_INTERNAL_SERVER_ERROR;
334 handler = r->handler;
335 handler_len = strlen(handler);
338 handler = r->content_type ? r->content_type : ap_default_type(r);
339 if ((p = ap_strchr_c(handler, ';')) != NULL) {
340 /* MIME type arguments */
341 while (p > handler && p[-1] == ' ')
342 --p; /* strip trailing spaces */
343 handler_len = p - handler;
346 handler_len = strlen(handler);
350 /* Pass one --- direct matches */
352 for (handp = handlers; handp->hr.content_type; ++handp) {
353 if (handler_len == handp->len
354 && !strncmp(handler, handp->hr.content_type, handler_len)) {
355 result = (*handp->hr.handler) (r);
357 if (result != DECLINED)
362 /* Pass two --- wildcard matches */
364 for (handp = wildhandlers; handp->hr.content_type; ++handp) {
365 if (handler_len >= handp->len
366 && !strncmp(handler, handp->hr.content_type, handp->len)) {
367 result = (*handp->hr.handler) (r);
369 if (result != DECLINED)
374 if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
375 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
376 "handler \"%s\" not found for: %s", r->handler, r->filename);
378 return HTTP_INTERNAL_SERVER_ERROR;
381 API_EXPORT(int) ap_method_is_limited(cmd_parms *cmd, const char *method) {
386 methnum = ap_method_number_of(method);
388 * The simple case: a method hard-coded into Apache.
390 if (methnum != M_INVALID) {
391 return (methnum & cmd->limited);
394 * Some extension method we don't know implicitly.
396 if ((cmd->limited_xmethods == NULL)
397 || (cmd->limited_xmethods->nelts == 0)) {
400 xmethod = (char **) cmd->limited_xmethods->elts;
401 for (i = 0; i < cmd->limited_xmethods->nelts; ++i) {
402 if (strcmp(method, xmethod[i]) == 0) {
409 API_EXPORT(void) ap_register_hooks(module *m)
411 if(m->register_hooks)
413 if(getenv("SHOW_HOOKS"))
415 printf("Registering hooks for %s\n",m->name);
416 ap_debug_module_hooks=1;
418 ap_debug_module_name=m->name;
423 /* One-time setup for precompiled modules --- NOT to be done on restart */
425 API_EXPORT(void) ap_add_module(module *m)
427 /* This could be called from an AddModule httpd.conf command,
428 * after the file has been linked and the module structure within it
432 if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
433 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
434 "%s: module \"%s\" is not compatible with this "
435 "version of Apache.", ap_server_argv0, m->name);
436 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
440 if (m->next == NULL) {
441 m->next = top_module;
444 if (m->module_index == -1) {
445 m->module_index = total_modules++;
448 if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
449 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
450 "%s: module \"%s\" could not be loaded, because"
451 " the dynamic", ap_server_argv0, m->name);
452 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
453 "module limit was reached. Please increase "
454 "DYNAMIC_MODULE_LIMIT and recompile.");
459 /* Some C compilers put a complete path into __FILE__, but we want
460 * only the filename (e.g. mod_includes.c). So check for path
461 * components (Unix and DOS), and remove them.
464 if (ap_strrchr_c(m->name, '/'))
465 m->name = 1 + ap_strrchr_c(m->name, '/');
466 if (ap_strrchr_c(m->name, '\\'))
467 m->name = 1 + ap_strrchr_c(m->name, '\\');
469 #ifdef _OSD_POSIX /* __FILE__="*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)" */
470 /* We cannot fix the string in-place, because it's const */
471 if (m->name[strlen(m->name)-1]==')') {
472 char *tmp = strdup(m->name); /* FIXME:memory leak, albeit a small one */
473 tmp[strlen(tmp)-1] = '\0';
476 #endif /*_OSD_POSIX*/
478 /* FIXME: is this the right place to call this? */
479 ap_register_hooks(m);
483 * remove_module undoes what add_module did. There are some caveats:
484 * when the module is removed, its slot is lost so all the current
485 * per-dir and per-server configurations are invalid. So we should
486 * only ever call this function when you are invalidating almost
487 * all our current data. I.e. when doing a restart.
490 API_EXPORT(void) ap_remove_module(module *m)
496 /* We are the top module, special case */
497 top_module = modp->next;
501 /* Not the top module, find use. When found modp will
502 * point to the module _before_ us in the list
505 while (modp && modp->next != m) {
509 /* Uh-oh, this module doesn't exist */
510 ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
511 "Cannot remove module %s: not found in module list",
515 /* Eliminate us from the module list */
516 modp->next = modp->next->next;
519 m->module_index = -1; /* simulate being unloaded, should
525 API_EXPORT(void) ap_add_loaded_module(module *mod)
530 * Add module pointer to top of chained module list
535 * And module pointer to list of loaded modules
537 * Notes: 1. ap_add_module() would already complain if no more space
538 * exists for adding a dynamically loaded module
539 * 2. ap_add_module() accepts double inclusion, so we have
540 * to accept this, too.
542 for (m = ap_loaded_modules; *m != NULL; m++)
548 API_EXPORT(void) ap_remove_loaded_module(module *mod)
555 * Remove module pointer from chained module list
557 ap_remove_module(mod);
560 * Remove module pointer from list of loaded modules
562 * Note: 1. We cannot determine if the module was successfully
563 * removed by ap_remove_module().
564 * 2. We have not to complain explicity when the module
565 * is not found because ap_remove_module() did it
568 for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
569 if (*m2 == mod && done == 0)
577 API_EXPORT(void) ap_setup_prelinked_modules(process_rec *process)
582 ap_global_hook_pool=process->pconf;
585 * Initialise total_modules variable and module indices
588 for (m = ap_preloaded_modules; *m != NULL; m++)
589 (*m)->module_index = total_modules++;
592 * Initialise list of loaded modules
594 ap_loaded_modules = (module **)apr_palloc(process->pool,
595 sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
596 if (ap_loaded_modules == NULL) {
597 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
598 "Ouch! Out of memory in ap_setup_prelinked_modules()!");
600 for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
605 * Initialize chain of linked (=activate) modules
607 for (m = ap_prelinked_modules; *m != NULL; m++)
613 API_EXPORT(const char *) ap_find_module_name(module *m)
618 API_EXPORT(module *) ap_find_linked_module(const char *name)
622 for (modp = top_module; modp; modp = modp->next) {
623 if (strcmp(modp->name, name) == 0)
629 /* Add a named module. Returns 1 if module found, 0 otherwise. */
630 API_EXPORT(int) ap_add_named_module(const char *name)
635 for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
636 if (strcmp(modp->name, name) == 0) {
637 /* Only add modules that are not already enabled. */
638 if (modp->next == NULL) {
648 /* Clear the internal list of modules, in preparation for starting over. */
649 API_EXPORT(void) ap_clear_module_list()
651 module **m = &top_module;
655 next_m = &((*m)->next);
660 /* This is required; so we add it always. */
661 ap_add_named_module("http_core.c");
664 /*****************************************************************
666 * Resource, access, and .htaccess config files now parsed by a common
669 * Let's begin with the basics; parsing the line and
670 * invoking the function...
673 static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
674 void *mconfig, const char *args)
679 if ((parms->override & cmd->req_override) == 0)
680 return apr_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
682 parms->info = cmd->cmd_data;
685 switch (cmd->args_how) {
687 #ifdef RESOLVE_ENV_PER_TOKEN
688 args = ap_resolve_env(parms->pool,args);
690 return cmd->AP_RAW_ARGS(parms, mconfig, args);
694 return apr_pstrcat(parms->pool, cmd->name, " takes no arguments",
697 return cmd->AP_NO_ARGS(parms, mconfig);
700 w = ap_getword_conf(parms->pool, &args);
702 if (*w == '\0' || *args != 0)
703 return apr_pstrcat(parms->pool, cmd->name, " takes one argument",
704 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
706 return cmd->AP_TAKE1(parms, mconfig, w);
709 w = ap_getword_conf(parms->pool, &args);
710 w2 = ap_getword_conf(parms->pool, &args);
712 if (*w == '\0' || *w2 == '\0' || *args != 0)
713 return apr_pstrcat(parms->pool, cmd->name, " takes two arguments",
714 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
716 return cmd->AP_TAKE2(parms, mconfig, w, w2);
720 w = ap_getword_conf(parms->pool, &args);
721 w2 = ap_getword_conf(parms->pool, &args);
723 if (*w == '\0' || *args != 0)
724 return apr_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
725 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
727 return cmd->AP_TAKE2(parms, mconfig, w, *w2 ? w2 : NULL);
731 w = ap_getword_conf(parms->pool, &args);
732 w2 = ap_getword_conf(parms->pool, &args);
733 w3 = ap_getword_conf(parms->pool, &args);
735 if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
736 return apr_pstrcat(parms->pool, cmd->name, " takes three arguments",
737 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
739 return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
743 w = ap_getword_conf(parms->pool, &args);
744 w2 = ap_getword_conf(parms->pool, &args);
745 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
747 if (*w == '\0' || *w2 == '\0' || *args != 0)
748 return apr_pstrcat(parms->pool, cmd->name,
749 " takes two or three arguments",
750 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
752 return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
756 w = ap_getword_conf(parms->pool, &args);
757 w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
758 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
760 if (*w == '\0' || *args != 0)
761 return apr_pstrcat(parms->pool, cmd->name,
762 " takes one, two or three arguments",
763 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
765 return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
769 w = ap_getword_conf(parms->pool, &args);
770 w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
771 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
773 if (*w == '\0' || (w2 && *w2 && !w3) || *args != 0)
774 return apr_pstrcat(parms->pool, cmd->name,
775 " takes one or three arguments",
776 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
778 return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
782 while (*(w = ap_getword_conf(parms->pool, &args)) != '\0')
784 if ((errmsg = cmd->AP_TAKE1(parms, mconfig, w)))
792 w = ap_getword_conf(parms->pool, &args);
794 if (*w == '\0' || *args == 0)
795 return apr_pstrcat(parms->pool, cmd->name,
796 " requires at least two arguments",
797 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
799 while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0')
801 if ((errmsg = cmd->AP_TAKE2(parms, mconfig, w, w2)))
809 w = ap_getword_conf(parms->pool, &args);
811 if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
812 return apr_pstrcat(parms->pool, cmd->name, " must be On or Off",
815 return cmd->AP_FLAG(parms, mconfig, strcasecmp(w, "off") != 0);
819 return apr_pstrcat(parms->pool, cmd->name,
820 " is improperly configured internally (server bug)",
825 CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds)
828 if (!strcasecmp(name, cmds->name))
836 CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod)
838 const command_rec *cmdp;
841 for (modp = *mod; modp; modp = modp->next)
842 if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
850 CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
852 void *mconfig = ap_get_module_config(config, mod);
853 void *sconfig = ap_get_module_config(parms->server->module_config, mod);
855 if (!mconfig && mod->create_dir_config) {
856 mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
857 ap_set_module_config(config, mod, mconfig);
860 if (!sconfig && mod->create_server_config) {
861 sconfig = (*mod->create_server_config) (parms->pool, parms->server);
862 ap_set_module_config(parms->server->module_config, mod, sconfig);
867 static const char *execute_now(char *cmd_line, const char *args, cmd_parms *parms,
868 apr_pool_t *p, apr_pool_t *ptemp,
869 ap_directive_t **sub_tree, ap_directive_t *parent);
871 static const char * ap_build_config_sub(apr_pool_t *p, apr_pool_t *temp_pool,
872 const char *l, cmd_parms *parms,
873 ap_directive_t **current,
874 ap_directive_t **curr_parent,
875 ap_directive_t **conftree)
879 ap_directive_t *newdir;
880 module *mod = top_module;
881 const command_rec *cmd;
883 if (*l == '#' || *l == '\0')
886 #if RESOLVE_ENV_PER_TOKEN
889 args = ap_resolve_env(temp_pool, l);
891 cmd_name = ap_getword_conf(p, &args);
892 if (*cmd_name == '\0') {
893 /* Note: this branch should not occur. An empty line should have
894 * triggered the exit further above.
899 newdir = apr_pcalloc(p, sizeof(ap_directive_t));
900 newdir->filename = parms->config_file->name;
901 newdir->line_num = parms->config_file->line_number;
902 newdir->directive = cmd_name;
903 newdir->args = apr_pstrdup(p, args);
905 if ((cmd = ap_find_command_in_modules(cmd_name, &mod)) != NULL) {
906 if (cmd->req_override & EXEC_ON_READ) {
908 ap_directive_t *sub_tree = NULL;
910 parms->err_directive = newdir;
911 retval = execute_now(cmd_name, args, parms, p, temp_pool,
912 &sub_tree, *curr_parent);
914 (*current)->next = sub_tree;
917 (*current) = sub_tree;
919 (*curr_parent)->first_child = (*current);
922 (*current)->parent = (*curr_parent);
927 /* Before walking *current to the end of the list,
928 * set the head to *current.
930 *conftree = *current;
932 while ((*current)->next != NULL) {
933 (*current) = (*current)->next;
934 (*current)->parent = (*curr_parent);
941 if (cmd_name[0] == '<') {
942 if (cmd_name[1] != '/') {
943 (*current) = ap_add_node(curr_parent, *current, newdir, 1);
945 else if (*curr_parent == NULL) {
946 parms->err_directive = newdir;
947 return apr_pstrcat(p, cmd_name,
948 " without matching <", cmd_name + 2,
952 char *bracket = cmd_name + strlen(cmd_name) - 1;
954 if (*bracket != '>') {
955 return apr_pstrcat(p, cmd_name,
956 "> directive missing closing '>'", NULL);
959 if (strcasecmp(cmd_name + 2,
960 (*curr_parent)->directive + 1) != 0) {
961 return apr_pstrcat(p, "Expected </",
962 (*curr_parent)->directive + 1, "> but saw ",
963 cmd_name, ">", NULL);
967 /* done with this section; move up a level */
968 *current = *curr_parent;
969 *curr_parent = (*current)->parent;
973 *current = ap_add_node(curr_parent, *current, newdir, 0);
979 const char *ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool,
981 ap_directive_t **current,
982 ap_directive_t **curr_parent,
983 char *orig_directive)
985 char l[MAX_STRING_LEN];
988 ap_directive_t *conftree = NULL;
990 bracket = apr_pstrcat(p, orig_directive + 1, ">", NULL);
991 while(!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
992 if ((strcasecmp(l + 2, bracket) == 0) &&
993 (*curr_parent == NULL)) {
996 retval = ap_build_config_sub(p, temp_pool, l, parms, current,
997 curr_parent, &conftree);
1000 if (conftree == NULL && curr_parent != NULL) {
1001 conftree = *curr_parent;
1003 if (conftree == NULL && current != NULL) {
1004 conftree = *current;
1007 *current = conftree;
1011 static const char *ap_walk_config_sub(const ap_directive_t *current,
1012 cmd_parms *parms, void *config)
1014 module *mod = top_module;
1017 const command_rec *cmd;
1019 if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
1020 parms->err_directive = current;
1021 return apr_pstrcat(parms->pool, "Invalid command '",
1023 "', perhaps mis-spelled or defined by a module "
1024 "not included in the server configuration",
1028 void *mconfig = ap_set_config_vectors(parms,config, mod);
1031 retval = invoke_cmd(cmd, parms, mconfig, current->args);
1032 if (retval == NULL) {
1035 if (strcmp(retval, DECLINE_CMD) != 0) {
1036 /* If the directive in error has already been set, don't
1037 * replace it. Otherwise, an error inside a container
1038 * will be reported as occuring on the first line of the
1041 if (!parms->err_directive) {
1042 parms->err_directive = current;
1047 mod = mod->next; /* Next time around, skip this one */
1053 API_EXPORT(const char *) ap_walk_config(ap_directive_t *current,
1054 cmd_parms *parms, void *config)
1056 void *oldconfig = parms->context;
1058 parms->context = config;
1060 /* scan through all directives, executing each one */
1061 for (; current != NULL; current = current->next) {
1064 parms->directive = current;
1066 /* actually parse the command and execute the correct function */
1067 errmsg = ap_walk_config_sub(current, parms, config);
1068 if (errmsg != NULL) {
1069 /* restore the context (just in case) */
1070 parms->context = oldconfig;
1075 parms->context = oldconfig;
1080 API_EXPORT(const char *) ap_build_config(cmd_parms *parms,
1081 apr_pool_t *p, apr_pool_t *temp_pool,
1082 ap_directive_t **conftree)
1084 ap_directive_t *current = *conftree;
1085 ap_directive_t *curr_parent = NULL;
1086 char l[MAX_STRING_LEN];
1089 if (current != NULL) {
1090 while (current->next) {
1091 current = current->next;
1095 while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
1097 errmsg = ap_build_config_sub(p, temp_pool, l, parms,
1098 ¤t, &curr_parent, conftree);
1102 if (*conftree == NULL && curr_parent != NULL) {
1103 *conftree = curr_parent;
1105 if (*conftree == NULL && current != NULL) {
1106 *conftree = current;
1110 if (curr_parent != NULL) {
1112 while (curr_parent != NULL) {
1113 errmsg = apr_psprintf(p, "%s%s%s:%u: %s> was not closed.",
1115 *errmsg == '\0' ? "" : APR_EOL_STR,
1116 curr_parent->filename,
1117 curr_parent->line_num,
1118 curr_parent->directive);
1119 curr_parent = curr_parent->parent;
1128 * Generic command functions...
1131 API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
1135 /* This one's pretty generic... */
1137 int offset = (int) (long) cmd->info;
1138 *(const char **) ((char *)struct_ptr + offset) = arg;
1142 API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
1146 /* This one's pretty generic... */
1147 char *arg=apr_pstrdup(cmd->pool,arg_);
1149 int offset = (int) (long) cmd->info;
1150 ap_str_tolower(arg);
1151 *(char **) ((char *)struct_ptr + offset) = arg;
1155 API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
1156 void *struct_ptr_v, int arg)
1158 /* This one's pretty generic too... */
1160 int offset = (int) (long) cmd->info;
1161 char *struct_ptr = (char *)struct_ptr_v;
1162 *(int *) (struct_ptr + offset) = arg ? 1 : 0;
1166 API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_ptr,
1169 /* Prepend server_root to relative arg.
1170 This allows .htaccess to be independent of server_root,
1171 so the server can be moved or mirrored with less pain. */
1173 int offset = (int) (long) cmd->info;
1174 if (ap_os_is_path_absolute(arg))
1175 p = apr_pstrdup(cmd->pool, arg);
1177 p = ap_make_full_path(cmd->pool, ap_server_root, arg);
1178 *(char **) (struct_ptr + offset) = p;
1182 /*****************************************************************
1184 * Reading whole config files...
1187 static cmd_parms default_parms =
1188 {NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
1190 API_EXPORT(const char *) ap_server_root_relative(apr_pool_t *p, const char *file)
1192 if(ap_os_is_path_absolute(file))
1194 return ap_make_full_path(p, ap_server_root, file);
1197 API_EXPORT(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive)
1199 char l[MAX_STRING_LEN];
1203 while(!(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
1204 #if RESOLVE_ENV_PER_TOKEN
1207 args = ap_resolve_env(cmd->temp_pool, l);
1209 cmd_name = ap_getword_conf(cmd->pool, &args);
1210 if (cmd_name[0] == '<') {
1211 if (cmd_name[1] == '/') {
1212 cmd_name[strlen(cmd_name) - 1] = '\0';
1213 if (strcasecmp(cmd_name + 2, directive + 1) != 0) {
1214 return apr_pstrcat(cmd->pool, "Expected </",
1215 directive + 1, "> but saw ",
1216 cmd_name, ">", NULL);
1221 ap_soak_end_container(cmd, cmd_name);
1228 static const char *execute_now(char *cmd_line, const char *args, cmd_parms *parms,
1229 apr_pool_t *p, apr_pool_t *ptemp,
1230 ap_directive_t **sub_tree, ap_directive_t *parent)
1232 module *mod = top_module;
1233 const command_rec *cmd;
1235 if (!(cmd = ap_find_command_in_modules(cmd_line, &mod))) {
1236 return apr_pstrcat(parms->pool, "Invalid command '",
1238 "', perhaps mis-spelled or defined by a module "
1239 "not included in the server configuration",
1243 return invoke_cmd(cmd, parms, sub_tree, args);
1247 /* This structure and the following functions are needed for the
1248 * table-based config file reading. They are passed to the
1249 * cfg_open_custom() routine.
1252 /* Structure to be passed to cfg_open_custom(): it contains an
1253 * index which is incremented from 0 to nelts on each call to
1254 * cfg_getline() (which in turn calls arr_elts_getstr())
1255 * and an apr_array_header_t pointer for the string array.
1258 apr_array_header_t *array;
1263 /* arr_elts_getstr() returns the next line from the string array. */
1264 static void *arr_elts_getstr(void *buf, size_t bufsiz, void *param)
1266 arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
1268 /* End of array reached? */
1269 if (++arr_param->curr_idx > arr_param->array->nelts)
1272 /* return the line */
1273 apr_cpystrn(buf, ((char **) arr_param->array->elts)[arr_param->curr_idx - 1], bufsiz);
1279 /* arr_elts_close(): dummy close routine (makes sure no more lines can be read) */
1280 static int arr_elts_close(void *param)
1282 arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
1283 arr_param->curr_idx = arr_param->array->nelts;
1287 static void process_command_config(server_rec *s, apr_array_header_t *arr,
1288 ap_directive_t **conftree, apr_pool_t *p,
1293 arr_elts_param_t arr_parms;
1295 arr_parms.curr_idx = 0;
1296 arr_parms.array = arr;
1298 parms = default_parms;
1300 parms.temp_pool = ptemp;
1302 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1304 parms.config_file = ap_pcfg_open_custom(p, "-c/-C directives",
1306 arr_elts_getstr, arr_elts_close);
1308 errmsg = ap_build_config(&parms, p, ptemp, conftree);
1310 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1311 "Syntax error in -C/-c directive:" APR_EOL_STR "%s",
1316 ap_cfg_closefile(parms.config_file);
1319 void ap_process_resource_config(server_rec *s, const char *fname,
1320 ap_directive_t **conftree, apr_pool_t *p,
1328 fname = ap_server_root_relative(p, fname);
1330 /* don't require conf/httpd.conf if we have a -C or -c switch */
1331 if ((ap_server_pre_read_config->nelts
1332 || ap_server_post_read_config->nelts)
1333 && !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
1334 if (apr_stat(&finfo, fname, p) != APR_SUCCESS)
1338 /* GCC's initialization extensions are soooo nice here... */
1340 parms = default_parms;
1342 parms.temp_pool = ptemp;
1344 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1346 if (ap_pcfg_openfile(&cfp, p, fname) != APR_SUCCESS) {
1347 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1348 "%s: could not open document config file %s",
1349 ap_server_argv0, fname);
1353 parms.config_file = cfp;
1355 errmsg = ap_build_config(&parms, p, ptemp, conftree);
1357 if (errmsg != NULL) {
1358 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1359 "Syntax error on line %d of %s:",
1360 parms.err_directive->line_num,
1361 parms.err_directive->filename);
1362 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1367 ap_cfg_closefile(cfp);
1370 API_EXPORT(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
1371 apr_pool_t *p, apr_pool_t *ptemp)
1376 parms = default_parms;
1378 parms.temp_pool = ptemp;
1380 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1383 errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
1385 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1386 "Syntax error on line %d of %s:",
1387 parms.err_directive->line_num,
1388 parms.err_directive->filename);
1389 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1395 int ap_parse_htaccess(void **result, request_rec *r, int override,
1396 const char *d, const char *access_name) {
1397 configfile_t *f = NULL;
1399 char *filename = NULL;
1400 const struct htaccess_result *cache;
1401 struct htaccess_result *new;
1403 apr_status_t status;
1405 /* firstly, search cache */
1406 for (cache = r->htaccess; cache != NULL; cache = cache->next)
1407 if (cache->override == override && strcmp(cache->dir, d) == 0) {
1408 if (cache->htaccess != NULL)
1409 *result = cache->htaccess;
1413 parms = default_parms;
1414 parms.override = override;
1415 parms.pool = r->pool;
1416 parms.temp_pool = r->pool;
1417 parms.server = r->server;
1418 parms.path = apr_pstrdup(r->pool, d);
1420 /* loop through the access names and find the first one */
1422 while (access_name[0]) {
1423 filename = ap_make_full_path(r->pool, d,
1424 ap_getword_conf(r->pool, &access_name));
1425 status = ap_pcfg_openfile(&f, r->pool, filename);
1427 if (status == APR_SUCCESS) {
1429 ap_directive_t *conftree;
1431 dc = ap_create_per_dir_config(r->pool);
1433 parms.config_file = f;
1434 errmsg = ap_build_config(&parms, r->pool, r->pool, &conftree);
1436 errmsg = ap_walk_config(conftree, &parms, dc);
1438 ap_cfg_closefile(f);
1441 ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, r,
1442 "%s: %s", filename, errmsg);
1443 return HTTP_INTERNAL_SERVER_ERROR;
1448 apr_status_t cerr = apr_canonical_error(status);
1450 if (cerr != APR_ENOENT && cerr != APR_ENOTDIR) {
1451 ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r,
1452 "%s pcfg_openfile: unable to check htaccess file, "
1453 "ensure it is readable",
1455 apr_table_setn(r->notes, "error-notes",
1456 "Server unable to read htaccess file, denying "
1457 "access to be safe");
1458 return HTTP_FORBIDDEN;
1464 new = apr_palloc(r->pool, sizeof(struct htaccess_result));
1465 new->dir = parms.path;
1466 new->override = override;
1468 /* add to head of list */
1469 new->next = r->htaccess;
1476 CORE_EXPORT(const char *) ap_init_virtual_host(apr_pool_t *p, const char *hostname,
1477 server_rec *main_server, server_rec **ps)
1479 server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec));
1481 /* TODO: this crap belongs in http_core */
1482 s->process = main_server->process;
1483 s->server_admin = NULL;
1484 s->server_hostname = NULL;
1485 s->error_fname = NULL;
1487 s->keep_alive_timeout = 0;
1489 s->keep_alive_max = -1;
1490 s->error_log = main_server->error_log;
1491 s->loglevel = main_server->loglevel;
1492 /* useful default, otherwise we get a port of 0 on redirects */
1493 s->port = main_server->port;
1497 s->names = apr_make_array(p, 4, sizeof(char **));
1498 s->wild_names = apr_make_array(p, 4, sizeof(char **));
1500 s->module_config = create_empty_config(p);
1501 s->lookup_defaults = ap_create_per_dir_config(p);
1504 s->server_uid = ap_user_id;
1505 s->server_gid = ap_group_id;
1508 s->limit_req_line = main_server->limit_req_line;
1509 s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1510 s->limit_req_fields = main_server->limit_req_fields;
1514 return ap_parse_vhost_addrs(p, hostname, s);
1518 API_EXPORT(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server)
1522 for (virt = main_server->next; virt; virt = virt->next) {
1523 merge_server_configs(p, main_server->module_config,
1524 virt->module_config);
1526 virt->lookup_defaults =
1527 ap_merge_per_dir_configs(p, main_server->lookup_defaults,
1528 virt->lookup_defaults);
1530 if (virt->server_admin == NULL)
1531 virt->server_admin = main_server->server_admin;
1533 if (virt->timeout == 0)
1534 virt->timeout = main_server->timeout;
1536 if (virt->keep_alive_timeout == 0)
1537 virt->keep_alive_timeout = main_server->keep_alive_timeout;
1539 if (virt->keep_alive == -1)
1540 virt->keep_alive = main_server->keep_alive;
1542 if (virt->keep_alive_max == -1)
1543 virt->keep_alive_max = main_server->keep_alive_max;
1545 /* XXX: this is really something that should be dealt with by a
1546 * post-config api phase */
1547 ap_core_reorder_directories(p, virt);
1549 ap_core_reorder_directories(p, main_server);
1552 /*****************************************************************
1554 * Getting *everything* configured...
1557 static void init_config_globals(apr_pool_t *p)
1559 /* Global virtual host hash bucket pointers. Init to null. */
1560 ap_init_vhost_config(p);
1563 static server_rec *init_server_config(process_rec *process, apr_pool_t *p)
1565 server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec));
1567 apr_open_stderr(&s->error_log, p);
1568 s->process = process;
1570 s->server_admin = DEFAULT_ADMIN;
1571 s->server_hostname = NULL;
1572 s->error_fname = DEFAULT_ERRORLOG;
1573 s->loglevel = DEFAULT_LOGLEVEL;
1574 s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
1575 s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
1576 s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
1577 s->timeout = DEFAULT_TIMEOUT;
1578 s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
1579 s->keep_alive_max = DEFAULT_KEEPALIVE;
1582 s->addrs = apr_pcalloc(p, sizeof(server_addr_rec));
1583 /* NOT virtual host; don't match any real network interface */
1584 s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
1585 s->addrs->host_port = 0; /* matches any port */
1586 s->addrs->virthost = ""; /* must be non-NULL */
1587 s->names = s->wild_names = NULL;
1589 s->module_config = create_server_config(p, s);
1590 s->lookup_defaults = create_default_per_dir_config(p);
1596 API_EXPORT(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp,
1597 const char *confname,
1598 ap_directive_t **conftree)
1600 apr_pool_t *p = process->pconf;
1601 server_rec *s = init_server_config(process, p);
1603 init_config_globals(p);
1605 /* All server-wide config files now have the SAME syntax... */
1607 process_command_config(s, ap_server_pre_read_config, conftree,
1610 ap_process_resource_config(s, confname, conftree, p, ptemp);
1612 process_command_config(s, ap_server_post_read_config, conftree,
1618 void ap_single_module_configure(apr_pool_t *p, server_rec *s, module *m)
1620 if (m->create_server_config)
1621 ap_set_module_config(s->module_config, m,
1622 (*m->create_server_config)(p, s));
1623 if (m->create_dir_config)
1624 ap_set_module_config(s->lookup_defaults, m,
1625 (*m->create_dir_config)(p, NULL));
1628 API_EXPORT(void) ap_run_rewrite_args(process_rec *process)
1632 for (m = top_module; m; m = m->next)
1633 if (m->rewrite_args)
1634 (*m->rewrite_args) (process);
1637 API_EXPORT(void) ap_post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
1639 ap_run_post_config(pconf,plog,ptemp,s);
1640 init_handlers(pconf);
1643 void ap_child_init_hook(apr_pool_t *pchild, server_rec *s)
1645 /* TODO: uh this seems ugly, is there a better way? */
1646 /*ap_child_init_alloc(); PUT THIS BACK IN XXXXX */
1648 ap_run_child_init(pchild,s);
1651 /********************************************************************
1652 * Configuration directives are restricted in terms of where they may
1653 * appear in the main configuration files and/or .htaccess files according
1654 * to the bitmask req_override in the command_rec structure.
1655 * If any of the overrides set in req_override are also allowed in the
1656 * context in which the command is read, then the command is allowed.
1657 * The context is determined as follows:
1659 * inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
1660 * within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
1661 * within .htaccess --> override = AllowOverride for current directory;
1663 * the result is, well, a rather confusing set of possibilities for when
1664 * a particular directive is allowed to be used. This procedure prints
1665 * in English where the given (pc) directive can be used.
1667 static void show_overrides(const command_rec *pc, module *pm)
1671 printf("\tAllowed in *.conf ");
1672 if ((pc->req_override & (OR_OPTIONS | OR_FILEINFO | OR_INDEXES)) ||
1673 ((pc->req_override & RSRC_CONF) &&
1674 ((pc->req_override & (ACCESS_CONF | OR_AUTHCFG | OR_LIMIT)))))
1676 else if (pc->req_override & RSRC_CONF)
1677 printf("only outside <Directory>, <Files> or <Location>");
1679 printf("only inside <Directory>, <Files> or <Location>");
1681 /* Warn if the directive is allowed inside <Directory> or .htaccess
1682 * but module doesn't support per-dir configuration */
1684 if ((pc->req_override & (OR_ALL | ACCESS_CONF)) && !pm->create_dir_config)
1685 printf(" [no per-dir config]");
1687 if (pc->req_override & OR_ALL) {
1688 printf(" and in .htaccess\n\twhen AllowOverride");
1690 if ((pc->req_override & OR_ALL) == OR_ALL)
1691 printf(" isn't None");
1693 printf(" includes ");
1695 if (pc->req_override & OR_AUTHCFG) {
1698 printf("AuthConfig");
1700 if (pc->req_override & OR_LIMIT) {
1705 if (pc->req_override & OR_OPTIONS) {
1710 if (pc->req_override & OR_FILEINFO) {
1715 if (pc->req_override & OR_INDEXES) {
1725 /* Show the preloaded configuration directives, the help string explaining
1726 * the directive arguments, in what module they are handled, and in
1727 * what parts of the configuration they are allowed. Used for httpd -h.
1729 API_EXPORT(void) ap_show_directives()
1731 const command_rec *pc;
1734 for (n = 0; ap_loaded_modules[n]; ++n)
1735 for (pc = ap_loaded_modules[n]->cmds; pc && pc->name; ++pc) {
1736 printf("%s (%s)\n", pc->name, ap_loaded_modules[n]->name);
1738 printf("\t%s\n", pc->errmsg);
1739 show_overrides(pc, ap_loaded_modules[n]);
1743 /* Show the preloaded module names. Used for httpd -l. */
1744 API_EXPORT(void) ap_show_modules()
1748 printf("Compiled in modules:\n");
1749 for (n = 0; ap_loaded_modules[n]; ++n)
1750 printf(" %s\n", ap_loaded_modules[n]->name);