1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

Replace ap_get_server_version with ap_get_server_banner() and

ap_get_server_description().

High-level summary:

The full server version information is now included in the error log at
startup as well as server status reports, irrespective of the setting
of the ServerTokens directive.

Third-party modules must now use ap_get_server_banner() or 
ap_get_server_description() in place of ap_get_server_version().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@440337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeff Trawick
2006-09-05 13:08:15 +00:00
parent 3397848717
commit 743a621e8d
28 changed files with 88 additions and 58 deletions

View File

@@ -2,6 +2,12 @@
Changes with Apache 2.3.0
[Remove entries to the current 2.0 and 2.2 section below, when backported]
*) The full server version information is now included in the error log at
startup as well as server status reports, irrespective of the setting
of the ServerTokens directive. Third-party modules must now use
ap_get_server_banner() or ap_get_server_description() in place of
ap_get_server_version(). [Jeff Trawick]
*) mod_proxy_balancer: Extract stickysession routing information contained as
parameter in the URL correctly. PR 40400.
[Ruediger Pluem, Tomokazu Harada <harada sysrdc.ns-sol.co.jp>]

View File

@@ -121,14 +121,16 @@
* proxy_server (minor)
* 20060110.3 (2.3.0-dev) added inreslist member to proxy_conn_rec (minor)
* 20060110.4 (2.3.0-dev) Added server_scheme member to server_rec (minor)
* 20060905.0 (2.3.0-dev) Replaced ap_get_server_version() with
* ap_get_server_banner() and ap_get_server_description()
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20060110
#define MODULE_MAGIC_NUMBER_MAJOR 20060905
#endif
#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a

View File

@@ -420,13 +420,24 @@ typedef struct {
AP_DECLARE(void) ap_get_server_revision(ap_version_t *version);
/**
* Get the server version string
* @return The server version string
* Get the server banner in a form suitable for sending over the
* network, with the level of information controlled by the
* ServerTokens directive.
* @return The server banner
*/
AP_DECLARE(const char *) ap_get_server_version(void);
AP_DECLARE(const char *) ap_get_server_banner(void);
/**
* Add a component to the version string
* Get the server description in a form suitable for local displays,
* status reports, or logging. This includes the detailed server
* version and information about some modules. It is not affected
* by the ServerTokens directive.
* @return The server description
*/
AP_DECLARE(const char *) ap_get_server_description(void);
/**
* Add a component to the server description and banner strings
* @param pconf The pool to allocate the component from
* @param component The string to add
*/

View File

@@ -1074,7 +1074,7 @@ char *ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r,
/* XXX-Can't get specific SSL info from NetWare */
/*result = ssl_var_lookup_ssl_version(p, var+12);*/
else if (strcEQ(var, "SERVER_SOFTWARE"))
result = ap_get_server_version();
result = ap_get_server_banner();
else if (strcEQ(var, "API_VERSION")) {
result = apr_itoa(p, MODULE_MAGIC_NUMBER);
resdup = FALSE;

View File

@@ -546,7 +546,7 @@ static int x_handler(request_rec *r)
ap_rputs(" </H1>\n", r);
ap_rputs(" <P>\n", r);
ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n",
ap_get_server_version());
ap_get_server_banner());
ap_rputs(" <BR>\n", r);
ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built());
ap_rputs(" </P>\n", r);;

View File

