mod_info.c revision 11e076839c8d5a82d55e710194d0daac51390dbd
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Info Module. Display configuration information for the server and
* all included modules.
*
* <Location /server-info>
* SetHandler server-info
* </Location>
*
* GET /server-info - Returns full configuration page for server and all modules
* GET /server-info?server - Returns server configuration only
* GET /server-info?module_name - Returns configuration for a single module
* GET /server-info?list - Returns quick list of included modules
* GET /server-info?config - Returns full configuration
* GET /server-info?hooks - Returns a listing of the modules active for each hook
*
* Original Author:
* Rasmus Lerdorf <rasmus vex.net>, May 1996
*
* Modified By:
* Lou Langholtz <ldl usi.utah.edu>, July 1997
*
* Apache 2.0 Port:
* Ryan Morgan <rmorgan covalent.net>, August 2000
*
*/
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_version.h"
#if APR_MAJOR_VERSION < 2
#include "apu_version.h"
#endif
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"
#include "http_connection.h"
#include "http_request.h"
#include "util_script.h"
#include "ap_mpm.h"
#include <stdio.h>
typedef struct
{
const char *name; /* matching module name */
const char *info; /* additional info */
} info_entry;
typedef struct
{
/* current file name when doing -DDUMP_CONFIG */
const char *dump_config_fn_info;
{
return conf;
}
{
info_svr_conf *new =
return new;
}
{
if (i) {
if (r)
else
}
else {
if (r)
ap_rputs(" ", r);
else
printf(" ");
}
}
{
if (r)
else
}
static const char *get_fn_info(request_rec *r)
{
if (r)
else
return dump_config_fn_info;
}
{
int i;
const char *prevfn = get_fn_info(r);
thisfn = "*UNKNOWN*";
if (r) {
ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n",
thisfn);
}
else {
}
set_fn_info(r, thisfn);
}
if (r) {
ap_rputs("<dd><tt>", r);
ap_rputs(": ", r);
}
else if (linenum > 0) {
for (i = 1; i <= nest; ++i)
printf(" ");
putchar('#');
printf(":\n");
}
for (i = 1; i <= nest; ++i) {
if (r)
ap_rputs(" ", r);
else
printf(" ");
}
}
int nest)
{
if (r)
ap_rprintf(r, "%s <i>%s</i></tt></dd>\n",
else
}
int nest)
{
if (r)
ap_rprintf(r, "%s %s</tt></dd>\n",
else
}
int nest)
{
if (*dirname == '<') {
if (r)
ap_rprintf(r, "</%s></tt></dd>",
else
}
else {
if (r)
else
}
}
{
const command_rec *cmd;
return 1;
return 1;
}
return 0;
}
{
}
{
if (level == 0)
set_fn_info(r, NULL);
}
}
}
}
}
return shown;
}
typedef struct
{ /*XXX: should get something from apr_hooks.h instead */
void (*pFunc) (void); /* just to get the right size */
const char *szName;
const char *const *aszPredecessors;
const char *const *aszSuccessors;
int nOrder;
/*
* hook_get_t is a pointer to a function that takes void as an argument and
* returns a pointer to an apr_array_header_t. The nasty WIN32 ifdef
* is required to account for the fact that the ap_hook* calls all use
* STDCALL calling convention.
*/
typedef apr_array_header_t *(
#ifdef WIN32
#endif
* hook_get_t) (void);
typedef struct
{
const char *name;
static hook_lookup_t startup_hooks[] = {
{"Pre-Config", ap_hook_get_pre_config},
{"Check Configuration", ap_hook_get_check_config},
{"Test Configuration", ap_hook_get_test_config},
{"Post Configuration", ap_hook_get_post_config},
{"Open Logs", ap_hook_get_open_logs},
{"Child Init", ap_hook_get_child_init},
{NULL},
};
static hook_lookup_t request_hooks[] = {
{"Pre-Connection", ap_hook_get_pre_connection},
{"Create Connection", ap_hook_get_create_connection},
{"Process Connection", ap_hook_get_process_connection},
{"Create Request", ap_hook_get_create_request},
{"Post-Read Request", ap_hook_get_post_read_request},
{"Header Parse", ap_hook_get_header_parser},
{"HTTP Scheme", ap_hook_get_http_scheme},
{"Default Port", ap_hook_get_default_port},
{"Quick Handler", ap_hook_get_quick_handler},
{"Translate Name", ap_hook_get_translate_name},
{"Map to Storage", ap_hook_get_map_to_storage},
{"Check Access", ap_hook_get_access_checker},
{"Verify User ID", ap_hook_get_check_user_id},
{"Verify User Access", ap_hook_get_auth_checker},
{"Check Type", ap_hook_get_type_checker},
{"Fixups", ap_hook_get_fixups},
{"Insert Filters", ap_hook_get_insert_filter},
{"Content Handlers", ap_hook_get_handler},
{"Logging", ap_hook_get_log_transaction},
{"Insert Errors", ap_hook_get_insert_error_filter},
{NULL},
};
{
int i;
if (!hooks) {
return 0;
}
return 1;
}
}
return 0;
}
static void module_participate(request_rec * r,
{
if (*comma) {
ap_rputs(", ", r);
}
*comma = 1;
}
}
{
int i, comma = 0;
ap_rputs("<dt><strong>Request Phase Participation:</strong>\n", r);
for (i = 0; request_hooks[i].name; i++) {
}
if (!comma) {
ap_rputs("<tt> <em>none</em></tt>", r);
}
ap_rputs("</dt>\n", r);
}
{
int i;
&info_module);
if (!module_name) {
return 0;
}
}
entry++;
}
return 0;
}
static int show_server_settings(request_rec * r)
{
ap_rputs("<h2><a name=\"server\">Server Settings</a></h2>", r);
ap_rprintf(r,
"<dl><dt><strong>Server Version:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></dt>\n",
ap_rprintf(r,
"<dt><strong>Server Built:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></dt>\n",
ap_rprintf(r,
"<dt><strong>Server loaded APR Version:</strong> "
"<tt>%s</tt></dt>\n", apr_version_string());
ap_rprintf(r,
"<dt><strong>Compiled with APR Version:</strong> "
"<tt>%s</tt></dt>\n", APR_VERSION_STRING);
#if APR_MAJOR_VERSION < 2
ap_rprintf(r,
"<dt><strong>Server loaded APU Version:</strong> "
"<tt>%s</tt></dt>\n", apu_version_string());
ap_rprintf(r,
"<dt><strong>Compiled with APU Version:</strong> "
"<tt>%s</tt></dt>\n", APU_VERSION_STRING);
#endif
ap_rprintf(r,
"<dt><strong>Module Magic Number:</strong> "
"<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
ap_rprintf(r,
"<tt>%s:%u</tt></dt>\n", ap_get_server_name(r),
ap_get_server_port(r));
ap_rprintf(r,
"<dt><strong>Timeouts:</strong> "
"<tt>connection: %d "
"keep-alive: %d</tt></dt>",
ap_rprintf(r, "<dt><strong>MPM Name:</strong> <tt>%s</tt></dt>\n",
ap_show_mpm());
ap_rprintf(r,
"<dt><strong>MPM Information:</strong> "
"<tt>Max Daemons: %d Threaded: %s Forked: %s</tt></dt>\n",
ap_rprintf(r,
"<dt><strong>Server Architecture:</strong> "
"<tt>%ld-bit</tt></dt>\n", 8 * (long) sizeof(void *));
ap_rprintf(r,
"<dt><strong>Server Root:</strong> "
"<tt>%s</tt></dt>\n", ap_server_root);
ap_rprintf(r,
"<dt><strong>Config File:</strong> "
ap_rputs("<dt><strong>Server Built With:</strong>\n"
"<tt style=\"white-space: pre;\">\n", r);
/* TODO: Not all of these defines are getting set like they do in main.c.
* Missing some headers?
*/
#ifdef BIG_SECURITY_HOLE
ap_rputs(" -D BIG_SECURITY_HOLE\n", r);
#endif
ap_rputs(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n", r);
#endif
#ifdef OS
#endif
#ifdef HAVE_SHMGET
ap_rputs(" -D HAVE_SHMGET\n", r);
#endif
ap_rputs(" -D APR_FILE_BASED_SHM\n", r);
#endif
#if APR_HAS_SENDFILE
ap_rputs(" -D APR_HAS_SENDFILE\n", r);
#endif
#if APR_HAS_MMAP
ap_rputs(" -D APR_HAS_MMAP\n", r);
#endif
#ifdef NO_WRITEV
ap_rputs(" -D NO_WRITEV\n", r);
#endif
#ifdef NO_LINGCLOSE
ap_rputs(" -D NO_LINGCLOSE\n", r);
#endif
#if APR_HAVE_IPV6
ap_rputs(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ", r);
#ifdef AP_ENABLE_V4_MAPPED
ap_rputs("enabled)\n", r);
#else
ap_rputs("disabled)\n", r);
#endif
#endif
ap_rputs(" -D APR_USE_FLOCK_SERIALIZE\n", r);
#endif
ap_rputs(" -D APR_USE_SYSVSEM_SERIALIZE\n", r);
#endif
ap_rputs(" -D APR_USE_POSIXSEM_SERIALIZE\n", r);
#endif
ap_rputs(" -D APR_USE_FCNTL_SERIALIZE\n", r);
#endif
ap_rputs(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n", r);
#endif
ap_rputs(" -D APR_PROCESS_LOCK_IS_GLOBAL\n", r);
#endif
ap_rputs(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n", r);
#endif
ap_rputs(" -D APR_HAS_OTHER_CHILD\n", r);
#endif
#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
ap_rputs(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n", r);
#endif
#ifdef BUFFERED_LOGS
ap_rputs(" -D BUFFERED_LOGS\n", r);
#ifdef PIPE_BUF
#endif
#endif
ap_rputs(" -D APR_CHARSET_EBCDIC\n", r);
#endif
#ifdef NEED_HASHBANG_EMUL
ap_rputs(" -D NEED_HASHBANG_EMUL\n", r);
#endif
/* This list displays the compiled in default paths: */
#ifdef HTTPD_ROOT
#endif
#ifdef SUEXEC_BIN
#endif
#ifdef DEFAULT_PIDLOG
#endif
#ifdef DEFAULT_SCOREBOARD
#endif
#ifdef DEFAULT_ERRORLOG
#endif
#ifdef AP_TYPES_CONFIG_FILE
#endif
#ifdef SERVER_CONFIG_FILE
#endif
ap_rputs("</tt></dt>\n", r);
ap_rputs("</dl><hr />", r);
return 0;
}
{
int i;
char qs;
if (!hooks) {
return 0;
}
qs = '?';
}
else {
qs = '#';
}
ap_rprintf(r,
" %02d <a href=\"%c%s\">%s</a> <br/>",
}
return 0;
}
static int show_active_hooks(request_rec * r)
{
int i;
ap_rputs("<h2><a name=\"startup_hooks\">Startup Hooks</a></h2>\n<dl>", r);
for (i = 0; startup_hooks[i].name; i++) {
ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
startup_hooks[i].name);
ap_rputs("\n </tt>\n</dt>\n", r);
}
("</dl>\n<hr />\n<h2><a name=\"request_hooks\">Request Hooks</a></h2>\n<dl>",
r);
for (i = 0; request_hooks[i].name; i++) {
ap_rprintf(r, "<dt><strong>%s:</strong>\n <br /><tt>\n",
request_hooks[i].name);
ap_rputs("\n </tt>\n</dt>\n", r);
}
ap_rputs("</dl>\n<hr />\n", r);
return 0;
}
static int display_info(request_rec * r)
{
const char *more_info;
const command_rec *cmd;
return DECLINED;
}
if (r->method_number != M_GET) {
return DECLINED;
}
ap_set_content_type(r, "text/html; charset=ISO-8859-1");
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
"<head>\n"
" <title>Server Information</title>\n" "</head>\n", r);
ap_rputs("<body><h1 style=\"text-align: center\">"
"Apache Server Information</h1>\n", r);
if (!r->args) {
ap_rputs("<dl><dt><tt>Subpages:<br />", r);
ap_rputs("<a href=\"?config\">Configuration Files</a>, "
"<a href=\"?server\">Server Settings</a>, "
"<a href=\"?list\">Module List</a>, "
"<a href=\"?hooks\">Active Hooks</a>", r);
ap_rputs("</tt></dt></dl><hr />", r);
ap_rputs("<dl><dt><tt>Sections:<br />", r);
ap_rputs("<a href=\"#modules\">Loaded Modules</a>, "
"<a href=\"#server\">Server Settings</a>, "
"<a href=\"#startup_hooks\">Startup Hooks</a>, "
"<a href=\"#request_hooks\">Request Hooks</a>", r);
ap_rputs("</tt></dt></dl><hr />", r);
ap_rputs("<h2><a name=\"modules\">Loaded Modules</a></h2>"
"<dl><dt><tt>", r);
/* TODO: Sort by Alpha */
ap_rputs(", ", r);
}
}
ap_rputs("</tt></dt></dl><hr />", r);
}
}
}
ap_rputs("<dl><dt><strong>Configuration:</strong>\n", r);
ap_rputs("</dl><hr />", r);
}
else {
int comma = 0;
ap_rprintf(r,
"<dl><dt><a name=\"%s\"><strong>Module Name:</strong></a> "
"<font size=\"+1\"><tt><a href=\"?%s\">%s</a></tt></font></dt>\n",
ap_rputs("<dt><strong>Content handlers:</strong> ", r);
ap_rputs("<tt> <em>yes</em></tt>", r);
}
else {
ap_rputs("<tt> <em>none</em></tt>", r);
}
ap_rputs("</dt>", r);
("<dt><strong>Configuration Phase Participation:</strong>\n",
r);
if (modp->create_dir_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Create Directory Config</tt>", r);
comma = 1;
}
if (modp->merge_dir_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Merge Directory Configs</tt>", r);
comma = 1;
}
if (modp->create_server_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Create Server Config</tt>", r);
comma = 1;
}
if (modp->merge_server_config) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Merge Server Configs</tt>", r);
comma = 1;
}
if (!comma)
ap_rputs("<tt> <em>none</em></tt>", r);
comma = 0;
ap_rputs("</dt>", r);
if (cmd) {
("<dt><strong>Module Directives:</strong></dt>",
r);
while (cmd) {
ap_rprintf(r, "<dd><tt>%s%s - <i>",
}
ap_rputs("</i></tt></dd>\n", r);
}
else {
break;
}
cmd++;
}
("<dt><strong>Current Configuration:</strong></dt>\n",
r);
0);
}
else {
("<dt><strong>Module Directives:</strong> <tt>none</tt></dt>",
r);
}
if (more_info) {
("<dt><strong>Additional Information:</strong>\n</dt><dd>",
r);
ap_rputs("</dd>", r);
}
ap_rputs("</dl><hr />\n", r);
if (r->args) {
break;
}
}
}
ap_rputs("<p><b>No such module</b></p>\n", r);
}
}
}
else {
ap_rputs("<dl><dt>Server Module List</dt>", r);
ap_rputs("<dd>", r);
ap_rputs("</dd>", r);
}
ap_rputs("</dl><hr />", r);
}
ap_rputs("</body></html>\n", r);
/* Done, turn off timeout, close file and return */
return 0;
}
{
&info_module);
return NULL;
}
static const command_rec info_cmds[] = {
"a module name and additional information on that module"),
{NULL}
};
server_rec *s)
{
if (ap_exists_config_define("DUMP_CONFIG"))
return DECLINED;
}
static void register_hooks(apr_pool_t * p)
{
}
AP_DECLARE_MODULE(info) = {
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
create_info_config, /* server config */
merge_info_config, /* merge server config */
info_cmds, /* command apr_table_t */
};