]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
the mailto links on Squid's ERR pages now contain data about the
authorhno <>
Tue, 10 Sep 2002 15:54:52 +0000 (15:54 +0000)
committerhno <>
Tue, 10 Sep 2002 15:54:52 +0000 (15:54 +0000)
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)

ChangeLog
src/cf.data.pre
src/errorpage.cc
src/structs.h

index e33cc8c792979b3158e582563c04b07b28c6b66b..e6b631a4f5561b5069b7434547cb5328b96e3ce8 100644 (file)
--- 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 ():
 
index 4ae46c7e4ce0351480b393a86d5a7c9171c5fd0a..a2b50839d102a2b2b0eaf2c0777efa6027052703 100644 (file)
@@ -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 <A HREF="mailto:%w%W">%w</A>
+DOC_END
+
 
 NAME: deny_info
 TYPE: denyinfo
index ec3cf44e279c853fc29032cdb32b77fe6f9a7b9f..d4ad5032d1206f88e6c683077e11b6b45b4d703f 100644 (file)
@@ -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<BR clear=\"all\">\n"
            "<HR noshade size=\"1px\">\n"
+           "<ADDRESS>\n"
            "Generated %T by %h (%s)\n"
+           "</ADDRESS>\n"
            "</BODY></HTML>\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;
index 24257d945ba987d570f39e99362428f973510fd4..d6e236dfb092d0c85cab1ae1a94c1ad7b3af8d76 100644 (file)
@@ -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 {