@@ -347,7 +347,7 @@ static int show_server_settings(request_rec * r)
ap_rprintf(r,
"<dl><dt><strong>Server Version:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></dt>\n",
ap_get_server_version());
ap_get_server_description());
ap_rprintf(r,
"<dt><strong>Server Built:</strong> "
"<font size=\"+1\"><tt>%s</tt></font></dt>\n",

View File

@@ -397,7 +397,7 @@ static int status_handler(request_rec *r)
ap_rputs("<h1>Apache Server Status for ", r);
ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);
ap_rvputs(r, "<dl><dt>Server Version: ",
ap_get_server_version(), "</dt>\n", NULL);
ap_get_server_description(), "</dt>\n", NULL);
ap_rvputs(r, "<dt>Server Built: ",
ap_get_server_built(), "\n</dt></dl><hr /><dl>\n", NULL);
ap_rvputs(r, "<dt>Current Time: ",

View File

@@ -735,11 +735,11 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb,
if (server) {
form_header_field(&h, "Server", server);
} else {
form_header_field(&h, "Server", ap_get_server_version());
form_header_field(&h, "Server", ap_get_server_banner());
}
}
else {
form_header_field(&h, "Server", ap_get_server_version());
form_header_field(&h, "Server", ap_get_server_banner());
}
/* unset so we don't send them again */

View File

@@ -2006,7 +2006,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
case 'S':
if (!strcmp(var, "SERVER_SOFTWARE")) {
result = ap_get_server_version();
result = ap_get_server_banner();
}
break;
}

View File

@@ -667,7 +667,7 @@ static int balancer_handler(request_rec *r)
ap_rputs("<body><h1>Load Balancer Manager for ", r);
ap_rvputs(r, ap_get_server_name(r), "</h1>\n\n", NULL);
ap_rvputs(r, "<dl><dt>Server Version: ",
ap_get_server_version(), "</dt>\n", NULL);
ap_get_server_description(), "</dt>\n", NULL);
ap_rvputs(r, "<dt>Server Built: ",
ap_get_server_built(), "\n</dt></dl>\n", NULL);
balancer = (proxy_balancer *)conf->balancers->elts;

View File

@@ -224,7 +224,7 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
"CONNECT %s HTTP/1.0" CRLF, r->uri);
apr_socket_send(sock, buffer, &nbytes);
nbytes = apr_snprintf(buffer, sizeof(buffer),
"Proxy-agent: %s" CRLF CRLF, ap_get_server_version());
"Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
apr_socket_send(sock, buffer, &nbytes);
}
else {
@@ -235,7 +235,7 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
ap_xlate_proto_to_ascii(buffer, nbytes);
apr_socket_send(client_socket, buffer, &nbytes);
nbytes = apr_snprintf(buffer, sizeof(buffer),
"Proxy-agent: %s" CRLF CRLF, ap_get_server_version());
"Proxy-agent: %s" CRLF CRLF, ap_get_server_banner());
ap_xlate_proto_to_ascii(buffer, nbytes);
apr_socket_send(client_socket, buffer, &nbytes);
#if 0
@@ -244,7 +244,7 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
*/
r->status = HTTP_OK;
r->header_only = 1;
apr_table_set(r->headers_out, "Proxy-agent: %s", ap_get_server_version());
apr_table_set(r->headers_out, "Proxy-agent: %s", ap_get_server_banner());
ap_rflush(r);
#endif
}

View File

