From: serassio <> Date: Sun, 1 May 2005 14:11:47 +0000 (+0000) Subject: This patch adds the capability to suppress the version information in X-Git-Tag: SQUID_3_0_PRE4~786 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3caee79958007154751162f8178a1829f876408;p=thirdparty%2Fsquid.git This patch adds the capability to suppress the version information in the HTTP server headers and in the HTML error pages. New squid.conf directive: httpd_suppress_version_string on | off (default on) Based on contribution from Nathan R. Valentine (thanks !!!) --- diff --git a/src/HttpReply.cc b/src/HttpReply.cc index ad557ca995..dce639413d 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.70 2004/12/21 17:52:53 robertc Exp $ + * $Id: HttpReply.cc,v 1.71 2005/05/01 08:11:47 serassio Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -273,7 +273,7 @@ httpReplySetHeaders(HttpReply * reply, HttpVersion ver, http_status status, cons assert(reply); httpStatusLineSet(&reply->sline, ver, status, reason); hdr = &reply->header; - httpHeaderPutStr(hdr, HDR_SERVER, full_appname_string); + httpHeaderPutStr(hdr, HDR_SERVER, visible_appname_string); httpHeaderPutStr(hdr, HDR_MIME_VERSION, "1.0"); httpHeaderPutTime(hdr, HDR_DATE, squid_curtime); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index deea028773..6b82af4288 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.471 2005/04/25 15:46:35 serassio Exp $ + * $Id: cache_cf.cc,v 1.472 2005/05/01 08:11:47 serassio Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -410,7 +410,13 @@ configDoConfigure(void) Config.onoff.announce = 0; } + if (Config.onoff.httpd_suppress_version_string) + visible_appname_string = (char *)appname_string; + else + visible_appname_string = (char *)full_appname_string; + #if USE_DNSSERVERS + if (Config.dnsChildren < 1) fatal("No dnsservers allocated"); @@ -434,7 +440,7 @@ configDoConfigure(void) snprintf(ThisCache, sizeof(ThisCache), "%s (%s)", uniqueHostname(), - full_appname_string); + visible_appname_string); /* * the extra space is for loop detection in client_side.c -- we search @@ -442,7 +448,7 @@ configDoConfigure(void) */ snprintf(ThisCache2, sizeof(ThisCache), " %s (%s)", uniqueHostname(), - full_appname_string); + visible_appname_string); if (!Config.udpMaxHitObjsz || Config.udpMaxHitObjsz > SQUID_UDP_SO_SNDBUF) Config.udpMaxHitObjsz = SQUID_UDP_SO_SNDBUF; diff --git a/src/cf.data.pre b/src/cf.data.pre index b0c05461dd..f66e710322 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.386 2005/04/24 14:00:45 serassio Exp $ +# $Id: cf.data.pre,v 1.387 2005/05/01 08:11:48 serassio Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2949,6 +2949,16 @@ DOC_START DOC_END +NAME: httpd_suppress_version_string +COMMENT: on|off +TYPE: onoff +DEFAULT: off +LOC: Config.onoff.httpd_suppress_version_string +DOC_START + Suppress Squid version string info in HTTP headers and HTML error pages. +DOC_END + + NAME: visible_hostname TYPE: string LOC: Config.visibleHostname diff --git a/src/errorpage.cc b/src/errorpage.cc index 93725a0da4..6a30bc23d9 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.200 2005/04/23 13:20:30 serassio Exp $ + * $Id: errorpage.cc,v 1.201 2005/05/01 08:11:48 serassio Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -739,7 +739,7 @@ errorConvert(char token, ErrorState * err) break; case 's': - p = full_appname_string; + p = visible_appname_string; break; case 'S': diff --git a/src/ftp.cc b/src/ftp.cc index 3d4fd6ab12..f16bb74c0d 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.361 2005/03/05 14:51:52 serassio Exp $ + * $Id: ftp.cc,v 1.362 2005/05/01 08:11:48 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -567,7 +567,7 @@ ftpListingFinish(FtpStateData * ftpState) storeAppendPrintf(e, "Generated %s by %s (%s)\n", mkrfc1123(squid_curtime), getMyHostname(), - full_appname_string); + visible_appname_string); storeAppendPrintf(e, "\n"); storeBufferFlush(e); } diff --git a/src/globals.h b/src/globals.h index 3c5bac7811..c0210c26b9 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.131 2005/04/23 12:28:11 serassio Exp $ + * $Id: globals.h,v 1.132 2005/05/01 08:11:48 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -56,6 +56,8 @@ extern const char *const localhost; /* "127.0.0.1" */ extern const char *const null_string; /* "" */ extern const char *const version_string; /* VERSION */ extern const char *const full_appname_string; /* PACKAGE "/" VERSION */ +extern const char *const appname_string; /* PACKAGE */ +extern char * visible_appname_string; extern const char *const w_space; /* " \t\n\r" */ extern const char *fdTypeStr[]; extern const char *hier_strings[]; diff --git a/src/gopher.cc b/src/gopher.cc index 92208742d8..57e95fca63 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.186 2005/01/28 09:23:41 serassio Exp $ + * $Id: gopher.cc,v 1.187 2005/05/01 08:11:48 serassio Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -299,7 +299,7 @@ gopherHTMLFooter(StoreEntry * e) storeAppendPrintf(e, "Generated %s by %s (%s)\n", mkrfc1123(squid_curtime), getMyHostname(), - full_appname_string); + visible_appname_string); storeAppendPrintf(e, "\n"); } diff --git a/src/structs.h b/src/structs.h index 0508a4f1ba..6fa91ef537 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.517 2005/04/23 14:49:41 serassio Exp $ + * $Id: structs.h,v 1.518 2005/05/01 08:11:48 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -382,6 +382,7 @@ struct _SquidConfig Log; char *adminEmail; char *effectiveUser; + char *visible_appname_string; char *effectiveGroup; struct @@ -576,6 +577,7 @@ struct _SquidConfig int check_hostnames; int via; int emailErrData; + int httpd_suppress_version_string; } onoff;