mod_info.c revision ab2c1c1c83ec91415565da5a71fbc15d9685caa6
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* 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
*
* Rasmus Lerdorf <rasmus@vex.net>, May 1996
*
* 05.01.96 Initial Version
*
* Lou Langholtz <ldl@usi.utah.edu>, July 1997
*
* 07.11.97 Addition of the AddModuleInfo directive
*
*/
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"
#include "util_script.h"
#include "http_conf_globals.h"
typedef struct {
char *name; /* matching module name */
char *info; /* additional info */
} info_entry;
typedef struct {
typedef struct info_cfg_lines {
char *cmd;
char *line;
struct info_cfg_lines *next;
extern module *top_module;
{
return conf;
}
{
return new;
}
{
const char *s;
char *t;
char *end_buf;
s = string;
t = buf;
/* keep space for \0 byte */
while ((*s) && (t < end_buf)) {
if (*s == '<') {
t += 4;
}
else if (*s == '>') {
t += 4;
}
else if (*s == '&') {
t += 5;
}
else {
*t++ = *s;
}
s++;
}
/* oops, overflowed... don't overwrite */
if (t > end_buf) {
*end_buf = '\0';
}
else {
*t = '\0';
}
return (buf);
}
request_rec *r)
{
char s[MAX_STRING_LEN];
const char *t;
if (!fp) {
"mod_info: couldn't open config file %s",
filename);
return NULL;
}
if (*s == '#') {
continue; /* skip comments */
}
if (!ret) {
}
if (prev) {
}
t = s;
if (*t) {
}
else {
}
}
return (ret);
}
{
char buf[MAX_STRING_LEN];
while (li) {
if (nest) {
}
else {
}
nest++;
continue;
}
if (block_start) {
ap_rputs("<dd><tt>", r);
if (nest == 2) {
ap_rputs(" ", r);
}
ap_rputs(" ", r);
}
ap_rputs("</tt>\n", r);
nest--;
if (!nest) {
block_start = NULL;
}
else {
block_start = li_st;
}
}
else {
nest--;
if (!nest) {
}
}
}
else {
nest--;
if (!nest) {
}
}
continue;
}
while (cmd) {
if (!lab) {
ap_rputs("<dt><strong>", r);
ap_rputs("</strong>\n", r);
lab = 1;
}
ap_rputs("<dd><tt>", r);
ap_rputs(" ", r);
}
ap_rputs("</tt>\n", r);
block_start = li_st;
if (li_se) {
ap_rputs("<dd><tt> ", r);
ap_rputs(" ", r);
}
ap_rputs("</tt>\n", r);
block_start = li_se;
}
}
ap_rputs("<dd><tt>", r);
if (nest) {
ap_rputs(" ", r);
}
if (nest == 2) {
ap_rputs(" ", r);
}
ap_rputs(" <i>", r);
ap_rputs("</i>", r);
}
ap_rputs("</tt>", r);
}
}
else
break;
cmd++;
}
}
}
{
int i;
&info_module);
if (!module_name) {
return 0;
}
}
entry++;
}
return 0;
}
static int display_info(request_rec *r)
{
char *more_info;
int comma = 0;
if (r->method_number != M_GET)
return DECLINED;
r->content_type = "text/html";
if (r->header_only) {
return 0;
}
"<html><head><title>Server Information</title></head>\n", r);
ap_rputs("<body><h1 align=center>Apache Server Information</h1>\n", r);
if (!r->args) {
ap_rputs("<tt><a href=\"#server\">Server Settings</a>, ", r);
ap_rputs(", ", r);
}
}
ap_rputs("</tt><hr>", r);
}
ap_rprintf(r, "<a name=\"server\"><strong>Server Version:</strong> "
"<font size=+1><tt>%s</tt></a></font><br>\n",
ap_rprintf(r, "<strong>Server Built:</strong> "
"<font size=+1><tt>%s</tt></a></font><br>\n",
ap_rprintf(r, "<strong>API Version:</strong> "
"<tt>%d:%d</tt><br>\n",
ap_rprintf(r, "<strong>User/Group:</strong> "
"<tt>%s(%d)/%d</tt><br>\n",
ap_rprintf(r, "<strong>Hostname/port:</strong> "
"<tt>%s:%u</tt><br>\n",
ap_rprintf(r, "<strong>Daemons:</strong> "
"<tt>start: %d "
"min idle: %d "
"max idle: %d "
"max: %d</tt><br>\n",
ap_rprintf(r, "<strong>Max Requests:</strong> "
"<tt>per child: %d "
"keep alive: %s "
"max per connection: %d</tt><br>\n",
ap_rprintf(r, "<strong>Threads:</strong> "
"<tt>per child: %d </tt><br>\n",
ap_rprintf(r, "<strong>Timeouts:</strong> "
"<tt>connection: %d "
"keep-alive: %d</tt><br>",
ap_rprintf(r, "<strong>Server Root:</strong> "
"<tt>%s</tt><br>\n", ap_server_root);
ap_rprintf(r, "<strong>Config File:</strong> "
"<tt>%s</tt><br>\n", ap_server_confname);
ap_rprintf(r, "<strong>PID File:</strong> "
"<tt>%s</tt><br>\n", ap_pid_fname);
ap_rprintf(r, "<strong>Scoreboard File:</strong> "
"<tt>%s</tt><br>\n", ap_scoreboard_fname);
}
ap_rputs("<hr><dl>", r);
ap_rprintf(r, "<dt><a name=\"%s\"><strong>Module Name:</strong> "
"<font size=+1><tt>%s</tt></a></font>\n",
ap_rputs("<dt><strong>Content handlers:</strong>", r);
if (hand) {
while (hand) {
if (hand->content_type) {
}
else {
break;
}
hand++;
ap_rputs(",", r);
}
}
}
else {
ap_rputs("<tt> <EM>none</EM></tt>", r);
}
ap_rputs("<dt><strong>Configuration Phase Participation:</strong> \n",
r);
if (modp->child_init) {
ap_rputs("<tt>Child Init</tt>", r);
comma = 1;
}
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 (modp->child_exit) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Child Exit</tt>", r);
comma = 1;
}
if (!comma)
ap_rputs("<tt> <EM>none</EM></tt>", r);
comma = 0;
ap_rputs("<dt><strong>Request Phase Participation:</strong> \n",
r);
if (modp->post_read_request) {
ap_rputs("<tt>Post-Read Request</tt>", r);
comma = 1;
}
if (modp->header_parser) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Header Parse</tt>", r);
comma = 1;
}
if (modp->translate_handler) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Translate Path</tt>", r);
comma = 1;
}
if (modp->access_checker) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Check Access</tt>", r);
comma = 1;
}
if (modp->ap_check_user_id) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Verify User ID</tt>", r);
comma = 1;
}
if (modp->auth_checker) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Verify User Access</tt>", r);
comma = 1;
}
if (modp->type_checker) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Check Type</tt>", r);
comma = 1;
}
if (modp->fixer_upper) {
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Fixups</tt>", r);
comma = 1;
}
if (comma) {
ap_rputs(", ", r);
}
ap_rputs("<tt>Logging</tt>", r);
comma = 1;
}
if (!comma)
ap_rputs("<tt> <EM>none</EM></tt>", r);
comma = 0;
ap_rputs("<dt><strong>Module Directives:</strong> ", r);
if (cmd) {
while (cmd) {
ap_rprintf(r, "<dd><tt>%s - <i>",
}
ap_rputs("</i></tt>\n", r);
}
else {
break;
}
cmd++;
}
ap_rputs("<dt><strong>Current Configuration:</strong>\n", r);
"httpd.conf");
"srm.conf");
"access.conf");
}
else {
ap_rputs("<tt> none</tt>\n", r);
}
if (more_info) {
ap_rputs("<dt><strong>Additional Information:</strong>\n<dd>",
r);
}
ap_rputs("<dt><hr>\n", r);
if (r->args) {
break;
}
}
}
ap_rputs("<b>No such module</b>\n", r);
}
}
else {
ap_rputs("<br>", r);
}
}
}
ap_rputs("</dl>\n", r);
ap_rputs("</body></html>\n", r);
/* Done, turn off timeout, close file and return */
return 0;
}
char *info)
{
&info_module);
return NULL;
}
static const command_rec info_cmds[] =
{
"a module name and additional information on that module"},
{NULL}
};
static const handler_rec info_handlers[] =
{
{"server-info", display_info},
{NULL}
};
{
NULL, /* initializer */
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 ap_table_t */
info_handlers, /* handlers */
NULL, /* filename translation */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* post read-request */
};