FilledChecklist.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
10 #include "acl/FilledChecklist.h"
11 #include "client_side.h"
12 #include "comm/Connection.h"
13 #include "comm/forward.h"
14 #include "ExternalACLEntry.h"
15 #include "http/Stream.h"
16 #include "HttpReply.h"
17 #include "HttpRequest.h"
18 #include "SquidConfig.h"
19 #if USE_AUTH
20 #include "auth/AclProxyAuth.h"
21 #include "auth/UserRequest.h"
22 #endif
23 
25 
27  dst_rdns(NULL),
28  request (NULL),
29  reply (NULL),
30 #if USE_AUTH
31  auth_user_request (NULL),
32 #endif
33 #if SQUID_SNMP
34  snmp_community(NULL),
35 #endif
36 #if USE_OPENSSL
37  sslErrors(NULL),
38 #endif
39  requestErrorType(ERR_MAX),
40  conn_(NULL),
41  fd_(-1),
42  destinationDomainChecked_(false),
43  sourceDomainChecked_(false)
44 {
45  my_addr.setEmpty();
48  rfc931[0] = '\0';
49 }
50 
52 {
54 
55  safe_free(dst_rdns); // created by xstrdup().
56 
58 
60 
62 
63 #if USE_OPENSSL
65 #endif
66 
67  debugs(28, 4, HERE << "ACLFilledChecklist destroyed " << this);
68 }
69 
70 static void
71 showDebugWarning(const char *msg)
72 {
73  static uint16_t count = 0;
74  if (count > 10)
75  return;
76 
77  ++count;
78  debugs(28, DBG_IMPORTANT, "ALE missing " << msg);
79 }
80 
81 void
83 {
84  // make sure the ALE fields used by Format::assemble to
85  // fill the old external_acl_type codes are set if any
86  // data on them exists in the Checklist
87 
88  if (!al->cache.port && conn()) {
89  showDebugWarning("listening port");
90  al->cache.port = conn()->port;
91  }
92 
93  if (request) {
94  if (!al->request) {
95  showDebugWarning("HttpRequest object");
96  al->request = request;
98  }
99 
100  if (!al->adapted_request) {
101  showDebugWarning("adapted HttpRequest object");
104  }
105 
106  if (al->url.isEmpty()) {
107  showDebugWarning("URL");
108  al->url = request->url.absolute();
109  }
110  }
111 
112  if (reply && !al->reply) {
113  showDebugWarning("HttpReply object");
114  al->reply = reply;
115  HTTPMSGLOCK(al->reply);
116  }
117 
118 #if USE_IDENT
119  if (*rfc931 && !al->cache.rfc931) {
120  showDebugWarning("IDENT");
122  }
123 #endif
124 }
125 
128 {
129  return cbdataReferenceValid(conn_) ? conn_ : nullptr;
130 }
131 
132 void
134 {
135  if (conn() == aConn)
136  return;
137  assert (conn() == NULL);
138  conn_ = cbdataReference(aConn);
139 }
140 
141 int
143 {
144  const auto c = conn();
145  return (c && c->clientConnection) ? c->clientConnection->fd : fd_;
146 }
147 
148 void
149 ACLFilledChecklist::fd(int aDescriptor)
150 {
151  const auto c = conn();
152  assert(!c || !c->clientConnection || c->clientConnection->fd == aDescriptor);
153  fd_ = aDescriptor;
154 }
155 
156 bool
158 {
160 }
161 
162 void
164 {
167 }
168 
169 bool
171 {
172  return sourceDomainChecked_;
173 }
174 
175 void
177 {
179  sourceDomainChecked_ = true;
180 }
181 
182 /*
183  * There are two common ACLFilledChecklist lifecycles paths:
184  *
185  * A) Using aclCheckFast(): The caller creates an ACLFilledChecklist object
186  * on stack and calls aclCheckFast().
187  *
188  * B) Using aclNBCheck() and callbacks: The caller allocates an
189  * ACLFilledChecklist object (via operator new) and passes it to
190  * aclNBCheck(). Control eventually passes to ACLChecklist::checkCallback(),
191  * which will invoke the callback function as requested by the
192  * original caller of aclNBCheck(). This callback function must
193  * *not* delete the list. After the callback function returns,
194  * checkCallback() will delete the list (i.e., self).
195  */
196 ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request, const char *ident):
197  dst_rdns(NULL),
198  request(NULL),
199  reply(NULL),
200 #if USE_AUTH
201  auth_user_request(NULL),
202 #endif
203 #if SQUID_SNMP
204  snmp_community(NULL),
205 #endif
206 #if USE_OPENSSL
207  sslErrors(NULL),
208 #endif
209  requestErrorType(ERR_MAX),
210  conn_(NULL),
211  fd_(-1),
212  destinationDomainChecked_(false),
213  sourceDomainChecked_(false)
214 {
215  my_addr.setEmpty();
216  src_addr.setEmpty();
217  dst_addr.setEmpty();
218  rfc931[0] = '\0';
219 
220  changeAcl(A);
221 
222  if (http_request != NULL) {
223  request = http_request;
225 #if FOLLOW_X_FORWARDED_FOR
228  else
229 #endif /* FOLLOW_X_FORWARDED_FOR */
232 
235  }
236 
237 #if USE_IDENT
238  if (ident)
239  xstrncpy(rfc931, ident, USER_IDENT_SZ);
240 #endif
241 }
242 
bool asyncInProgress() const
async call has been started and has not finished (or failed) yet
Definition: Checklist.h:149
#define assert(EX)
Definition: assert.h:17
Ip::Address my_addr
Definition: HttpRequest.h:143
bool sourceDomainChecked() const
#define cbdataReferenceDone(var)
Definition: cbdata.h:350
Ip::Address dst_addr
Ip::Address src_addr
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
#define xstrdup
#define safe_free(x)
Definition: xalloc.h:73
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:154
bool isEmpty() const
Definition: SBuf.h:422
ConnStateData * conn() const
The client connection manager.
bool destinationDomainChecked() const
CBDATA_CLASS_INIT(ACLFilledChecklist)
HttpRequest * adapted_request
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
#define cbdataReference(var)
Definition: cbdata.h:341
HttpReply * reply
#define DBG_IMPORTANT
Definition: Debug.h:45
#define USER_IDENT_SZ
Definition: defines.h:60
Ip::Address client_addr
Definition: HttpRequest.h:137
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
int fd() const
The client side fd. It uses conn() if available.
char * xstrncpy(char *dst, const char *src, size_t n)
Definition: xstring.cc:37
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:218
HttpRequest * request
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
Definition: Address.cc:177
char rfc931[USER_IDENT_SZ]
URL url
the request URI
Definition: HttpRequest.h:103
static void showDebugWarning(const char *msg)
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:147
class AccessLogEntry::CacheDetails cache
struct SquidConfig::@112 onoff
static uint32 A
Definition: md4.c:43
HttpRequest * request
ConnStateData * conn_
int acl_uses_indirect_client
Definition: SquidConfig.h:326
const Acl::Tree * changeAcl(const Acl::Tree *t)
Definition: Checklist.h:171
AnyP::PortCfgPointer port
const Security::CertErrors * sslErrors
SSL [certificate validation] errors, in undefined order.
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:412
void markDestinationDomainChecked()
#define acl_access
Definition: forward.h:44
SBuf & absolute() const
Definition: url.cc:488
Ip::Address indirect_client_addr
Definition: HttpRequest.h:140
virtual void syncAle() const
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
Definition: CbcPointer.h:162
void HTTPMSGUNLOCK(Http::Message *a)
Definition: Message.h:144
#define false
Definition: GnuRegex.c:233
bool finished() const
whether markFinished() was called
Definition: Checklist.h:147

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors