From: hno <> Date: Tue, 10 Sep 2002 15:54:52 +0000 (+0000) Subject: the mailto links on Squid's ERR pages now contain data about the X-Git-Tag: SQUID_3_0_PRE1~766 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5fb34f1920bc7af3a1f3476f979dbe6aa9d2c94;p=thirdparty%2Fsquid.git the mailto links on Squid's ERR pages now contain data about the cccurred error by default, so that the email will contain this data in its body. This feature can be disabled via the email_err_data directive. (Clemens Löser) --- diff --git a/ChangeLog b/ChangeLog index e33cc8c792..e6b631a4f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,11 @@ Changes to squid-2.6 (): (Robert Cohren) - Nuked num32 types, and made type detection more robust by the use of typedefs rather than #defines. + - the mailto links on Squid's ERR pages now contain data about the + occurred error by default, so that the email will contain this data in + its body. This feature can be disabled via the email_err_data directive. + (Clemens Löser) + Changes to squid-2.5 (): diff --git a/src/cf.data.pre b/src/cf.data.pre index 4ae46c7e4c..a2b50839d1 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.283 2002/09/04 13:33:13 hno Exp $ +# $Id: cf.data.pre,v 1.284 2002/09/10 09:54:52 hno Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2662,6 +2662,18 @@ DOC_START insert a %L tag in the error template file. DOC_END +NAME: email_err_data +COMMENT: on|off +TYPE: onoff +LOC: Config.onoff.emailErrData +DEFAULT: on +DOC_START + If enabled, information about the occurred error will be + included in the mailto links of the ERR pages (if %W is set) + so that the email body then contains the data. + Syntax is %w +DOC_END + NAME: deny_info TYPE: denyinfo diff --git a/src/errorpage.cc b/src/errorpage.cc index ec3cf44e27..d4ad5032d1 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.174 2002/07/18 23:43:14 hno Exp $ + * $Id: errorpage.cc,v 1.175 2002/09/10 09:54:53 hno Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -65,7 +65,9 @@ static const struct { ERR_SQUID_SIGNATURE, "\n
\n" "
\n" + "
\n" "Generated %T by %h (%s)\n" + "
\n" "\n" }, { @@ -88,6 +90,7 @@ static const char *errorFindHardText(err_type type); static ErrorDynamicPageInfo *errorDynamicPageInfoCreate(int id, const char *page_name); static void errorDynamicPageInfoDestroy(ErrorDynamicPageInfo * info); static MemBuf errorBuildContent(ErrorState * err); +static int errorDump(ErrorState * err, MemBuf * mb); static const char *errorConvert(char token, ErrorState * err); static CWCB errorSendComplete; @@ -407,6 +410,71 @@ errorStateFree(ErrorState * err) cbdataFree(err); } +static int +errorDump(ErrorState * err, MemBuf * mb) +{ + request_t *r = err->request; + MemBuf str = MemBufNULL; + const char *p = NULL; /* takes priority over mb if set */ + memBufReset(&str); + /* email subject line */ + memBufPrintf(&str, "CacheErrorInfo - %s", errorPageName(err->type)); + memBufPrintf(mb, "?subject=%s", rfc1738_escape_part(str.buf)); + memBufReset(&str); + /* email body */ + memBufPrintf(&str, "CacheHost: %s\r\n", getMyHostname()); + /* - Err Msgs */ + memBufPrintf(&str, "ErrPage: %s\r\n", errorPageName(err->type)); + if (err->xerrno) { + memBufPrintf(&str, "Err: (%d) %s\r\n", err->xerrno, strerror(err->xerrno)); + } else { + memBufPrintf(&str, "Err: [none]\r\n"); + } + if (authenticateAuthUserRequestMessage(err->auth_user_request)) { + memBufPrintf(&str, "extAuth ErrMsg: %s\r\n", authenticateAuthUserRequestMessage(err->auth_user_request)); + } + if (err->dnsserver_msg) { + memBufPrintf(&str, "DNS Server ErrMsg: %s\r\n", err->dnsserver_msg); + } + /* - TimeStamp */ + memBufPrintf(&str, "TimeStamp: %s\r\n\r\n", mkrfc1123(squid_curtime)); + /* - IP stuff */ + memBufPrintf(&str, "ClientIP: %s\r\n", inet_ntoa(err->src_addr)); + if (err->host) { + memBufPrintf(&str, "ServerIP: %s\r\n", err->host); + } + memBufPrintf(&str, "\r\n"); + /* - HTTP stuff */ + memBufPrintf(&str, "HTTP Request:\r\n"); + if (NULL != r) { + Packer p; + memBufPrintf(&str, "%s %s HTTP/%d.%d\n", + RequestMethodStr[r->method], + strLen(r->urlpath) ? strBuf(r->urlpath) : "/", + r->http_ver.major, r->http_ver.minor); + packerToMemInit(&p, &str); + httpHeaderPackInto(&r->header, &p); + packerClean(&p); + } else if (err->request_hdrs) { + p = err->request_hdrs; + } else { + p = "[none]"; + } + memBufPrintf(&str, "\r\n"); + /* - FTP stuff */ + if (err->ftp.request) { + memBufPrintf(&str, "FTP Request: %s\r\n", err->ftp.request); + memBufPrintf(&str, "FTP Reply: %s\r\n", err->ftp.reply); + memBufPrintf(&str, "FTP Msg: "); + wordlistCat(err->ftp.server_msg, &str); + memBufPrintf(&str, "\r\n"); + } + memBufPrintf(&str, "\r\n"); + memBufPrintf(mb, "&body=%s", rfc1738_escape_part(str.buf)); + memBufClean(&str); + return 0; +} + #define CVT_BUF_SZ 512 /* @@ -435,6 +503,7 @@ errorStateFree(ErrorState * err) * U - URL without password x * u - URL with password x * w - cachemgr email address x + * W - error data (to be included in the mailto links) * z - dns server error message x */ @@ -572,6 +641,10 @@ errorConvert(char token, ErrorState * err) else p = "[unknown]"; break; + case 'W': + if (Config.adminEmail && Config.onoff.emailErrData) + errorDump(err, &mb); + break; case 'z': if (err->dnsserver_msg) p = err->dnsserver_msg; diff --git a/src/structs.h b/src/structs.h index 24257d945b..d6e236dfb0 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.427 2002/09/07 23:11:04 hno Exp $ + * $Id: structs.h,v 1.428 2002/09/10 09:54:53 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -590,6 +590,7 @@ struct _SquidConfig { int pipeline_prefetch; int check_hostnames; int via; + int emailErrData; } onoff; acl *aclList; struct {