Apache HTTPD
mod_info.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * Info Module. Display configuration information for the server and
19 * all included modules.
20 *
21 * <Location /server-info>
22 * SetHandler server-info
23 * </Location>
24 *
25 * GET /server-info - Returns full configuration page for server and all modules
26 * GET /server-info?server - Returns server configuration only
27 * GET /server-info?module_name - Returns configuration for a single module
28 * GET /server-info?list - Returns quick list of included modules
29 * GET /server-info?config - Returns full configuration
30 * GET /server-info?hooks - Returns a listing of the modules active for each hook
31 *
32 * Original Author:
33 * Rasmus Lerdorf <rasmus vex.net>, May 1996
34 *
35 * Modified By:
36 * Lou Langholtz <ldl usi.utah.edu>, July 1997
37 *
38 * Apache 2.0 Port:
39 * Ryan Morgan <rmorgan covalent.net>, August 2000
40 *
41 */
42
43
44#include "apr.h"
45#include "apr_strings.h"
46#include "apr_lib.h"
47#include "apr_version.h"
48#if APR_MAJOR_VERSION < 2
49#include "apu_version.h"
50#endif
51#define APR_WANT_STRFUNC
52#include "apr_want.h"
53
54#include "httpd.h"
55#include "http_config.h"
56#include "http_core.h"
57#include "http_log.h"
58#include "http_main.h"
59#include "http_protocol.h"
60#include "http_connection.h"
61#include "http_request.h"
62#include "util_script.h"
63#include "ap_mpm.h"
64#include "mpm_common.h"
65#include "ap_provider.h"
66#include <stdio.h>
67#include <stdlib.h>
68
69typedef struct
70{
71 const char *name; /* matching module name */
72 const char *info; /* additional info */
74
79
80module AP_MODULE_DECLARE_DATA info_module;
81
82/* current file name when doing -DDUMP_CONFIG */
83static const char *dump_config_fn_info;
84/* file handle when doing -DDUMP_CONFIG */
86
88{
89 info_svr_conf *conf =
91
92 conf->more_info = apr_array_make(p, 20, sizeof(info_entry));
93 return conf;
94}
95
96static void *merge_info_config(apr_pool_t * p, void *basev, void *overridesv)
97{
98 info_svr_conf *new =
102
103 new->more_info =
104 apr_array_append(p, overrides->more_info, base->more_info);
105 return new;
106}
107
108static void put_int_flush_right(request_rec * r, int i, int field)
109{
110 if (field > 1 || i > 9)
111 put_int_flush_right(r, i / 10, field - 1);
112 if (i) {
113 if (r)
114 ap_rputc('0' + i % 10, r);
115 else
116 apr_file_putc((char)('0' + i % 10), out);
117 }
118 else {
119 if (r)
120 ap_rputs("&nbsp;", r);
121 else
122 apr_file_printf(out, " ");
123 }
124}
125
126static void set_fn_info(request_rec *r, const char *name)
127{
128 if (r)
129 ap_set_module_config(r->request_config, &info_module, (void *)name);
130 else
132}
133
134static const char *get_fn_info(request_rec *r)
135{
136 if (r)
137 return ap_get_module_config(r->request_config, &info_module);
138 else
139 return dump_config_fn_info;
140}
141
142
144 const char *thisfn, int linenum)
145{
146 int i;
147 const char *prevfn = get_fn_info(r);
148 if (thisfn == NULL)
149 thisfn = "*UNKNOWN*";
150 if (prevfn == NULL || 0 != strcmp(prevfn, thisfn)) {
151 if (r) {
153 ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n",
154 thisfn);
155 }
156 else {
157 apr_file_printf(out, "# In file: %s\n", thisfn);
158 }
160 }
161
162 if (r) {
163 ap_rputs("<dd><tt>", r);
164 put_int_flush_right(r, linenum > 0 ? linenum : 0, 4);
165 ap_rputs(":&nbsp;", r);
166 }
167 else if (linenum > 0) {
168 for (i = 1; i <= nest; ++i)
169 apr_file_printf(out, " ");
170 apr_file_putc('#', out);
172 apr_file_printf(out, ":\n");
173 }
174
175 for (i = 1; i <= nest; ++i) {
176 if (r)
177 ap_rputs("&nbsp;&nbsp;", r);
178 else
179 apr_file_printf(out, " ");
180 }
181}
182
184 int nest)
185{
186 mod_info_indent(r, nest, dir->filename, dir->line_num);
187 if (r)
188 ap_rprintf(r, "%s <i>%s</i></tt></dd>\n",
189 ap_escape_html(r->pool, dir->directive),
190 ap_escape_html(r->pool, dir->args));
191 else
192 apr_file_printf(out, "%s %s\n", dir->directive, dir->args);
193}
194
196 int nest)
197{
198 mod_info_indent(r, nest, dir->filename, dir->line_num);
199 if (r)
200 ap_rprintf(r, "%s %s</tt></dd>\n",
201 ap_escape_html(r->pool, dir->directive),
202 ap_escape_html(r->pool, dir->args));
203 else
204 apr_file_printf(out, "%s %s\n", dir->directive, dir->args);
205}
206
208 int nest)
209{
210 const char *dirname = dir->directive;
211 mod_info_indent(r, nest, dir->filename, 0);
212 if (*dirname == '<') {
213 if (r)
214 ap_rprintf(r, "&lt;/%s&gt;</tt></dd>",
216 else
217 apr_file_printf(out, "</%s>\n", dirname + 1);
218 }
219 else {
220 if (r)
221 ap_rprintf(r, "/%s</tt></dd>", ap_escape_html(r->pool, dirname));
222 else
223 apr_file_printf(out, "/%s\n", dirname);
224 }
225}
226
228{
229 const command_rec *cmd;
230 if (cmds == NULL)
231 return 1;
232 for (cmd = cmds; cmd->name; ++cmd) {
233 if (ap_cstr_casecmp(cmd->name, dir->directive) == 0)
234 return 1;
235 }
236 return 0;
237}
238
240 int from, int to)
241{
242 if (from < to)
243 mod_info_show_parents(r, node->parent, from, to - 1);
244 mod_info_show_open(r, node, to);
245}
246
248 ap_directive_t * node, int from, int level)
249{
250 int shown = from;
252 if (level == 0)
254 for (dir = node; dir; dir = dir->next) {
255 if (dir->first_child != NULL) {
256 if (level < mod_info_module_cmds(r, cmds, dir->first_child,
257 shown, level + 1)) {
258 shown = level;
259 mod_info_show_close(r, dir, level);
260 }
261 }
262 else if (mod_info_has_cmd(cmds, dir)) {
263 if (shown < level) {
264 mod_info_show_parents(r, dir->parent, shown, level - 1);
265 shown = level;
266 }
267 mod_info_show_cmd(r, dir, level);
268 }
269 }
270 return shown;
271}
272
273typedef struct
274{ /*XXX: should get something from apr_hooks.h instead */
275 void (*pFunc) (void); /* just to get the right size */
276 const char *szName;
277 const char *const *aszPredecessors;
278 const char *const *aszSuccessors;
281
282/*
283 * hook_get_t is a pointer to a function that takes void as an argument and
284 * returns a pointer to an apr_array_header_t. The nasty WIN32 ifdef
285 * is required to account for the fact that the ap_hook* calls all use
286 * STDCALL calling convention.
287 */
289#ifdef WIN32
291#endif
292 * hook_get_t) (void);
293
294typedef struct
295{
296 const char *name;
299
300static const hook_lookup_t startup_hooks[] = {
301 {"Pre-Config", ap_hook_get_pre_config},
302 {"Check Configuration", ap_hook_get_check_config},
303 {"Test Configuration", ap_hook_get_test_config},
304 {"Post Configuration", ap_hook_get_post_config},
305 {"Open Logs", ap_hook_get_open_logs},
306 {"Pre-MPM", ap_hook_get_pre_mpm},
307 {"MPM", ap_hook_get_mpm},
308 {"Drop Privileges", ap_hook_get_drop_privileges},
309 {"Retrieve Optional Functions", ap_hook_get_optional_fn_retrieve},
310 {"Child Init", ap_hook_get_child_init},
311 {NULL},
312};
313
314static const hook_lookup_t request_hooks[] = {
315 {"Pre-Connection", ap_hook_get_pre_connection},
316 {"Create Connection", ap_hook_get_create_connection},
317 {"Process Connection", ap_hook_get_process_connection},
318 {"Create Request", ap_hook_get_create_request},
319 {"Pre-Read Request", ap_hook_get_pre_read_request},
320 {"Post-Read Request", ap_hook_get_post_read_request},
321 {"Header Parse", ap_hook_get_header_parser},
322 {"HTTP Scheme", ap_hook_get_http_scheme},
323 {"Default Port", ap_hook_get_default_port},
324 {"Quick Handler", ap_hook_get_quick_handler},
325 {"Pre-Translate Name", ap_hook_get_pre_translate_name},
326 {"Translate Name", ap_hook_get_translate_name},
327 {"Map to Storage", ap_hook_get_map_to_storage},
328 {"Check Access", ap_hook_get_access_checker_ex},
329 {"Check Access (legacy)", ap_hook_get_access_checker},
330 {"Verify User ID", ap_hook_get_check_user_id},
331 {"Note Authentication Failure", ap_hook_get_note_auth_failure},
332 {"Verify User Access", ap_hook_get_auth_checker},
333 {"Check Type", ap_hook_get_type_checker},
334 {"Fixups", ap_hook_get_fixups},
335 {"Insert Filters", ap_hook_get_insert_filter},
336 {"Content Handlers", ap_hook_get_handler},
337 {"Transaction Logging", ap_hook_get_log_transaction},
338 {"Insert Errors", ap_hook_get_insert_error_filter},
339 {"Generate Log ID", ap_hook_get_generate_log_id},
340 {NULL},
341};
342
343static const hook_lookup_t other_hooks[] = {
344 {"Monitor", ap_hook_get_monitor},
345 {"Child Status", ap_hook_get_child_status},
346 {"End Generation", ap_hook_get_end_generation},
347 {"Error Logging", ap_hook_get_error_log},
348 {"Query MPM Attributes", ap_hook_get_mpm_query},
349 {"Query MPM Name", ap_hook_get_mpm_get_name},
350 {"Register Timed Callback", ap_hook_get_mpm_register_timed_callback},
351 {"Extend Expression Parser", ap_hook_get_expr_lookup},
352 {"Set Management Items", ap_hook_get_get_mgmt_items},
353#if AP_ENABLE_EXCEPTION_HOOK
354 {"Handle Fatal Exceptions", ap_hook_get_fatal_exception},
355#endif
356 {NULL},
357};
358
360{
361 int i;
363 hook_struct_t *elts;
364
365 if (!hooks) {
366 return 0;
367 }
368
369 elts = (hook_struct_t *) hooks->elts;
370
371 for (i = 0; i < hooks->nelts; i++) {
372 if (strcmp(elts[i].szName, modp->name) == 0) {
373 return 1;
374 }
375 }
376
377 return 0;
378}
379
381 module * modp,
382 const hook_lookup_t *lookup, int *comma)
383{
384 if (module_find_hook(modp, lookup->get)) {
385 if (*comma) {
386 ap_rputs(", ", r);
387 }
388 ap_rvputs(r, "<tt>", lookup->name, "</tt>", NULL);
389 *comma = 1;
390 }
391}
392
394{
395 int i, comma = 0;
396
397 ap_rputs("<dt><strong>Request Phase Participation:</strong>\n", r);
398
399 for (i = 0; request_hooks[i].name; i++) {
401 }
402
403 if (!comma) {
404 ap_rputs("<tt> <em>none</em></tt>", r);
405 }
406 ap_rputs("</dt>\n", r);
407}
408
409static const char *find_more_info(server_rec * s, const char *module_name)
410{
411 int i;
412 info_svr_conf *conf =
413 (info_svr_conf *) ap_get_module_config(s->module_config,
414 &info_module);
415 info_entry *entry = (info_entry *) conf->more_info->elts;
416
417 if (!module_name) {
418 return 0;
419 }
420 for (i = 0; i < conf->more_info->nelts; i++) {
421 if (!strcmp(module_name, entry->name)) {
422 return entry->info;
423 }
424 entry++;
425 }
426 return 0;
427}
428
430{
433
434 ap_rputs("<h2><a name=\"server\">Server Settings</a></h2>", r);
436 "<dl><dt><strong>Server Version:</strong> "
437 "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
440 "<dt><strong>Server Built:</strong> "
441 "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
444 "<dt><strong>Server loaded APR Version:</strong> "
445 "<tt>%s</tt></dt>\n", apr_version_string());
447 "<dt><strong>Compiled with APR Version:</strong> "
448 "<tt>%s</tt></dt>\n", APR_VERSION_STRING);
449#if APR_MAJOR_VERSION < 2
451 "<dt><strong>Server loaded APU Version:</strong> "
452 "<tt>%s</tt></dt>\n", apu_version_string());
454 "<dt><strong>Compiled with APU Version:</strong> "
455 "<tt>%s</tt></dt>\n", APU_VERSION_STRING);
456#endif
458 "<dt><strong>Server loaded PCRE Version:</strong> "
459 "<tt>%s</tt></dt>\n", ap_pcre_version_string(AP_REG_PCRE_LOADED));
461 "<dt><strong>Compiled with PCRE Version:</strong> "
462 "<tt>%s</tt></dt>\n", ap_pcre_version_string(AP_REG_PCRE_COMPILED));
464 "<dt><strong>Module Magic Number:</strong> "
465 "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
468 "<dt><strong>Hostname/port:</strong> "
469 "<tt>%s:%u</tt></dt>\n",
473 "<dt><strong>Timeouts:</strong> "
474 "<tt>connection: %d &nbsp;&nbsp; "
475 "keep-alive: %d</tt></dt>",
476 (int) (apr_time_sec(serv->timeout)),
477 (int) (apr_time_sec(serv->keep_alive_timeout)));
481 ap_rprintf(r, "<dt><strong>MPM Name:</strong> <tt>%s</tt></dt>\n",
482 ap_show_mpm());
484 "<dt><strong>MPM Information:</strong> "
485 "<tt>Max Daemons: %d Threaded: %s Forked: %s</tt></dt>\n",
486 max_daemons, threaded ? "yes" : "no", forked ? "yes" : "no");
488 "<dt><strong>Server Architecture:</strong> "
489 "<tt>%ld-bit</tt></dt>\n", 8 * (long) sizeof(void *));
491 "<dt><strong>Server Root:</strong> "
492 "<tt>%s</tt></dt>\n", ap_server_root);
494 "<dt><strong>Config File:</strong> "
495 "<tt>%s</tt></dt>\n", ap_conftree->filename);
496
497 ap_rputs("<dt><strong>Server Built With:</strong>\n"
498 "<tt style=\"white-space: pre;\">\n", r);
499
500 /* TODO: Not all of these defines are getting set like they do in main.c.
501 * Missing some headers?
502 */
503
504#ifdef BIG_SECURITY_HOLE
505 ap_rputs(" -D BIG_SECURITY_HOLE\n", r);
506#endif
507
508#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
509 ap_rputs(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n", r);
510#endif
511
512#ifdef OS
513 ap_rputs(" -D OS=\"" OS "\"\n", r);
514#endif
515
516#ifdef HAVE_SHMGET
517 ap_rputs(" -D HAVE_SHMGET\n", r);
518#endif
519
520#if APR_FILE_BASED_SHM
521 ap_rputs(" -D APR_FILE_BASED_SHM\n", r);
522#endif
523
524#if APR_HAS_SENDFILE
525 ap_rputs(" -D APR_HAS_SENDFILE\n", r);
526#endif
527
528#if APR_HAS_MMAP
529 ap_rputs(" -D APR_HAS_MMAP\n", r);
530#endif
531
532#ifdef NO_WRITEV
533 ap_rputs(" -D NO_WRITEV\n", r);
534#endif
535
536#ifdef NO_LINGCLOSE
537 ap_rputs(" -D NO_LINGCLOSE\n", r);
538#endif
539
540#if APR_HAVE_IPV6
541 ap_rputs(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ", r);
542#ifdef AP_ENABLE_V4_MAPPED
543 ap_rputs("enabled)\n", r);
544#else
545 ap_rputs("disabled)\n", r);
546#endif
547#endif
548
549#if APR_USE_FLOCK_SERIALIZE
550 ap_rputs(" -D APR_USE_FLOCK_SERIALIZE\n", r);
551#endif
552
553#if APR_USE_SYSVSEM_SERIALIZE
554 ap_rputs(" -D APR_USE_SYSVSEM_SERIALIZE\n", r);
555#endif
556
557#if APR_USE_POSIXSEM_SERIALIZE
558 ap_rputs(" -D APR_USE_POSIXSEM_SERIALIZE\n", r);
559#endif
560
561#if APR_USE_FCNTL_SERIALIZE
562 ap_rputs(" -D APR_USE_FCNTL_SERIALIZE\n", r);
563#endif
564
565#if APR_USE_PROC_PTHREAD_SERIALIZE
566 ap_rputs(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n", r);
567#endif
568#if APR_PROCESS_LOCK_IS_GLOBAL
569 ap_rputs(" -D APR_PROCESS_LOCK_IS_GLOBAL\n", r);
570#endif
571
572#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
573 ap_rputs(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n", r);
574#endif
575
576#if APR_HAS_OTHER_CHILD
577 ap_rputs(" -D APR_HAS_OTHER_CHILD\n", r);
578#endif
579
580#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
581 ap_rputs(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n", r);
582#endif
583
584#ifdef BUFFERED_LOGS
585 ap_rputs(" -D BUFFERED_LOGS\n", r);
586#ifdef PIPE_BUF
587 ap_rprintf(r, " -D PIPE_BUF=%ld\n", (long) PIPE_BUF);
588#endif
589#endif
590
591#if APR_CHARSET_EBCDIC
592 ap_rputs(" -D APR_CHARSET_EBCDIC\n", r);
593#endif
594
595#ifdef NEED_HASHBANG_EMUL
596 ap_rputs(" -D NEED_HASHBANG_EMUL\n", r);
597#endif
598
599/* This list displays the compiled in default paths: */
600#ifdef HTTPD_ROOT
601 ap_rputs(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n", r);
602#endif
603
604#ifdef SUEXEC_BIN
605 ap_rputs(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n", r);
606#endif
607
608#ifdef DEFAULT_PIDLOG
609 ap_rputs(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n", r);
610#endif
611
612#ifdef DEFAULT_SCOREBOARD
613 ap_rputs(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n", r);
614#endif
615
616#ifdef DEFAULT_ERRORLOG
617 ap_rputs(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n", r);
618#endif
619
620
621#ifdef AP_TYPES_CONFIG_FILE
622 ap_rputs(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n", r);
623#endif
624
625#ifdef SERVER_CONFIG_FILE
626 ap_rputs(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n", r);
627#endif
628 ap_rputs("</tt></dt>\n", r);
629 ap_rputs("</dl><hr />", r);
630 return 0;
631}
632
634{
635 int i;
636 char qs;
637 hook_struct_t *elts;
639
640 if (!hooks) {
641 return 0;
642 }
643
644 if (r->args && strcasecmp(r->args, "hooks") == 0) {
645 qs = '?';
646 }
647 else {
648 qs = '#';
649 }
650
651 elts = (hook_struct_t *) hooks->elts;
652
653 for (i = 0; i < hooks->nelts; i++) {
655 "&nbsp;&nbsp; %02d <a href=\"%c%s\">%s</a> <br/>",
656 elts[i].nOrder, qs, elts[i].szName, elts[i].szName);
657 }
658 return 0;
659}
660
662{
663 int i;
664 ap_rputs("<h2><a name=\"startup_hooks\">Startup Hooks</a></h2>\n<dl>", r);
665
666 for (i = 0; startup_hooks[i].name; i++) {
667 ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
670 ap_rputs("\n </tt>\n</dt>\n", r);
671 }
672
674 ("</dl>\n<hr />\n<h2><a name=\"request_hooks\">Request Hooks</a></h2>\n<dl>",
675 r);
676
677 for (i = 0; request_hooks[i].name; i++) {
678 ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
681 ap_rputs("\n </tt>\n</dt>\n", r);
682 }
683
685 ("</dl>\n<hr />\n<h2><a name=\"other_hooks\">Other Hooks</a></h2>\n<dl>",
686 r);
687
688 for (i = 0; other_hooks[i].name; i++) {
689 ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
691 dump_a_hook(r, other_hooks[i].get);
692 ap_rputs("\n </tt>\n</dt>\n", r);
693 }
694
695 ap_rputs("</dl>\n<hr />\n", r);
696
697 return 0;
698}
699
700static int cmp_provider_groups(const void *a_, const void *b_)
701{
702 const ap_list_provider_groups_t *a = a_, *b = b_;
703 int ret = strcmp(a->provider_group, b->provider_group);
704 if (!ret)
705 ret = strcmp(a->provider_version, b->provider_version);
706 return ret;
707}
708
709static int cmp_provider_names(const void *a_, const void *b_)
710{
711 const ap_list_provider_names_t *a = a_, *b = b_;
712 return strcmp(a->provider_name, b->provider_name);
713}
714
716{
721 int i,j;
722 const char *cur_group = NULL;
723
724 qsort(groups->elts, groups->nelts, sizeof(ap_list_provider_groups_t),
726 ap_rputs("<h2><a name=\"providers\">Providers</a></h2>\n<dl>", r);
727
728 for (i = 0; i < groups->nelts; i++) {
730 if (!cur_group || strcmp(cur_group, group->provider_group) != 0) {
731 if (cur_group)
732 ap_rputs("\n</dt>\n", r);
733 cur_group = group->provider_group;
734 ap_rprintf(r, "<dt><strong>%s</strong> (version <tt>%s</tt>):"
735 "\n <br />\n", cur_group, group->provider_version);
736 }
738 group->provider_version);
739 qsort(names->elts, names->nelts, sizeof(ap_list_provider_names_t),
741 for (j = 0; j < names->nelts; j++) {
743 ap_rprintf(r, "<tt>&nbsp;&nbsp;%s</tt><br/>", name->provider_name);
744 }
745 }
746 if (cur_group)
747 ap_rputs("\n</dt>\n", r);
748 ap_rputs("</dl>\n<hr />\n", r);
749}
750
751static int cmp_module_name(const void *a_, const void *b_)
752{
753 const module * const *a = a_;
754 const module * const *b = b_;
755 return strcmp((*a)->name, (*b)->name);
756}
757
759{
760 apr_array_header_t *arr = apr_array_make(p, 64, sizeof(module *));
761 module *modp, **entry;
762 for (modp = ap_top_module; modp; modp = modp->next) {
763 entry = &APR_ARRAY_PUSH(arr, module *);
764 *entry = modp;
765 }
766 qsort(arr->elts, arr->nelts, sizeof(module *), cmp_module_name);
767 return arr;
768}
769
771{
772 module *modp = NULL;
773 const char *more_info;
774 const command_rec *cmd;
776 int i;
777
778 if (strcmp(r->handler, "server-info")) {
779 return DECLINED;
780 }
781
782 r->allowed |= (AP_METHOD_BIT << M_GET);
783 if (r->method_number != M_GET) {
784 return DECLINED;
785 }
786
787 ap_set_content_type_ex(r, "text/html; charset=ISO-8859-1", 1);
788
790 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
791 "<head>\n"
792 " <title>Server Information</title>\n" "</head>\n", r);
793 ap_rputs("<body><h1 style=\"text-align: center\">"
794 "Apache Server Information</h1>\n", r);
795 if (!r->args || ap_cstr_casecmp(r->args, "list")) {
796 if (!r->args) {
797 ap_rputs("<dl><dt><tt>Subpages:<br />", r);
798 ap_rputs("<a href=\"?config\">Configuration Files</a>, "
799 "<a href=\"?server\">Server Settings</a>, "
800 "<a href=\"?list\">Module List</a>, "
801 "<a href=\"?hooks\">Active Hooks</a>, "
802 "<a href=\"?providers\">Available Providers</a>", r);
803 ap_rputs("</tt></dt></dl><hr />", r);
804
805 ap_rputs("<dl><dt><tt>Sections:<br />", r);
806 ap_rputs("<a href=\"#modules\">Loaded Modules</a>, "
807 "<a href=\"#server\">Server Settings</a>, "
808 "<a href=\"#startup_hooks\">Startup Hooks</a>, "
809 "<a href=\"#request_hooks\">Request Hooks</a>, "
810 "<a href=\"#other_hooks\">Other Hooks</a>, "
811 "<a href=\"#providers\">Providers</a>", r);
812 ap_rputs("</tt></dt></dl><hr />", r);
813
814 ap_rputs("<h2><a name=\"modules\">Loaded Modules</a></h2>"
815 "<dl><dt><tt>", r);
816
818 for (i = 0; i < modules->nelts; i++) {
820 ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name,
821 modp->name);
822 if (i < modules->nelts) {
823 ap_rputs(", ", r);
824 }
825 }
826 ap_rputs("</tt></dt></dl><hr />", r);
827 }
828
829 if (!r->args || !ap_cstr_casecmp(r->args, "server")) {
831 }
832
833 if (!r->args || !ap_cstr_casecmp(r->args, "hooks")) {
835 }
836
837 if (!r->args || !ap_cstr_casecmp(r->args, "providers")) {
839 }
840
841 if (r->args && 0 == ap_cstr_casecmp(r->args, "config")) {
842 ap_rputs("<dl><dt><strong>Configuration:</strong>\n", r);
844 ap_rputs("</dl><hr />", r);
845 }
846 else {
847 int comma = 0;
848 if (!modules)
850 for (i = 0; i < modules->nelts; i++) {
852 if (!r->args || !ap_cstr_casecmp(modp->name, r->args)) {
854 "<dl><dt><a name=\"%s\"><strong>Module Name:</strong></a> "
855 "<font size=\"+1\"><tt><a href=\"?%s\">%s</a></tt></font></dt>\n",
856 modp->name, modp->name, modp->name);
857 ap_rputs("<dt><strong>Content handlers:</strong> ", r);
858
860 ap_rputs("<tt> <em>yes</em></tt>", r);
861 }
862 else {
863 ap_rputs("<tt> <em>none</em></tt>", r);
864 }
865
866 ap_rputs("</dt>", r);
868 ("<dt><strong>Configuration Phase Participation:</strong>\n",
869 r);
870 if (modp->create_dir_config) {
871 if (comma) {
872 ap_rputs(", ", r);
873 }
874 ap_rputs("<tt>Create Directory Config</tt>", r);
875 comma = 1;
876 }
877 if (modp->merge_dir_config) {
878 if (comma) {
879 ap_rputs(", ", r);
880 }
881 ap_rputs("<tt>Merge Directory Configs</tt>", r);
882 comma = 1;
883 }
884 if (modp->create_server_config) {
885 if (comma) {
886 ap_rputs(", ", r);
887 }
888 ap_rputs("<tt>Create Server Config</tt>", r);
889 comma = 1;
890 }
891 if (modp->merge_server_config) {
892 if (comma) {
893 ap_rputs(", ", r);
894 }
895 ap_rputs("<tt>Merge Server Configs</tt>", r);
896 comma = 1;
897 }
898 if (!comma)
899 ap_rputs("<tt> <em>none</em></tt>", r);
900 comma = 0;
901 ap_rputs("</dt>", r);
902
904
905 cmd = modp->cmds;
906 if (cmd) {
908 ("<dt><strong>Module Directives:</strong></dt>",
909 r);
910 while (cmd) {
911 if (cmd->name) {
912 ap_rprintf(r, "<dd><tt>%s%s - <i>",
913 ap_escape_html(r->pool, cmd->name),
914 cmd->name[0] == '<' ? "&gt;" : "");
915 if (cmd->errmsg) {
916 ap_rputs(ap_escape_html(r->pool, cmd->errmsg), r);
917 }
918 ap_rputs("</i></tt></dd>\n", r);
919 }
920 else {
921 break;
922 }
923 cmd++;
924 }
926 ("<dt><strong>Current Configuration:</strong></dt>\n",
927 r);
929 0);
930 }
931 else {
933 ("<dt><strong>Module Directives:</strong> <tt>none</tt></dt>",
934 r);
935 }
936 more_info = find_more_info(r->server, modp->name);
937 if (more_info) {
939 ("<dt><strong>Additional Information:</strong>\n</dt><dd>",
940 r);
941 ap_rputs(more_info, r);
942 ap_rputs("</dd>", r);
943 }
944 ap_rputs("</dl><hr />\n", r);
945 if (r->args) {
946 break;
947 }
948 }
949 }
950 if (!modp && r->args && ap_cstr_casecmp(r->args, "server")) {
951 ap_rputs("<p><b>No such module</b></p>\n", r);
952 }
953 }
954 }
955 else {
956 ap_rputs("<dl><dt>Server Module List</dt>", r);
958 for (i = 0; i < modules->nelts; i++) {
960 ap_rputs("<dd>", r);
961 ap_rputs(modp->name, r);
962 ap_rputs("</dd>", r);
963 }
964 ap_rputs("</dl><hr />", r);
965 }
966 ap_rputs(ap_psignature("", r), r);
967 ap_rputs("</body></html>\n", r);
968 /* Done, turn off timeout, close file and return */
969 return 0;
970}
971
972static const char *add_module_info(cmd_parms * cmd, void *dummy,
973 const char *name, const char *info)
974{
975 server_rec *s = cmd->server;
976 info_svr_conf *conf =
977 (info_svr_conf *) ap_get_module_config(s->module_config,
978 &info_module);
979 info_entry *new = apr_array_push(conf->more_info);
980
981 new->name = name;
982 new->info = info;
983 return NULL;
984}
985
986static const command_rec info_cmds[] = {
987 AP_INIT_TAKE2("AddModuleInfo", add_module_info, NULL, RSRC_CONF,
988 "a module name and additional information on that module"),
989 {NULL}
990};
991
993 server_rec *s)
994{
995 if (ap_exists_config_define("DUMP_CONFIG")) {
996 apr_file_open_stdout(&out, ptemp);
998 }
999
1000 return DECLINED;
1001}
1002
1003
1009
1012 NULL, /* dir config creater */
1013 NULL, /* dir merger --- default is to override */
1014 create_info_config, /* server config */
1015 merge_info_config, /* merge server config */
1016 info_cmds, /* command apr_table_t */
1018};
#define DEFAULT_PIDLOG
Definition ap_config.h:144
Apache Multi-Processing Module library.
Apache Provider API.
@ AP_REG_PCRE_LOADED
Definition ap_regex.h:96
@ AP_REG_PCRE_COMPILED
Definition ap_regex.h:95
APR general purpose library routines.
APR Strings library.
apr_array_append(apr_pool_t *p, const apr_array_header_t *first, const apr_array_header_t *second)
Definition apr_tables.c:213
APR Versioning Interface.
#define APR_VERSION_STRING
APR Standard Headers Support.
APR-util Versioning Interface.
#define APU_VERSION_STRING
Definition apu_version.h:93
apr_array_header_t * ap_hook_get_process_connection(void)
Definition connection.c:42
apr_array_header_t * ap_hook_get_pre_connection(void)
Definition connection.c:43
apr_array_header_t * ap_hook_get_create_connection(void)
Definition connection.c:41
static apr_pool_t * pconf
Definition event.c:441
ap_directive_t * ap_conftree
Definition config.c:69
#define ap_get_module_config(v, m)
apr_array_header_t * ap_hook_get_handler(void)
Definition config.c:170
const command_rec * cmds
apr_array_header_t * ap_hook_get_test_config(void)
Definition config.c:100
apr_array_header_t * ap_hook_get_pre_config(void)
Definition config.c:91
#define AP_DECLARE_MODULE(foo)
ap_conf_vector_t * base
apr_array_header_t * ap_hook_get_open_logs(void)
Definition config.c:163
void ap_hook_check_config(ap_HOOK_check_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:96
apr_array_header_t * ap_hook_get_optional_fn_retrieve(void)
Definition config.c:195
void ap_hook_handler(ap_HOOK_handler_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:170
#define ap_set_module_config(v, m, val)
apr_array_header_t * ap_hook_get_post_config(void)
Definition config.c:105
apr_array_header_t * ap_hook_get_quick_handler(void)
Definition config.c:173
request_rec * r
apr_array_header_t * ap_hook_get_header_parser(void)
Definition config.c:86
const char * ap_show_mpm(void)
Definition mpm_common.c:548
apr_array_header_t * ap_hook_get_child_init(void)
Definition config.c:167
apr_array_header_t * ap_hook_get_check_config(void)
Definition config.c:96
#define AP_INIT_TAKE2(directive, func, mconfig, where, help)
#define HTTPD_ROOT
Definition httpd.h:91
#define DOCTYPE_XHTML_1_0T
Definition httpd.h:258
#define DEFAULT_ERRORLOG
Definition httpd.h:130
const char * ap_get_server_built(void)
Definition buildmark.c:26
#define SERVER_CONFIG_FILE
Definition httpd.h:146
const char * ap_get_server_description(void)
Definition core.c:3587
#define DECLINED
Definition httpd.h:457
#define AP_TYPES_CONFIG_FILE
Definition httpd.h:228
#define SUEXEC_BIN
Definition httpd.h:156
apr_array_header_t * ap_hook_get_get_mgmt_items(void)
Definition core.c:103
apr_port_t ap_get_server_port(const request_rec *r)
Definition core.c:1199
int ap_exists_config_define(const char *name)
Definition core.c:2896
const char * ap_get_server_name(request_rec *r)
Definition core.c:1145
apr_array_header_t * ap_hook_get_error_log(void)
Definition log.c:2004
apr_array_header_t * ap_hook_get_generate_log_id(void)
Definition log.c:2009
const char * ap_server_root
Definition config.c:61
#define MODULE_MAGIC_NUMBER_MAJOR
Definition ap_mmn.h:611
#define MODULE_MAGIC_NUMBER_MINOR
Definition ap_mmn.h:613
apr_array_header_t * ap_hook_get_child_status(void)
Definition mpm_common.c:109
apr_array_header_t * ap_hook_get_mpm(void)
Definition mpm_common.c:97
apr_array_header_t * ap_hook_get_end_generation(void)
Definition mpm_common.c:106
int ap_rvputs(request_rec *r,...)
Definition protocol.c:2220
apr_array_header_t * ap_hook_get_default_port(void)
Definition protocol.c:2591
apr_array_header_t * ap_hook_get_http_scheme(void)
Definition protocol.c:2589
int ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf
apr_array_header_t * ap_hook_get_note_auth_failure(void)
Definition protocol.c:2594
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
int ap_rputc(int c, request_rec *r)
Definition protocol.c:2117
void ap_set_content_type_ex(request_rec *r, const char *ct, int trusted)
apr_array_header_t * ap_hook_get_insert_error_filter(void)
apr_array_header_t * ap_hook_get_log_transaction(void)
Definition protocol.c:2587
apr_array_header_t * ap_hook_get_post_read_request(void)
Definition protocol.c:2585
apr_array_header_t * ap_hook_get_pre_read_request(void)
Definition protocol.c:2583
apr_array_header_t * ap_list_provider_names(apr_pool_t *pool, const char *provider_group, const char *provider_version)
Definition provider.c:127
apr_array_header_t * ap_list_provider_groups(apr_pool_t *pool)
Definition provider.c:168
apr_array_header_t * ap_hook_get_insert_filter(void)
Definition request.c:96
apr_array_header_t * ap_hook_get_fixups(void)
Definition request.c:87
apr_array_header_t * ap_hook_get_translate_name(void)
Definition request.c:81
apr_array_header_t * ap_hook_get_check_user_id(void)
Definition request.c:85
apr_array_header_t * ap_hook_get_type_checker(void)
Definition request.c:89
apr_array_header_t * ap_hook_get_create_request(void)
Definition request.c:98
apr_array_header_t * ap_hook_get_map_to_storage(void)
Definition request.c:83
apr_array_header_t * ap_hook_get_pre_translate_name(void)
Definition request.c:79
apr_array_header_t * ap_hook_get_access_checker_ex(void)
Definition request.c:93
apr_array_header_t * ap_hook_get_auth_checker(void)
Definition request.c:95
apr_array_header_t * ap_hook_get_access_checker(void)
Definition request.c:91
void * dummy
Definition http_vhost.h:62
apr_array_header_t * ap_hook_get_monitor(void)
Definition mpm_common.c:91
apr_array_header_t * ap_hook_get_mpm_register_timed_callback(void)
Definition mpm_common.c:103
apr_array_header_t * ap_hook_get_drop_privileges(void)
Definition mpm_common.c:94
apr_array_header_t * ap_hook_get_mpm_query(void)
Definition mpm_common.c:100
apr_array_header_t * ap_hook_get_mpm_get_name(void)
Definition mpm_common.c:136
apr_bucket apr_bucket_brigade * a
#define APR_HOOK_FIRST
Definition apr_hooks.h:301
#define APR_HOOK_MIDDLE
Definition apr_hooks.h:303
void(*) const char *const const char *const in nOrder)
apr_array_header_t * ap_hook_get_expr_lookup(void)
#define RSRC_CONF
#define AP_METHOD_BIT
Definition httpd.h:629
#define M_GET
Definition httpd.h:592
#define STANDARD20_MODULE_STUFF
int ap_cstr_casecmp(const char *s1, const char *s2)
Definition util.c:3542
const char * ap_psignature(const char *prefix, request_rec *r)
Definition core.c:3516
#define ap_escape_html(p, s)
Definition httpd.h:1860
apr_size_t size
const char * dirname
int strcasecmp(const char *a, const char *b)
apr_pool_t * b
Definition apr_pools.h:529
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
apr_dir_t * dir
int to
const char * s
Definition apr_strings.h:95
#define APR_ARRAY_PUSH(ary, type)
Definition apr_tables.h:150
const apr_array_header_t * arr
Definition apr_tables.h:187
int nelts
Definition apr_tables.h:122
#define APR_ARRAY_IDX(ary, i, type)
Definition apr_tables.h:141
apr_cmdtype_e cmd
#define apr_time_sec(time)
Definition apr_time.h:63
apr_status_t ap_mpm_query(int query_code, int *result)
Definition mpm_common.c:421
#define AP_MPMQ_IS_FORKED
Definition ap_mpm.h:154
#define AP_MPMQ_MAX_DAEMON_USED
Definition ap_mpm.h:150
#define AP_MPMQ_IS_THREADED
Definition ap_mpm.h:152
Apache Configuration.
Apache connection library.
CORE HTTP Daemon.
Apache Logging library.
Command line options.
HTTP protocol handling.
Apache Request library.
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
static int display_info(request_rec *r)
Definition mod_info.c:770
static int mod_info_has_cmd(const command_rec *cmds, ap_directive_t *dir)
Definition mod_info.c:227
static const hook_lookup_t startup_hooks[]
Definition mod_info.c:300
static const hook_lookup_t other_hooks[]
Definition mod_info.c:343
static void * create_info_config(apr_pool_t *p, server_rec *s)
Definition mod_info.c:87
static int check_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
Definition mod_info.c:992
static int show_active_hooks(request_rec *r)
Definition mod_info.c:661
static void mod_info_indent(request_rec *r, int nest, const char *thisfn, int linenum)
Definition mod_info.c:143
static int show_server_settings(request_rec *r)
Definition mod_info.c:429
static apr_array_header_t * get_sorted_modules(apr_pool_t *p)
Definition mod_info.c:758
static const command_rec info_cmds[]
Definition mod_info.c:986
static void mod_info_show_cmd(request_rec *r, const ap_directive_t *dir, int nest)
Definition mod_info.c:183
static int mod_info_module_cmds(request_rec *r, const command_rec *cmds, ap_directive_t *node, int from, int level)
Definition mod_info.c:247
static const char * add_module_info(cmd_parms *cmd, void *dummy, const char *name, const char *info)
Definition mod_info.c:972
static void set_fn_info(request_rec *r, const char *name)
Definition mod_info.c:126
static void * merge_info_config(apr_pool_t *p, void *basev, void *overridesv)
Definition mod_info.c:96
static void mod_info_show_open(request_rec *r, const ap_directive_t *dir, int nest)
Definition mod_info.c:195
static void register_hooks(apr_pool_t *p)
Definition mod_info.c:1004
apr_array_header_t *(* hook_get_t)(void)
Definition mod_info.c:292
static int module_find_hook(module *modp, hook_get_t hook_get)
Definition mod_info.c:359
static int cmp_provider_names(const void *a_, const void *b_)
Definition mod_info.c:709
static void module_participate(request_rec *r, module *modp, const hook_lookup_t *lookup, int *comma)
Definition mod_info.c:380
static const char * get_fn_info(request_rec *r)
Definition mod_info.c:134
static void module_request_hook_participate(request_rec *r, module *modp)
Definition mod_info.c:393
static const char * find_more_info(server_rec *s, const char *module_name)
Definition mod_info.c:409
static void mod_info_show_close(request_rec *r, const ap_directive_t *dir, int nest)
Definition mod_info.c:207
static void put_int_flush_right(request_rec *r, int i, int field)
Definition mod_info.c:108
static void show_providers(request_rec *r)
Definition mod_info.c:715
static void mod_info_show_parents(request_rec *r, ap_directive_t *node, int from, int to)
Definition mod_info.c:239
static const char * dump_config_fn_info
Definition mod_info.c:83
static int cmp_module_name(const void *a_, const void *b_)
Definition mod_info.c:751
static int cmp_provider_groups(const void *a_, const void *b_)
Definition mod_info.c:700
static apr_file_t * out
Definition mod_info.c:85
static const hook_lookup_t request_hooks[]
Definition mod_info.c:314
static int dump_a_hook(request_rec *r, hook_get_t hook_get)
Definition mod_info.c:633
static const char *const hooks[]
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
Multi-Processing Modules functions.
#define DEFAULT_SCOREBOARD
Definition scoreboard.h:43
apr_array_header_t * ap_hook_get_pre_mpm(void)
Definition scoreboard.c:102
char * name
KEY name
Definition xmlparse.c:229
Structure used to build the config tree.
struct ap_directive_t * parent
const char * filename
const char * provider_group
Definition ap_provider.h:40
const char * provider_version
Definition ap_provider.h:41
const char * name
hook_get_t get
Definition mod_info.c:297
const char * name
Definition mod_info.c:296
const char *const * aszSuccessors
Definition mod_info.c:278
const char * szName
Definition mod_info.c:276
const char *const * aszPredecessors
Definition mod_info.c:277
Definition mod_info.c:70
const char * name
Definition mod_info.c:71
const char * info
Definition mod_info.c:72
apr_array_header_t * more_info
Definition mod_info.c:77
A structure that represents the current request.
Definition httpd.h:845
const char * handler
Definition httpd.h:994
int method_number
Definition httpd.h:898
apr_pool_t * pool
Definition httpd.h:847
struct ap_conf_vector_t * request_config
Definition httpd.h:1049
apr_int64_t allowed
Definition httpd.h:922
server_rec * server
Definition httpd.h:851
char * args
Definition httpd.h:1026
A structure to store information for each virtual server.
Definition httpd.h:1322
Apache script tools.
INT info
static NAMED * lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
Definition xmlparse.c:7191