* 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
*
*/
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_lib.h"
+#define APR_WANT_STRFUNC
+#include "apr_want.h"
+
#define CORE_PRIVATE
#include "httpd.h"
#include "http_protocol.h"
#include "http_request.h"
#include "util_script.h"
-#include "apr_strings.h"
-#include "apr_lib.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
#include "ap_mpm.h"
typedef struct
thisfn = ap_escape_html(r->pool, thisfn);
ap_rprintf(r, "<dd><tt><strong>In file: %s</strong></tt></dd>\n",
thisfn);
- ap_set_module_config(r->request_config, &info_module, thisfn);
+ ap_set_module_config(r->request_config, &info_module,
+ (void *) thisfn);
}
ap_rputs("<dd><tt>", r);
hook_get_t get;
} hook_lookup_t;
+/* TODO: Find Any Missing Hooks */
static hook_lookup_t request_hooks[] = {
{"Post-Read Request", ap_hook_get_post_read_request},
{"Header Parse", ap_hook_get_header_parser},
return 0;
}
+static int show_server_settings(request_rec *r)
+{
+ server_rec *serv = r->server;
+ int max_daemons, forked, threaded;
+
+ ap_rputs("<a name=\"server\"<h2>Server Settings</h2></a>", r);
+ ap_rprintf(r,
+ "<dl><dt><strong>Server Version:</strong> "
+ "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
+ ap_get_server_version());
+ ap_rprintf(r,
+ "<dt><strong>Server Built:</strong> "
+ "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
+ ap_get_server_built());
+ ap_rprintf(r,
+ "<dt><strong>Module Magic Number:</strong> "
+ "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
+ MODULE_MAGIC_NUMBER_MINOR);
+ ap_rprintf(r,
+ "<dt><strong>Hostname/port:</strong> "
+ "<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>",
+ (int) (apr_time_sec(serv->timeout)),
+ (int) (apr_time_sec(serv->timeout)));
+ ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
+ ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded);
+ ap_mpm_query(AP_MPMQ_IS_FORKED, &forked);
+ 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",
+ max_daemons, threaded ? "yes" : "no", forked ? "yes" : "no");
+ 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> "
+ "<tt>%s</tt></dt>\n", ap_conftree->filename);
+
+ ap_rputs("<dt><strong>Server Built With:</strong>\n<tt>\n<pre>", r);
+
+ /* TODO: Not all of these 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
+
+#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
+ ap_rputs(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n", r);
+#endif
+
+#ifdef OS
+ ap_rputs(" -D OS=\"" OS "\"\n", r);
+#endif
+
+#ifdef APACHE_MPM_DIR
+ ap_rputs(" -D APACHE_MPM_DIR=\"" APACHE_MPM_DIR "\"\n", r);
+#endif
+
+#ifdef HAVE_SHMGET
+ ap_rputs(" -D HAVE_SHMGET\n", r);
+#endif
+
+#if APR_FILE_BASED_SHM
+ 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
+
+#if APR_USE_FLOCK_SERIALIZE
+ ap_rputs(" -D APR_USE_FLOCK_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_SYSVSEM_SERIALIZE
+ ap_rputs(" -D APR_USE_SYSVSEM_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_POSIXSEM_SERIALIZE
+ ap_rputs(" -D APR_USE_POSIXSEM_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_FCNTL_SERIALIZE
+ ap_rputs(" -D APR_USE_FCNTL_SERIALIZE\n", r);
+#endif
+
+#if APR_USE_PROC_PTHREAD_SERIALIZE
+ ap_rputs(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n", r);
+#endif
+#if APR_PROCESS_LOCK_IS_GLOBAL
+ ap_rputs(" -D APR_PROCESS_LOCK_IS_GLOBAL\n", r);
+#endif
+
+#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+ ap_rputs(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n", r);
+#endif
+
+#if APR_HAS_OTHER_CHILD
+ 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
+ ap_rputs(" -D PIPE_BUF=%ld\n", (long) PIPE_BUF, r);
+#endif
+#endif
+
+#if APR_CHARSET_EBCDIC
+ ap_rputs(" -D APR_CHARSET_EBCDIC\n", r);
+#endif
+
+#ifdef NEED_HASHBANG_EMUL
+ ap_rputs(" -D NEED_HASHBANG_EMUL\n", r);
+#endif
+
+#ifdef SHARED_CORE
+ ap_rputs(" -D SHARED_CORE\n", r);
+#endif
+
+/* This list displays the compiled in default paths: */
+#ifdef HTTPD_ROOT
+ ap_rputs(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n", r);
+#endif
+
+#ifdef SUEXEC_BIN
+ ap_rputs(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n", r);
+#endif
+
+#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
+ ap_rputs(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n", r);
+#endif
+
+#ifdef DEFAULT_PIDLOG
+ ap_rputs(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n", r);
+#endif
+
+#ifdef DEFAULT_SCOREBOARD
+ ap_rputs(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n", r);
+#endif
+
+#ifdef DEFAULT_LOCKFILE
+ ap_rputs(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n", r);
+#endif
+
+#ifdef DEFAULT_ERRORLOG
+ ap_rputs(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n", r);
+#endif
+
+
+#ifdef AP_TYPES_CONFIG_FILE
+ ap_rputs(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n", r);
+#endif
+
+#ifdef SERVER_CONFIG_FILE
+ ap_rputs(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n", r);
+#endif
+ ap_rputs("</pre></tt></dt>\n", r);
+ ap_rputs("</dl><hr />", r);
+ return 0;
+}
+
+static int dump_a_hook(request_rec *r, hook_get_t hook_get)
+{
+ int i;
+ char qs;
+ hook_struct_t *elts;
+ apr_array_header_t *hooks = hook_get();
+
+ if (!hooks) {
+ return 0;
+ }
+
+ if (r->args && strcasecmp(r->args, "hooks") == 0) {
+ qs = '?';
+ }
+ else {
+ qs = '#';
+ }
+
+ elts = (hook_struct_t *) hooks->elts;
+
+ for (i = 0; i < hooks->nelts; i++) {
+ ap_rprintf(r,
+ " %02d <a href=\"%c%s\">%s</a> <br/>",
+ elts[i].nOrder, qs, elts[i].szName, elts[i].szName);
+ }
+ return 0;
+}
+
+static int show_hooks_settings(request_rec *r)
+{
+ int i;
+ ap_rputs("<a name=\"hooks\"><h2>Active Hooks</h2></a>\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);
+ dump_a_hook(r, request_hooks[i].get);
+ ap_rputs("\n </tt>\n</dt>\n", r);
+ }
+
+ ap_rputs("</dl>\n<hr />\n", r);
+
+ return 0;
+}
+
static int display_info(request_rec *r)
{
module *modp = NULL;
+ server_rec *serv = r->server;
const char *more_info;
const command_rec *cmd = NULL;
-#ifdef NEVERMORE
- const handler_rec *hand = NULL;
-#endif
- server_rec *serv = r->server;
int comma = 0;
if (strcmp(r->handler, "server-info"))
ap_set_content_type(r, "text/html");
- ap_rputs(DOCTYPE_HTML_3_2
- "<html><head><title>Server Information</title></head>\n", r);
- ap_rputs("<body><h1 align=\"center\">Apache Server Information</h1>\n",
+ ap_rputs(DOCTYPE_XHTML_1_0T
+ "<html>\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 || strcasecmp(r->args, "list")) {
if (!r->args) {
- ap_rputs("<dl><dt><tt><a href=\"#server\">Server Settings</a>, ",
- r);
+ 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=\"#server\">Server Settings</a>, "
+ "<a href=\"#hooks\">Active Hooks</a>", r);
+ ap_rputs("</tt></dt></dl><hr />", r);
+
+ ap_rputs("<dl><dt><tt>Loaded Modules: <br />", r);
+ /* TODO: Sort by Alpha */
for (modp = ap_top_module; modp; modp = modp->next) {
ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name,
modp->name);
}
}
ap_rputs("</tt></dt></dl><hr />", r);
-
}
+
if (!r->args || !strcasecmp(r->args, "server")) {
- int max_daemons, forked, threaded;
-
- ap_rprintf(r,
- "<dl><dt><a name=\"server\"><strong>Server Version:</strong> "
- "<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
- ap_get_server_version());
- ap_rprintf(r,
- "<dt><strong>Server Built:</strong> "
- "<font size=\"+1\"><tt>%s</tt></font></dt>\n",
- ap_get_server_built());
- ap_rprintf(r,
- "<dt><strong>API Version:</strong> "
- "<tt>%d:%d</tt></dt>\n", MODULE_MAGIC_NUMBER_MAJOR,
- MODULE_MAGIC_NUMBER_MINOR);
- ap_rprintf(r,
- "<dt><strong>Hostname/port:</strong> "
- "<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>",
- (int) (apr_time_sec(serv->timeout)),
- (int) (apr_time_sec(serv->timeout)));
- ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
- ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded);
- ap_mpm_query(AP_MPMQ_IS_FORKED, &forked);
- 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",
- max_daemons, threaded ? "yes" : "no",
- forked ? "yes" : "no");
- ap_rprintf(r,
- "<dt><strong>Server Root:</strong> "
- "<tt>%s</tt></dt>\n", ap_server_root);
- ap_rprintf(r,
- "<dt><strong>Config File:</strong> "
- "<tt>%s</tt></dt>\n", ap_conftree->filename);
- ap_rputs("</dl><hr />", r);
+ show_server_settings(r);
}
+
+ if (!r->args || !strcasecmp(r->args, "hooks")) {
+ show_hooks_settings(r);
+ }
+
if (r->args && 0 == strcasecmp(r->args, "config")) {
ap_rputs("<dl><dt><strong>Configuration:</strong>\n", r);
mod_info_module_cmds(r, NULL, ap_conftree, 0, 0);
for (modp = ap_top_module; modp; modp = modp->next) {
if (!r->args || !strcasecmp(modp->name, r->args)) {
ap_rprintf(r,
- "<dl><dt><a name=\"%s\"><strong>Module Name:</strong> "
- "<font size=\"+1\"><tt>%s</tt></font></a></dt>\n",
- modp->name, modp->name);
+ "<dl><dt><a name=\"%s\"><strong>Module Name:</strong></a> "
+ "<font size=\"+1\"><tt><a href=\"?%s\">%s</a></tt></font></dt>\n",
+ modp->name, modp->name, modp->name);
ap_rputs("<dt><strong>Content handlers:</strong> ", r);
-#ifdef NEVERMORE
- hand = modp->handlers;
- if (hand) {
- while (hand) {
- if (hand->content_type) {
- ap_rprintf(r, " <tt>%s</tt>\n",
- hand->content_type);
- }
- else {
- break;
- }
- hand++;
- if (hand && hand->content_type) {
- ap_rputs(",", r);
- }
- }
- }
- else {
- ap_rputs("<tt> <em>none</em></tt>", r);
- }
-#else
+
if (module_find_hook(modp, ap_hook_get_handler)) {
ap_rputs("<tt> <em>yes</em></tt>", r);
}
else {
ap_rputs("<tt> <em>none</em></tt>", r);
}
-#endif
+
ap_rputs("</dt>", r);
ap_rputs
("<dt><strong>Configuration Phase Participation:</strong>\n",