From: Jim Jagielski Date: Fri, 28 Aug 2009 17:37:12 +0000 (+0000) Subject: And additional ServerTokens improvement... X-Git-Tag: 2.3.3~354 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4cffc0e157f1c67d46b71ce0280c339c4c5952b3;p=thirdparty%2Fapache%2Fhttpd.git And additional ServerTokens improvement... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@808965 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index d7248aff27c..b80a023894b 100644 --- a/CHANGES +++ b/CHANGES @@ -3,8 +3,9 @@ Changes with Apache 2.3.3 *) ServerTokens now accepts 'Off' which disables sending of - Server: header and sets SERVER_SOFTWARE to empty. - [Jim Jagielski] + Server: header and sets SERVER_SOFTWARE to empty. It also accepts + 'Set' which allows the user to specify any string as the Server: + name. [Jim Jagielski] *) mod_headers: generalise the envclause to support expression evaluation with ap_expr parser [Nick Kew] diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml index 089a7b97f13..83a04aae1a3 100644 --- a/docs/manual/mod/core.xml +++ b/docs/manual/mod/core.xml @@ -2903,6 +2903,14 @@ header
Server sends (e.g.): Server: Apache/2.0.41 (Unix)
+
ServerTokens Set "String"
+ +
Server sends user specified string + (e.g.): Server: MyWebServer/8.6
+ Note: The string must be in quotes if + there are any embedded spaces. +
+
ServerTokens Full (or not specified)
Server sends (e.g.): Server: Apache/2.0.41 diff --git a/server/core.c b/server/core.c index 2656bd2cadc..a72c34e7de7 100644 --- a/server/core.c +++ b/server/core.c @@ -2677,6 +2677,7 @@ AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r) static char *server_banner = NULL; static int banner_locked = 0; static char *server_description = NULL; +static char *user_server_banner = NULL; enum server_token_type { SrvTk_MAJOR, /* eg: Apache/2 */ @@ -2685,7 +2686,8 @@ enum server_token_type { SrvTk_OS, /* eg: Apache/2.0.41 (UNIX) */ SrvTk_FULL, /* eg: Apache/2.0.41 (UNIX) PHP/4.2.2 FooBar/1.2b */ SrvTk_PRODUCT_ONLY, /* eg: Apache */ - SrvTk_OFF /* eg: */ + SrvTk_OFF, /* eg: */ + SrvTk_SET }; static enum server_token_type ap_server_tokens = SrvTk_FULL; @@ -2749,7 +2751,10 @@ AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *compone */ static void set_banner(apr_pool_t *pconf) { - if (ap_server_tokens == SrvTk_OFF) { + if (ap_server_tokens == SrvTk_SET) { + ap_add_version_component(pconf, user_server_banner); + } + else if (ap_server_tokens == SrvTk_OFF) { ap_add_version_component(pconf, ""); } else if (ap_server_tokens == SrvTk_PRODUCT_ONLY) { @@ -2779,7 +2784,7 @@ static void set_banner(apr_pool_t *pconf) } static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg1, const char *arg2) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -2787,22 +2792,26 @@ static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, return err; } - if (!strcasecmp(arg, "Off")) { + if (!strcasecmp(arg1, "Set")) { + ap_server_tokens = SrvTk_SET; + user_server_banner = (arg2 ? apr_pstrdup(cmd->pool, arg2) : ""); + } + else if (!strcasecmp(arg1, "Off")) { ap_server_tokens = SrvTk_OFF; } - else if (!strcasecmp(arg, "OS")) { + else if (!strcasecmp(arg1, "OS")) { ap_server_tokens = SrvTk_OS; } - else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) { + else if (!strcasecmp(arg1, "Min") || !strcasecmp(arg1, "Minimal")) { ap_server_tokens = SrvTk_MINIMAL; } - else if (!strcasecmp(arg, "Major")) { + else if (!strcasecmp(arg1, "Major")) { ap_server_tokens = SrvTk_MAJOR; } - else if (!strcasecmp(arg, "Minor") ) { + else if (!strcasecmp(arg1, "Minor") ) { ap_server_tokens = SrvTk_MINOR; } - else if (!strcasecmp(arg, "Prod") || !strcasecmp(arg, "ProductOnly")) { + else if (!strcasecmp(arg1, "Prod") || !strcasecmp(arg1, "ProductOnly")) { ap_server_tokens = SrvTk_PRODUCT_ONLY; } else { @@ -3310,8 +3319,9 @@ AP_INIT_TAKE1("LogLevel", set_loglevel, NULL, RSRC_CONF, "Level of verbosity in error logging"), AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF, "A numeric IP address:port, or the name of a host"), -AP_INIT_TAKE1("ServerTokens", set_serv_tokens, NULL, RSRC_CONF, - "Determine tokens displayed in the Server: header - Min(imal), Major, Minor, Prod, OS, Off or Full"), +AP_INIT_TAKE12("ServerTokens", set_serv_tokens, NULL, RSRC_CONF, + "Determine tokens displayed in the Server: header - Min(imal), " + "Major, Minor, Prod, OS, Off, Set or Full"), AP_INIT_TAKE1("LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF, "Limit on maximum size of an HTTP request line"), AP_INIT_TAKE1("LimitRequestFieldsize", set_limit_req_fieldsize, NULL,