@@ -1662,7 +1662,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
apr_rfc822_date(dates, r->request_time);
apr_table_setn(r->headers_out, "Date", dates);
apr_table_setn(r->headers_out, "Server", ap_get_server_version());
apr_table_setn(r->headers_out, "Server", ap_get_server_banner());
/* set content-type */
if (dirlisting) {

View File

@@ -192,7 +192,7 @@ char *ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r,
if (strlen(var) > 12 && strcEQn(var, "SSL_VERSION_", 12))
result = ssl_var_lookup_ssl_version(p, var+12);
else if (strcEQ(var, "SERVER_SOFTWARE"))
result = ap_get_server_version();
result = ap_get_server_banner();
else if (strcEQ(var, "API_VERSION")) {
result = apr_itoa(p, MODULE_MAGIC_NUMBER);
resdup = FALSE;

View File

@@ -2580,7 +2580,7 @@ AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r)
if (conf->server_signature == srv_sig_withmail) {
return apr_pstrcat(r->pool, prefix, "<address>",
ap_get_server_version(),
ap_get_server_banner(),
" Server at <a href=\"",
ap_is_url(r->server->server_admin) ? "" : "mailto:",
ap_escape_html(r->pool, r->server->server_admin),
@@ -2590,7 +2590,7 @@ AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r)
"</address>\n", NULL);
}
return apr_pstrcat(r->pool, prefix, "<address>", ap_get_server_version(),
return apr_pstrcat(r->pool, prefix, "<address>", ap_get_server_banner(),
" Server at ",
ap_escape_html(r->pool, ap_get_server_name(r)),
" Port ", sport,
@@ -2605,8 +2605,9 @@ AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r)
* string.
*/
static char *server_version = NULL;
static int version_locked = 0;
static char *server_banner = NULL;
static int banner_locked = 0;
static char *server_description = NULL;
enum server_token_type {
SrvTk_MAJOR, /* eg: Apache/2 */
@@ -2618,11 +2619,12 @@ enum server_token_type {
};
static enum server_token_type ap_server_tokens = SrvTk_FULL;
static apr_status_t reset_version(void *dummy)
static apr_status_t reset_banner(void *dummy)
{
version_locked = 0;
banner_locked = 0;
ap_server_tokens = SrvTk_FULL;
server_version = NULL;
server_banner = NULL;
server_description = NULL;
return APR_SUCCESS;
}
@@ -2634,40 +2636,48 @@ AP_DECLARE(void) ap_get_server_revision(ap_version_t *version)
version->add_string = AP_SERVER_ADD_STRING;
}
AP_DECLARE(const char *) ap_get_server_version(void)
AP_DECLARE(const char *) ap_get_server_description(void)
{
return (server_version ? server_version : AP_SERVER_BASEVERSION);
return server_description ? server_description :
AP_SERVER_BASEVERSION " (" PLATFORM ")";
}
AP_DECLARE(const char *) ap_get_server_banner(void)
{
return server_banner ? server_banner : AP_SERVER_BASEVERSION;
}
AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component)
{
if (! version_locked) {
if (! banner_locked) {
/*
* If the version string is null, register our cleanup to reset the
* pointer on pool destruction. We also know that, if NULL,
* we are adding the original SERVER_BASEVERSION string.
*/
if (server_version == NULL) {
apr_pool_cleanup_register(pconf, NULL, reset_version,
if (server_banner == NULL) {
apr_pool_cleanup_register(pconf, NULL, reset_banner,
apr_pool_cleanup_null);
server_version = apr_pstrdup(pconf, component);
server_banner = apr_pstrdup(pconf, component);
}
else {
/*
* Tack the given component identifier to the end of
* the existing string.
*/
server_version = apr_pstrcat(pconf, server_version, " ",
server_banner = apr_pstrcat(pconf, server_banner, " ",
component, NULL);
}
}
server_description = apr_pstrcat(pconf, server_description, " ",
component, NULL);
}
/*
* This routine adds the real server base identity to the version string,
* This routine adds the real server base identity to the banner string,
* and then locks out changes until the next reconfig.
*/
static void ap_set_version(apr_pool_t *pconf)
static void set_banner(apr_pool_t *pconf)
{
if (ap_server_tokens == SrvTk_PRODUCT_ONLY) {
ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT);
@@ -2686,12 +2696,13 @@ static void ap_set_version(apr_pool_t *pconf)
}
/*
* Lock the server_version string if we're not displaying
* Lock the server_banner string if we're not displaying
* the full set of tokens
*/
if (ap_server_tokens != SrvTk_FULL) {
version_locked++;
banner_locked++;
}
server_description = AP_SERVER_BASEVERSION " (" PLATFORM ")";
}
static const char *set_serv_tokens(cmd_parms *cmd, void *dummy,
@@ -3635,7 +3646,7 @@ static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
authn_ap_auth_type = APR_RETRIEVE_OPTIONAL_FN(authn_ap_auth_type);
authn_ap_auth_name = APR_RETRIEVE_OPTIONAL_FN(authn_ap_auth_name);
ap_set_version(pconf);
set_banner(pconf);
ap_setup_make_content_type(pconf);
return OK;
}

View File

@@ -92,7 +92,7 @@ static void show_mpm_settings(void)
static void show_compile_settings(void)
{
printf("Server version: %s\n", ap_get_server_version());
printf("Server version: %s\n", ap_get_server_description());
printf("Server built: %s\n", ap_get_server_built());
printf("Server's Module Magic Number: %u:%u\n",
MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
@@ -569,7 +569,7 @@ int main(int argc, const char * const argv[])
break;
case 'v':
printf("Server version: %s\n", ap_get_server_version());
printf("Server version: %s\n", ap_get_server_description());
printf("Server built: %s\n", ap_get_server_built());
destroy_and_exit_process(process, 0);

View File

@@ -935,7 +935,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
*/
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());

View File

@@ -1988,7 +1988,7 @@ int ap_mpm_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());

View File

@@ -1529,7 +1529,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -1314,7 +1314,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -1778,7 +1778,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -207,7 +207,7 @@ static char master_main()
int listener_num, num_listeners, slot;
ULONG rc;
printf("%s \n", ap_get_server_version());
printf("%s \n", ap_get_server_description());
set_signals();
if (ap_setup_listeners(ap_server_conf) < 1) {
@@ -270,7 +270,7 @@ static char master_main()
ap_scoreboard_image->global->restart_time = apr_time_now();
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -723,7 +723,7 @@ static void display_settings ()
request_count = 0;
ClearScreen (getscreenhandle());
printf("%s \n", ap_get_server_version());
printf("%s \n", ap_get_server_description());
for (i=0;i<SERVER_NUM_STATUS;i++) {
status_array[i] = 0;
@@ -793,7 +793,7 @@ static void show_server_data()
ap_listen_rec *lr;
module **m;
printf("%s\n", ap_get_server_version());
printf("%s\n", ap_get_server_description());
if (ap_my_addrspace && (ap_my_addrspace[0] != 'O') && (ap_my_addrspace[1] != 'S'))
printf(" Running in address space %s\n", ap_my_addrspace);
@@ -899,7 +899,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
@@ -1204,7 +1204,7 @@ static int CommandLineInterpreter(scr_t screenID, const char *commandLine)
restart();
}
else if (!strnicmp("VERSION",&szcommandLine[iCommandLen],3)) {
printf("Server version: %s\n", ap_get_server_version());
printf("Server version: %s\n", ap_get_server_description());
printf("Server built: %s\n", ap_get_server_built());
}
else if (!strnicmp("MODULES",&szcommandLine[iCommandLen],3)) {

View File

@@ -976,7 +976,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -1705,7 +1705,7 @@ AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s )
/* A real-honest to goodness parent */
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());

View File

@@ -436,7 +436,7 @@ static void set_service_description(void)
/* Time to fix up the description, upon each successful restart
*/
full_description = ap_get_server_version();
full_description = ap_get_server_description();
if ((osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
&& (osver.dwMajorVersion > 4)

View File

@@ -1737,7 +1737,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
ap_get_server_description());
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
"Server built: %s", ap_get_server_built());
#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH

View File

@@ -635,7 +635,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod)
* requests in their logs.
*/
srequest = apr_pstrcat(p, "GET / HTTP/1.0\r\nUser-Agent: ",
ap_get_server_version(),
ap_get_server_banner(),
" (internal dummy connection)\r\n\r\n", NULL);
/* Since some operating systems support buffering of data or entire

View File

@@ -223,7 +223,7 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r)
#endif
apr_table_addn(e, "SERVER_SIGNATURE", ap_psignature("", r));
apr_table_addn(e, "SERVER_SOFTWARE", ap_get_server_version());
apr_table_addn(e, "SERVER_SOFTWARE", ap_get_server_banner());
apr_table_addn(e, "SERVER_NAME",
ap_escape_html(r->pool, ap_get_server_name(r)));
apr_table_addn(e, "SERVER_ADDR", r->connection->local_ip); /* Apache */