]> git.pld-linux.org Git - packages/squid.git/blob - squid-2.5.STABLE2-deny_info_reset.patch
- grant stats user (statistics generators) access to squid logs
[packages/squid.git] / squid-2.5.STABLE2-deny_info_reset.patch
1 Index: squid/src/cf.data.pre
2 diff -c squid/src/cf.data.pre:1.245.2.42 squid/src/cf.data.pre:1.245.2.43
3 *** squid/src/cf.data.pre:1.245.2.42    Sun May 18 15:49:19 2003
4 --- squid/src/cf.data.pre       Wed May 21 08:34:38 2003
5 ***************
6 *** 2612,2617 ****
7 --- 2612,2618 ----
8   DEFAULT: none
9   DOC_START
10         Usage:   deny_info err_page_name acl
11 +       or       deny_info http://... acl
12         Example: deny_info ERR_CUSTOM_ACCESS_DENIED bad_guys
13   
14         This can be used to return a ERR_ page for requests which
15 ***************
16 *** 2621,2626 ****
17 --- 2622,2631 ----
18   
19         You may use ERR_ pages that come with Squid or create your own pages
20         and put them into the configured errors/ directory.
21
22 +       Alternatively you can specify an error URL. The browsers will then
23 +       get redirected (302) to the specified URL. %s in the redirection
24 +       URL will be replaced by the requested URL.
25   
26         Alternatively you can tell Squid to reset the TCP connection
27         by specifying TCP_RESET.
28 Index: squid/src/errorpage.c
29 diff -c squid/src/errorpage.c:1.167.2.6 squid/src/errorpage.c:1.167.2.7
30 *** squid/src/errorpage.c:1.167.2.6     Fri Sep 20 04:28:53 2002
31 --- squid/src/errorpage.c       Wed May 21 08:34:38 2003
32 ***************
33 *** 121,129 ****
34             /* dynamic */
35             ErrorDynamicPageInfo *info = ErrorDynamicPages.items[i - ERR_MAX];
36             assert(info && info->id == i && info->page_name);
37 !           error_text[i] = errorLoadText(info->page_name);
38         }
39 -       assert(error_text[i]);
40       }
41   }
42   
43 --- 121,131 ----
44             /* dynamic */
45             ErrorDynamicPageInfo *info = ErrorDynamicPages.items[i - ERR_MAX];
46             assert(info && info->id == i && info->page_name);
47 !           if (strchr(info->page_name, ':') == NULL) {
48 !               /* Not on redirected errors... */
49 !               error_text[i] = errorLoadText(info->page_name);
50 !           }
51         }
52       }
53   }
54   
55 ***************
56 *** 212,224 ****
57       xfree(info);
58   }
59   
60   int
61   errorReservePageId(const char *page_name)
62   {
63 !     ErrorDynamicPageInfo *info =
64 !     errorDynamicPageInfoCreate(ERR_MAX + ErrorDynamicPages.count, page_name);
65 !     stackPush(&ErrorDynamicPages, info);
66 !     return info->id;
67   }
68   
69   static const char *
70 --- 214,245 ----
71       xfree(info);
72   }
73   
74 + static int
75 + errorPageId(const char *page_name)
76 + {
77 +     int i;
78 +     for (i = 0; i < ERR_MAX; i++) {
79 +       if (strcmp(err_type_str[i], page_name) == 0)
80 +           return i;
81 +     }
82 +     for (i = 0; i < ErrorDynamicPages.count; i++) {
83 +       if (strcmp(((ErrorDynamicPageInfo *) ErrorDynamicPages.items[i - ERR_MAX])->page_name, page_name) == 0)
84 +           return i + ERR_MAX;
85 +     }
86 +     return ERR_NONE;
87 + }
88
89   int
90   errorReservePageId(const char *page_name)
91   {
92 !     ErrorDynamicPageInfo *info;
93 !     int id = errorPageId(page_name);
94 !     if (id == ERR_NONE) {
95 !       info = errorDynamicPageInfoCreate(ERR_MAX + ErrorDynamicPages.count, page_name);
96 !       stackPush(&ErrorDynamicPages, info);
97 !       id = info->id;
98 !     }
99 !     return id;
100   }
101   
102   static const char *
103 ***************
104 *** 579,601 ****
105   errorBuildReply(ErrorState * err)
106   {
107       HttpReply *rep = httpReplyCreate();
108 !     MemBuf content = errorBuildContent(err);
109       http_version_t version;
110       /* no LMT for error pages; error pages expire immediately */
111       httpBuildVersion(&version, 1, 0);
112 !     httpReplySetHeaders(rep, version, err->http_status, NULL, "text/html", content.size, 0, squid_curtime);
113 !     /*
114 !      * include some information for downstream caches. Implicit
115 !      * replaceable content. This isn't quite sufficient. xerrno is not
116 !      * necessarily meaningful to another system, so we really should
117 !      * expand it. Additionally, we should identify ourselves. Someone
118 !      * might want to know. Someone _will_ want to know OTOH, the first
119 !      * X-CACHE-MISS entry should tell us who.
120 !      */
121 !     httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%s %d",
122 !       errorPageName(err->page_id), err->xerrno);
123 !     httpBodySet(&rep->body, &content);
124 !     /* do not memBufClean() the content, it was absorbed by httpBody */
125       return rep;
126   }
127   
128 --- 600,631 ----
129   errorBuildReply(ErrorState * err)
130   {
131       HttpReply *rep = httpReplyCreate();
132 !     const char *name = errorPageName(err->page_id);
133       http_version_t version;
134       /* no LMT for error pages; error pages expire immediately */
135       httpBuildVersion(&version, 1, 0);
136 !     if (strchr(name, ':')) {
137 !       /* Redirection */
138 !       char *quoted_url = rfc1738_escape_part(errorConvert('u', err));
139 !       httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, squid_curtime);
140 !       httpHeaderPutStrf(&rep->header, HDR_LOCATION, name, quoted_url);
141 !       httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%d %s\n", err->http_status, "Access Denied");
142 !     } else {
143 !       MemBuf content = errorBuildContent(err);
144 !       httpReplySetHeaders(rep, version, err->http_status, NULL, "text/html", content.size, 0, squid_curtime);
145 !       /*
146 !        * include some information for downstream caches. Implicit
147 !        * replaceable content. This isn't quite sufficient. xerrno is not
148 !        * necessarily meaningful to another system, so we really should
149 !        * expand it. Additionally, we should identify ourselves. Someone
150 !        * might want to know. Someone _will_ want to know OTOH, the first
151 !        * X-CACHE-MISS entry should tell us who.
152 !        */
153 !       httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%s %d",
154 !           name, err->xerrno);
155 !       httpBodySet(&rep->body, &content);
156 !       /* do not memBufClean() the content, it was absorbed by httpBody */
157 !     }
158       return rep;
159   }
160   
This page took 0.040113 seconds and 3 git commands to generate.