]> git.ipfire.org Git - thirdparty/squid.git/blame - src/external_acl.cc
Support for --long-acl-options
[thirdparty/squid.git] / src / external_acl.cc
CommitLineData
d9572179 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
d9572179 3 *
bbc27441
AJ
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.
d9572179 7 */
8
bbc27441
AJ
9/* DEBUG: section 82 External ACL */
10
582c2af2 11#include "squid.h"
c0941a6a 12#include "acl/Acl.h"
582c2af2 13#include "acl/FilledChecklist.h"
8a01b99e 14#include "cache_cf.h"
a46d2c0e 15#include "client_side.h"
4e56d7f6 16#include "client_side_request.h"
5c336a3b 17#include "comm/Connection.h"
2eceb328 18#include "ConfigParser.h"
582c2af2 19#include "ExternalACL.h"
f9b6ff6e 20#include "ExternalACLEntry.h"
582c2af2 21#include "fde.h"
4e56d7f6 22#include "format/Token.h"
aa839030 23#include "helper.h"
24438ec5 24#include "helper/Reply.h"
d3dddfb5 25#include "http/Stream.h"
a5bac1d2 26#include "HttpHeaderTools.h"
582c2af2
FC
27#include "HttpReply.h"
28#include "HttpRequest.h"
29#include "ip/tools.h"
0eb49b6d 30#include "MemBuf.h"
582c2af2 31#include "mgr/Registration.h"
1fa9b1a7 32#include "rfc1738.h"
4d5904f7 33#include "SquidConfig.h"
f9b6ff6e 34#include "SquidString.h"
582c2af2
FC
35#include "SquidTime.h"
36#include "Store.h"
4e540555 37#include "tools.h"
b1bd952a 38#include "URL.h"
d295d770 39#include "wordlist.h"
cb4f4424 40#if USE_OPENSSL
cedca6e7 41#include "ssl/ServerBump.h"
4db984be
CT
42#include "ssl/support.h"
43#endif
582c2af2
FC
44#if USE_AUTH
45#include "auth/Acl.h"
46#include "auth/Gadgets.h"
47#include "auth/UserRequest.h"
48#endif
49#if USE_IDENT
50#include "ident/AclIdent.h"
51#endif
d9572179 52
53#ifndef DEFAULT_EXTERNAL_ACL_TTL
54#define DEFAULT_EXTERNAL_ACL_TTL 1 * 60 * 60
55#endif
d4f2f353 56#ifndef DEFAULT_EXTERNAL_ACL_CHILDREN
57#define DEFAULT_EXTERNAL_ACL_CHILDREN 5
d9572179 58#endif
59
c0941a6a 60static char *makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data);
abdd93d0
AJ
61static void external_acl_cache_delete(external_acl * def, const ExternalACLEntryPointer &entry);
62static int external_acl_entry_expired(external_acl * def, const ExternalACLEntryPointer &entry);
63static int external_acl_grace_expired(external_acl * def, const ExternalACLEntryPointer &entry);
64static void external_acl_cache_touch(external_acl * def, const ExternalACLEntryPointer &entry);
65static ExternalACLEntryPointer external_acl_cache_add(external_acl * def, const char *key, ExternalACLEntryData const &data);
d9572179 66
67/******************************************************************
68 * external_acl directive
69 */
62e76326 70
1e5562e3 71class external_acl
62e76326 72{
f205a92e
SM
73 /* FIXME: These are not really cbdata, but it is an easy way
74 * to get them pooled, refcounted, accounted and freed properly...
75 */
f963b531 76 CBDATA_CLASS(external_acl);
1e5562e3 77
78public:
f963b531
AJ
79 external_acl();
80 ~external_acl();
81
d9572179 82 external_acl *next;
1e5562e3 83
abdd93d0 84 void add(const ExternalACLEntryPointer &);
1e5562e3 85
86 void trimCache();
87
194ccc9c
CT
88 bool maybeCacheable(const allow_t &) const;
89
d9572179 90 int ttl;
1e5562e3 91
d9572179 92 int negative_ttl;
1e5562e3 93
47b0c1fa 94 int grace;
95
d9572179 96 char *name;
1e5562e3 97
4e56d7f6 98 Format::Format format;
1e5562e3 99
d9572179 100 wordlist *cmdline;
1e5562e3 101
76d9b994 102 Helper::ChildConfig children;
07eca7e0 103
e6ccf245 104 helper *theHelper;
1e5562e3 105
d9572179 106 hash_table *cache;
1e5562e3 107
d9572179 108 dlink_list lru_list;
1e5562e3 109
d9572179 110 int cache_size;
1e5562e3 111
d9572179 112 int cache_entries;
1e5562e3 113
d9572179 114 dlink_list queue;
1e5562e3 115
2f1431ea 116#if USE_AUTH
3265364b
AJ
117 /**
118 * Configuration flag. May only be altered by the configuration parser.
119 *
120 * Indicates that all uses of this external_acl_type helper require authentication
121 * details to be processed. If none are available its a fail match.
122 */
e870b1f8 123 bool require_auth;
2f1431ea 124#endif
dc1af3cf 125
95d78f10 126 Format::Quoting quote; // default quoting to use, set by protocol= parameter
cc192b50 127
b7ac5457 128 Ip::Address local_addr;
d9572179 129};
130
f963b531
AJ
131CBDATA_CLASS_INIT(external_acl);
132
133external_acl::external_acl() :
cc8c4af2 134 next(NULL),
f963b531
AJ
135 ttl(DEFAULT_EXTERNAL_ACL_TTL),
136 negative_ttl(-1),
137 grace(1),
138 name(NULL),
4e56d7f6 139 format("external_acl_type"),
f963b531
AJ
140 cmdline(NULL),
141 children(DEFAULT_EXTERNAL_ACL_CHILDREN),
142 theHelper(NULL),
143 cache(NULL),
144 cache_size(256*1024),
145 cache_entries(0),
146#if USE_AUTH
147 require_auth(0),
148#endif
95d78f10 149 quote(Format::LOG_QUOTE_URL)
d9572179 150{
f963b531
AJ
151 local_addr.setLocalhost();
152}
62e76326 153
f963b531
AJ
154external_acl::~external_acl()
155{
156 xfree(name);
f963b531
AJ
157 wordlistDestroy(&cmdline);
158
159 if (theHelper) {
160 helperShutdown(theHelper);
161 delete theHelper;
162 theHelper = NULL;
d9572179 163 }
62e76326 164
f963b531
AJ
165 while (lru_list.tail) {
166 ExternalACLEntryPointer e(static_cast<ExternalACLEntry *>(lru_list.tail->data));
167 external_acl_cache_delete(this, e);
168 }
169 if (cache)
170 hashFreeMemory(cache);
171
172 while (next) {
173 external_acl *node = next;
174 next = node->next;
175 node->next = NULL; // prevent recursion
176 delete node;
abdd93d0 177 }
d9572179 178}
179
180void
181parse_externalAclHelper(external_acl ** list)
182{
f963b531 183 char *token = ConfigParser::NextToken();
62e76326 184
7b6ce1c0 185 if (!token) {
62e76326 186 self_destruct();
7b6ce1c0
AJ
187 return;
188 }
62e76326 189
7b6ce1c0 190 external_acl *a = new external_acl;
d9572179 191 a->name = xstrdup(token);
192
2eceb328
CT
193 // Allow supported %macros inside quoted tokens
194 ConfigParser::EnableMacros();
195 token = ConfigParser::NextToken();
62e76326 196
d9572179 197 /* Parse options */
198 while (token) {
62e76326 199 if (strncmp(token, "ttl=", 4) == 0) {
200 a->ttl = atoi(token + 4);
201 } else if (strncmp(token, "negative_ttl=", 13) == 0) {
202 a->negative_ttl = atoi(token + 13);
07eca7e0 203 } else if (strncmp(token, "children=", 9) == 0) {
48d54e4d 204 a->children.n_max = atoi(token + 9);
fa84c01d 205 debugs(0, DBG_CRITICAL, "WARNING: external_acl_type option children=N has been deprecated in favor of children-max=N and children-startup=N");
48d54e4d
AJ
206 } else if (strncmp(token, "children-max=", 13) == 0) {
207 a->children.n_max = atoi(token + 13);
208 } else if (strncmp(token, "children-startup=", 17) == 0) {
209 a->children.n_startup = atoi(token + 17);
210 } else if (strncmp(token, "children-idle=", 14) == 0) {
211 a->children.n_idle = atoi(token + 14);
07eca7e0 212 } else if (strncmp(token, "concurrency=", 12) == 0) {
48d54e4d 213 a->children.concurrency = atoi(token + 12);
6825b101
CT
214 } else if (strncmp(token, "queue-size=", 11) == 0) {
215 a->children.queue_size = atoi(token + 11);
216 a->children.defaultQueueSize = false;
62e76326 217 } else if (strncmp(token, "cache=", 6) == 0) {
218 a->cache_size = atoi(token + 6);
47b0c1fa 219 } else if (strncmp(token, "grace=", 6) == 0) {
220 a->grace = atoi(token + 6);
dc1af3cf 221 } else if (strcmp(token, "protocol=2.5") == 0) {
95d78f10 222 a->quote = Format::LOG_QUOTE_SHELL;
dc1af3cf 223 } else if (strcmp(token, "protocol=3.0") == 0) {
05e52854 224 debugs(3, DBG_PARSE_NOTE(2), "WARNING: external_acl_type option protocol=3.0 is deprecated. Remove this from your config.");
95d78f10 225 a->quote = Format::LOG_QUOTE_URL;
dc1af3cf 226 } else if (strcmp(token, "quote=url") == 0) {
05e52854 227 debugs(3, DBG_PARSE_NOTE(2), "WARNING: external_acl_type option quote=url is deprecated. Remove this from your config.");
95d78f10 228 a->quote = Format::LOG_QUOTE_URL;
dc1af3cf 229 } else if (strcmp(token, "quote=shell") == 0) {
05e52854 230 debugs(3, DBG_PARSE_NOTE(2), "WARNING: external_acl_type option quote=shell is deprecated. Use protocol=2.5 if still needed.");
95d78f10 231 a->quote = Format::LOG_QUOTE_SHELL;
cc192b50 232
26ac0430
AJ
233 /* INET6: allow admin to configure some helpers explicitly to
234 bind to IPv4/v6 localhost port. */
cc192b50 235 } else if (strcmp(token, "ipv4") == 0) {
4dd643d5 236 if ( !a->local_addr.setIPv4() ) {
fa84c01d 237 debugs(3, DBG_CRITICAL, "WARNING: Error converting " << a->local_addr << " to IPv4 in " << a->name );
cc192b50 238 }
239 } else if (strcmp(token, "ipv6") == 0) {
055421ee 240 if (!Ip::EnableIpv6)
fa84c01d 241 debugs(3, DBG_CRITICAL, "WARNING: --enable-ipv6 required for external ACL helpers to use IPv6: " << a->name );
055421ee 242 // else nothing to do.
62e76326 243 } else {
244 break;
245 }
246
2eceb328 247 token = ConfigParser::NextToken();
d9572179 248 }
2eceb328 249 ConfigParser::DisableMacros();
62e76326 250
6f78f0ed 251 /* check that child startup value is sane. */
a3cecd6c
AJ
252 if (a->children.n_startup > a->children.n_max)
253 a->children.n_startup = a->children.n_max;
48d54e4d 254
6f78f0ed 255 /* check that child idle value is sane. */
a3cecd6c
AJ
256 if (a->children.n_idle > a->children.n_max)
257 a->children.n_idle = a->children.n_max;
258 if (a->children.n_idle < 1)
259 a->children.n_idle = 1;
48d54e4d 260
d9572179 261 if (a->negative_ttl == -1)
62e76326 262 a->negative_ttl = a->ttl;
d9572179 263
e44a3ec4 264 if (a->children.defaultQueueSize)
6825b101
CT
265 a->children.queue_size = 2 * a->children.n_max;
266
4e56d7f6
AJ
267 /* Legacy external_acl_type format parser.
268 * Handles a series of %... tokens where any non-% means
269 * the start of another parameter field (ie the path to binary).
270 */
271 enum Format::Quoting quote = Format::LOG_QUOTE_NONE;
272 Format::Token **fmt = &a->format.format;
712fa21e 273 bool data_used = false;
d9572179 274 while (token) {
4e56d7f6 275 /* stop on first non-% token found */
62e76326 276 if (*token != '%')
277 break;
278
4e56d7f6 279 *fmt = new Format::Token;
09e34608
AJ
280 // these tokens are whitespace delimited
281 (*fmt)->space = true;
4e56d7f6 282
3a80bdd7 283 // set the default encoding to match the protocol= config
95d78f10
AJ
284 // this will be overridden by explicit %macro attributes
285 (*fmt)->quote = a->quote;
286
4e56d7f6
AJ
287 // compatibility for old tokens incompatible with Format::Token syntax
288#if USE_OPENSSL // dont bother if we dont have to.
289 if (strncmp(token, "%USER_CERT_", 11) == 0) {
290 (*fmt)->type = Format::LFT_EXT_ACL_USER_CERT;
291 (*fmt)->data.string = xstrdup(token + 11);
292 (*fmt)->data.header.header = (*fmt)->data.string;
f06585e0 293 } else if (strncmp(token, "%USER_CA_CERT_", 14) == 0) {
4e56d7f6
AJ
294 (*fmt)->type = Format::LFT_EXT_ACL_USER_CA_CERT;
295 (*fmt)->data.string = xstrdup(token + 14);
296 (*fmt)->data.header.header = (*fmt)->data.string;
f06585e0 297 } else if (strncmp(token, "%CA_CERT_", 9) == 0) {
3650c90e 298 debugs(82, DBG_PARSE_NOTE(DBG_IMPORTANT), "WARNING: external_acl_type %CA_CERT_* code is obsolete. Use %USER_CA_CERT_* instead");
4e56d7f6
AJ
299 (*fmt)->type = Format::LFT_EXT_ACL_USER_CA_CERT;
300 (*fmt)->data.string = xstrdup(token + 9);
301 (*fmt)->data.header.header = (*fmt)->data.string;
302 } else
a7ad6e4e 303#endif
4e56d7f6
AJ
304 {
305 // we can use the Format::Token::parse() method since it
306 // only pulls off one token. Since we already checked
307 // for '%' prefix above this is guaranteed to be a token.
308 const size_t len = (*fmt)->parse(token, &quote);
309 assert(len == strlen(token));
310 }
311
312 // process special token-specific actions (only if necessary)
2f1431ea 313#if USE_AUTH
4e56d7f6
AJ
314 if ((*fmt)->type == Format::LFT_USER_LOGIN)
315 a->require_auth = true;
2f1431ea 316#endif
62e76326 317
95d78f10
AJ
318 if ((*fmt)->type == Format::LFT_EXT_ACL_DATA)
319 data_used = true;
712fa21e 320
4e56d7f6 321 fmt = &((*fmt)->next);
2eceb328 322 token = ConfigParser::NextToken();
d9572179 323 }
324
325 /* There must be at least one format token */
7b6ce1c0
AJ
326 if (!a->format.format) {
327 delete a;
62e76326 328 self_destruct();
7b6ce1c0
AJ
329 return;
330 }
d9572179 331
712fa21e
AJ
332 // format has implicit %DATA on the end if not used explicitly
333 if (!data_used) {
334 *fmt = new Format::Token;
335 (*fmt)->type = Format::LFT_EXT_ACL_DATA;
262eaf9a 336 (*fmt)->quote = Format::LOG_QUOTE_NONE;
712fa21e
AJ
337 }
338
d9572179 339 /* helper */
7b6ce1c0
AJ
340 if (!token) {
341 delete a;
62e76326 342 self_destruct();
7b6ce1c0
AJ
343 return;
344 }
62e76326 345
d9572179 346 wordlistAdd(&a->cmdline, token);
347
348 /* arguments */
a336d130 349 parse_wordlist(&a->cmdline);
d9572179 350
351 while (*list)
62e76326 352 list = &(*list)->next;
353
d9572179 354 *list = a;
355}
356
357void
358dump_externalAclHelper(StoreEntry * sentry, const char *name, const external_acl * list)
359{
360 const external_acl *node;
d9572179 361 const wordlist *word;
62e76326 362
d9572179 363 for (node = list; node; node = node->next) {
62e76326 364 storeAppendPrintf(sentry, "%s %s", name, node->name);
365
4dd643d5 366 if (!node->local_addr.isIPv6())
cc192b50 367 storeAppendPrintf(sentry, " ipv4");
368 else
369 storeAppendPrintf(sentry, " ipv6");
370
62e76326 371 if (node->ttl != DEFAULT_EXTERNAL_ACL_TTL)
372 storeAppendPrintf(sentry, " ttl=%d", node->ttl);
373
374 if (node->negative_ttl != node->ttl)
375 storeAppendPrintf(sentry, " negative_ttl=%d", node->negative_ttl);
376
47b0c1fa 377 if (node->grace)
378 storeAppendPrintf(sentry, " grace=%d", node->grace);
379
48d54e4d
AJ
380 if (node->children.n_max != DEFAULT_EXTERNAL_ACL_CHILDREN)
381 storeAppendPrintf(sentry, " children-max=%d", node->children.n_max);
62e76326 382
2ccfb9a7 383 if (node->children.n_startup != 0) // sync with helper/ChildConfig.cc default
48d54e4d 384 storeAppendPrintf(sentry, " children-startup=%d", node->children.n_startup);
62e76326 385
2ccfb9a7 386 if (node->children.n_idle != 1) // sync with helper/ChildConfig.cc default
48d54e4d
AJ
387 storeAppendPrintf(sentry, " children-idle=%d", node->children.n_idle);
388
2ccfb9a7 389 if (node->children.concurrency != 0)
48d54e4d 390 storeAppendPrintf(sentry, " concurrency=%d", node->children.concurrency);
07eca7e0 391
47b0c1fa 392 if (node->cache)
393 storeAppendPrintf(sentry, " cache=%d", node->cache_size);
394
95d78f10 395 if (node->quote == Format::LOG_QUOTE_SHELL)
05e52854
AJ
396 storeAppendPrintf(sentry, " protocol=2.5");
397
4e56d7f6 398 node->format.dump(sentry, NULL, false);
62e76326 399
400 for (word = node->cmdline; word; word = word->next)
401 storeAppendPrintf(sentry, " %s", word->key);
402
403 storeAppendPrintf(sentry, "\n");
d9572179 404 }
405}
406
407void
408free_externalAclHelper(external_acl ** list)
409{
f963b531
AJ
410 delete *list;
411 *list = NULL;
d9572179 412}
413
414static external_acl *
415find_externalAclHelper(const char *name)
416{
417 external_acl *node;
418
419 for (node = Config.externalAclHelperList; node; node = node->next) {
62e76326 420 if (strcmp(node->name, name) == 0)
421 return node;
d9572179 422 }
62e76326 423
d9572179 424 return NULL;
425}
426
1e5562e3 427void
abdd93d0 428external_acl::add(const ExternalACLEntryPointer &anEntry)
1e5562e3 429{
430 trimCache();
abdd93d0 431 assert(anEntry != NULL);
1e5562e3 432 assert (anEntry->def == NULL);
433 anEntry->def = this;
abdd93d0
AJ
434 ExternalACLEntry *e = const_cast<ExternalACLEntry *>(anEntry.getRaw()); // XXX: make hash a std::map of Pointer.
435 hash_join(cache, e);
436 dlinkAdd(e, &e->lru, &lru_list);
437 e->lock(); //cbdataReference(e); // lock it on behalf of the hash
95dc7ff4 438 ++cache_entries;
1e5562e3 439}
440
441void
442external_acl::trimCache()
443{
abdd93d0
AJ
444 if (cache_size && cache_entries >= cache_size) {
445 ExternalACLEntryPointer e(static_cast<ExternalACLEntry *>(lru_list.tail->data));
446 external_acl_cache_delete(this, e);
447 }
1e5562e3 448}
449
194ccc9c
CT
450bool
451external_acl::maybeCacheable(const allow_t &result) const
452{
453 if (cache_size <= 0)
454 return false; // cache is disabled
455
456 if (result == ACCESS_DUNNO)
457 return false; // non-cacheable response
458
459 if ((result == ACCESS_ALLOWED ? ttl : negative_ttl) <= 0)
460 return false; // not caching this type of response
461
462 return true;
463}
464
d9572179 465/******************************************************************
466 * external acl type
467 */
468
f963b531
AJ
469class external_acl_data
470{
471 CBDATA_CLASS(external_acl_data);
472
473public:
474 explicit external_acl_data(external_acl *aDef) : def(cbdataReference(aDef)), name(NULL), arguments(NULL) {}
475 ~external_acl_data();
476
d9572179 477 external_acl *def;
ec2d5242 478 const char *name;
d9572179 479 wordlist *arguments;
480};
481
f963b531
AJ
482CBDATA_CLASS_INIT(external_acl_data);
483
484external_acl_data::~external_acl_data()
d9572179 485{
f963b531
AJ
486 xfree(name);
487 wordlistDestroy(&arguments);
488 cbdataReferenceDone(def);
d9572179 489}
490
491void
b0dd28ba 492ACLExternal::parse()
d9572179 493{
7b6ce1c0 494 if (data) {
62e76326 495 self_destruct();
7b6ce1c0
AJ
496 return;
497 }
62e76326 498
16c5ad96 499 char *token = ConfigParser::strtokFile();
62e76326 500
7b6ce1c0 501 if (!token) {
62e76326 502 self_destruct();
7b6ce1c0
AJ
503 return;
504 }
62e76326 505
f963b531 506 data = new external_acl_data(find_externalAclHelper(token));
62e76326 507
7b6ce1c0
AJ
508 if (!data->def) {
509 delete data;
62e76326 510 self_destruct();
7b6ce1c0
AJ
511 return;
512 }
62e76326 513
ec2d5242
HN
514 // def->name is the name of the external_acl_type.
515 // this is the name of the 'acl' directive being tested
516 data->name = xstrdup(AclMatchedName);
517
16c5ad96 518 while ((token = ConfigParser::strtokFile())) {
62e76326 519 wordlistAdd(&data->arguments, token);
d9572179 520 }
d9572179 521}
522
4b0f5de8 523bool
524ACLExternal::valid () const
525{
2f1431ea 526#if USE_AUTH
4b0f5de8 527 if (data->def->require_auth) {
528 if (authenticateSchemeCount() == 0) {
fa84c01d 529 debugs(28, DBG_CRITICAL, "Can't use proxy auth because no authentication schemes were compiled.");
4b0f5de8 530 return false;
531 }
532
533 if (authenticateActiveSchemeCount() == 0) {
fa84c01d 534 debugs(28, DBG_CRITICAL, "Can't use proxy auth because no authentication schemes are fully configured.");
4b0f5de8 535 return false;
536 }
537 }
2f1431ea 538#endif
4b0f5de8 539
540 return true;
541}
542
543bool
544ACLExternal::empty () const
545{
546 return false;
547}
548
b0dd28ba 549ACLExternal::~ACLExternal()
d9572179 550{
f963b531
AJ
551 delete data;
552 xfree(class_);
d9572179 553}
554
1abe0161 555static void
abdd93d0 556copyResultsFromEntry(HttpRequest *req, const ExternalACLEntryPointer &entry)
1abe0161
AJ
557{
558 if (req) {
559#if USE_AUTH
560 if (entry->user.size())
561 req->extacl_user = entry->user;
562
563 if (entry->password.size())
564 req->extacl_passwd = entry->password;
565#endif
566 if (!req->tag.size())
567 req->tag = entry->tag;
568
569 if (entry->log.size())
570 req->extacl_log = entry->log;
571
572 if (entry->message.size())
573 req->extacl_message = entry->message;
a1df1417
NH
574
575 // attach the helper kv-pair to the transaction
576 UpdateRequestNotes(req->clientConnectionManager.get(), *req, entry->notes);
1abe0161
AJ
577 }
578}
579
e5f825ea 580static allow_t
c0941a6a 581aclMatchExternal(external_acl_data *acl, ACLFilledChecklist *ch)
d9572179 582{
c69ce640 583 debugs(82, 9, HERE << "acl=\"" << acl->def->name << "\"");
abdd93d0 584 ExternalACLEntryPointer entry = ch->extacl_entry;
62e76326 585
6f58d7d7
AR
586 external_acl_message = "MISSING REQUIRED INFORMATION";
587
abdd93d0
AJ
588 if (entry != NULL) {
589 if (entry->def == acl->def) {
ad06254e 590 /* Ours, use it.. if the key matches */
6f58d7d7
AR
591 const char *key = makeExternalAclKey(ch, acl);
592 if (!key)
593 return ACCESS_DUNNO; // insufficent data to continue
ad06254e 594 if (strcmp(key, (char*)entry->key) != 0) {
abdd93d0 595 debugs(82, 9, "entry key='" << (char *)entry->key << "', our key='" << key << "' dont match. Discarded.");
ad06254e 596 // too bad. need a new lookup.
abdd93d0 597 entry = ch->extacl_entry = NULL;
ad06254e 598 }
62e76326 599 } else {
abdd93d0
AJ
600 /* Not ours.. get rid of it */
601 debugs(82, 9, "entry " << entry << " not valid or not ours. Discarded.");
602 if (entry != NULL) {
603 debugs(82, 9, "entry def=" << entry->def << ", our def=" << acl->def);
6f58d7d7 604 const char *key = makeExternalAclKey(ch, acl); // may be nil
abdd93d0 605 debugs(82, 9, "entry key='" << (char *)entry->key << "', our key='" << key << "'");
c69ce640 606 }
abdd93d0 607 entry = ch->extacl_entry = NULL;
62e76326 608 }
d9572179 609 }
62e76326 610
d9572179 611 if (!entry) {
c69ce640 612 debugs(82, 9, HERE << "No helper entry available");
2f1431ea 613#if USE_AUTH
62e76326 614 if (acl->def->require_auth) {
62e76326 615 /* Make sure the user is authenticated */
e5f825ea 616 debugs(82, 3, HERE << acl->def->name << " check user authenticated.");
e0f7153c
AR
617 const allow_t ti = AuthenticateAcl(ch);
618 if (ti != ACCESS_ALLOWED) {
e5f825ea 619 debugs(82, 2, HERE << acl->def->name << " user not authenticated (" << ti << ")");
e0f7153c 620 return ti;
62e76326 621 }
e5f825ea 622 debugs(82, 3, HERE << acl->def->name << " user is authenticated.");
62e76326 623 }
2f1431ea 624#endif
6f58d7d7 625 const char *key = makeExternalAclKey(ch, acl);
41218131 626
627 if (!key) {
628 /* Not sufficient data to process */
e5f825ea 629 return ACCESS_DUNNO;
41218131 630 }
631
abdd93d0 632 entry = static_cast<ExternalACLEntry *>(hash_lookup(acl->def->cache, key));
62e76326 633
abdd93d0
AJ
634 const ExternalACLEntryPointer staleEntry = entry;
635 if (entry != NULL && external_acl_entry_expired(acl->def, entry))
e0f7153c
AR
636 entry = NULL;
637
abdd93d0 638 if (entry != NULL && external_acl_grace_expired(acl->def, entry)) {
e0f7153c
AR
639 // refresh in the background
640 ExternalACLLookup::Start(ch, acl, true);
641 debugs(82, 4, HERE << "no need to wait for the refresh of '" <<
642 key << "' in '" << acl->def->name << "' (ch=" << ch << ").");
643 }
644
645 if (!entry) {
e5f825ea 646 debugs(82, 2, HERE << acl->def->name << "(\"" << key << "\") = lookup needed");
95a83c22 647
6082a0e2
EB
648 // TODO: All other helpers allow temporary overload. Should not we?
649 if (!acl->def->theHelper->willOverload()) {
e5f825ea 650 debugs(82, 2, HERE << "\"" << key << "\": queueing a call.");
6f58d7d7
AR
651 if (!ch->goAsync(ExternalACLLookup::Instance()))
652 debugs(82, 2, "\"" << key << "\": no async support!");
e5f825ea 653 debugs(82, 2, HERE << "\"" << key << "\": return -1.");
e0f7153c 654 return ACCESS_DUNNO; // expired cached or simply absent entry
47b0c1fa 655 } else {
e0f7153c 656 if (!staleEntry) {
e5f825ea 657 debugs(82, DBG_IMPORTANT, "WARNING: external ACL '" << acl->def->name <<
6082a0e2 658 "' queue full. Request rejected '" << key << "'.");
4a972fa2 659 external_acl_message = "SYSTEM TOO BUSY, TRY AGAIN LATER";
e5f825ea 660 return ACCESS_DUNNO;
47b0c1fa 661 } else {
e5f825ea 662 debugs(82, DBG_IMPORTANT, "WARNING: external ACL '" << acl->def->name <<
6082a0e2 663 "' queue full. Using stale result. '" << key << "'.");
e0f7153c 664 entry = staleEntry;
47b0c1fa 665 /* Fall thru to processing below */
666 }
667 }
668 }
d9572179 669 }
62e76326 670
e0f7153c
AR
671 debugs(82, 4, HERE << "entry = { date=" <<
672 (long unsigned int) entry->date <<
673 ", result=" << entry->result <<
674 " tag=" << entry->tag <<
675 " log=" << entry->log << " }");
676#if USE_AUTH
677 debugs(82, 4, HERE << "entry user=" << entry->user);
678#endif
679
d9572179 680 external_acl_cache_touch(acl->def, entry);
a7a42b14 681 external_acl_message = entry->message.termedBuf();
4a972fa2 682
e5f825ea 683 debugs(82, 2, HERE << acl->def->name << " = " << entry->result);
1abe0161 684 copyResultsFromEntry(ch->request, entry);
e5f825ea 685 return entry->result;
d9572179 686}
687
b0dd28ba 688int
689ACLExternal::match(ACLChecklist *checklist)
690{
e5f825ea 691 allow_t answer = aclMatchExternal(data, Filled(checklist));
e5f825ea
AJ
692
693 // convert to tri-state ACL match 1,0,-1
9b831d57 694 switch (answer) {
e5f825ea 695 case ACCESS_ALLOWED:
e5f825ea
AJ
696 return 1; // match
697
698 case ACCESS_DENIED:
e5f825ea
AJ
699 return 0; // non-match
700
701 case ACCESS_DUNNO:
702 case ACCESS_AUTH_REQUIRED:
703 default:
e0f7153c 704 // If the answer is not allowed or denied (matches/not matches) and
6f58d7d7
AR
705 // async authentication is not in progress, then we are done.
706 if (checklist->keepMatching())
e0f7153c 707 checklist->markFinished(answer, "aclMatchExternal exception");
e5f825ea
AJ
708 return -1; // other
709 }
b0dd28ba 710}
711
dfad5100 712SBufList
b0dd28ba 713ACLExternal::dump() const
d9572179 714{
b0dd28ba 715 external_acl_data const *acl = data;
dfad5100
FC
716 SBufList rv;
717 rv.push_back(SBuf(acl->def->name));
62e76326 718
dfad5100
FC
719 for (wordlist *arg = acl->arguments; arg; arg = arg->next) {
720 SBuf s;
721 s.Printf(" %s", arg->key);
722 rv.push_back(s);
d9572179 723 }
62e76326 724
dfad5100 725 return rv;
d9572179 726}
727
728/******************************************************************
729 * external_acl cache
730 */
731
d9572179 732static void
abdd93d0 733external_acl_cache_touch(external_acl * def, const ExternalACLEntryPointer &entry)
d9572179 734{
c69ce640 735 // this must not be done when nothing is being cached.
194ccc9c 736 if (!def->maybeCacheable(entry->result))
c69ce640
AJ
737 return;
738
d9572179 739 dlinkDelete(&entry->lru, &def->lru_list);
abdd93d0
AJ
740 ExternalACLEntry *e = const_cast<ExternalACLEntry *>(entry.getRaw()); // XXX: make hash a std::map of Pointer.
741 dlinkAdd(e, &entry->lru, &def->lru_list);
d9572179 742}
743
744static char *
c0941a6a 745makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data)
d9572179 746{
032785bf 747 static MemBuf mb;
09e34608 748 mb.reset();
62e76326 749
4e56d7f6
AJ
750 // check for special case tokens in the format
751 for (Format::Token *t = acl_data->def->format.format; t ; t = t->next) {
62e76326 752
4e56d7f6
AJ
753 if (t->type == Format::LFT_EXT_ACL_NAME) {
754 // setup for %ACL
4ff6370b
AJ
755 safe_free(ch->al->lastAclName);
756 ch->al->lastAclName = xstrdup(acl_data->name);
789dda8d
CT
757 }
758
778647be 759 if (t->type == Format::LFT_EXT_ACL_DATA) {
4e56d7f6
AJ
760 // setup string for %DATA
761 SBuf sb;
4e56d7f6 762 for (auto arg = acl_data->arguments; arg; arg = arg->next) {
778647be 763 if (sb.length())
ec2d5242
HN
764 sb.append(" ", 1);
765
95d78f10 766 if (acl_data->def->quote == Format::LOG_QUOTE_URL) {
ec2d5242
HN
767 const char *quoted = rfc1738_escape(arg->key);
768 sb.append(quoted, strlen(quoted));
769 } else {
770 static MemBuf mb2;
771 mb2.init();
772 strwordquote(&mb2, arg->key);
773 sb.append(mb2.buf, mb2.size);
774 mb2.clean();
775 }
ec2d5242 776 }
778647be 777
b0e14ce2 778 ch->al->lastAclData = sb;
dc1af3cf 779 }
62e76326 780
33c2eb4d 781#if USE_IDENT
4e56d7f6 782 if (t->type == Format::LFT_USER_IDENT) {
a51ed963 783 if (!*ch->rfc931) {
4e56d7f6
AJ
784 // if we fail to go async, we still return NULL and the caller
785 // will detect the failure in ACLExternal::match().
786 (void)ch->goAsync(IdentLookup::Instance());
787 return NULL;
ec2d5242 788 }
ec2d5242 789 }
33c2eb4d 790#endif
d9572179 791 }
62e76326 792
712fa21e 793 // assemble the full helper lookup string
4e56d7f6
AJ
794 acl_data->def->format.assemble(mb, ch->al, 0);
795
d9572179 796 return mb.buf;
d9572179 797}
798
799static int
abdd93d0 800external_acl_entry_expired(external_acl * def, const ExternalACLEntryPointer &entry)
d9572179 801{
194ccc9c 802 if (def->cache_size <= 0 || entry->result == ACCESS_DUNNO)
c69ce640
AJ
803 return 1;
804
194ccc9c 805 if (entry->date + (entry->result == ACCESS_ALLOWED ? def->ttl : def->negative_ttl) < squid_curtime)
62e76326 806 return 1;
d9572179 807 else
62e76326 808 return 0;
d9572179 809}
62e76326 810
47b0c1fa 811static int
abdd93d0 812external_acl_grace_expired(external_acl * def, const ExternalACLEntryPointer &entry)
47b0c1fa 813{
194ccc9c 814 if (def->cache_size <= 0 || entry->result == ACCESS_DUNNO)
c69ce640
AJ
815 return 1;
816
47b0c1fa 817 int ttl;
194ccc9c 818 ttl = entry->result == ACCESS_ALLOWED ? def->ttl : def->negative_ttl;
47b0c1fa 819 ttl = (ttl * (100 - def->grace)) / 100;
820
98b70eff 821 if (entry->date + ttl <= squid_curtime)
47b0c1fa 822 return 1;
823 else
824 return 0;
825}
826
abdd93d0 827static ExternalACLEntryPointer
1e5562e3 828external_acl_cache_add(external_acl * def, const char *key, ExternalACLEntryData const & data)
d9572179 829{
abdd93d0 830 ExternalACLEntryPointer entry;
c69ce640 831
194ccc9c 832 if (!def->maybeCacheable(data.result)) {
c69ce640 833 debugs(82,6, HERE);
194ccc9c
CT
834
835 if (data.result == ACCESS_DUNNO) {
836 if (const ExternalACLEntryPointer oldentry = static_cast<ExternalACLEntry *>(hash_lookup(def->cache, key)))
837 external_acl_cache_delete(def, oldentry);
838 }
c69ce640
AJ
839 entry = new ExternalACLEntry;
840 entry->key = xstrdup(key);
841 entry->update(data);
842 entry->def = def;
843 return entry;
844 }
845
846 entry = static_cast<ExternalACLEntry *>(hash_lookup(def->cache, key));
bf8fe701 847 debugs(82, 2, "external_acl_cache_add: Adding '" << key << "' = " << data.result);
62e76326 848
abdd93d0
AJ
849 if (entry != NULL) {
850 debugs(82, 3, "updating existing entry");
c69ce640 851 entry->update(data);
62e76326 852 external_acl_cache_touch(def, entry);
62e76326 853 return entry;
d9572179 854 }
62e76326 855
1e5562e3 856 entry = new ExternalACLEntry;
4a8b20e8 857 entry->key = xstrdup(key);
c69ce640 858 entry->update(data);
1e5562e3 859
6ca34f6f 860 def->add(entry);
1e5562e3 861
d9572179 862 return entry;
863}
864
865static void
abdd93d0 866external_acl_cache_delete(external_acl * def, const ExternalACLEntryPointer &entry)
d9572179 867{
abdd93d0 868 assert(entry != NULL);
c69ce640 869 assert(def->cache_size > 0 && entry->def == def);
abdd93d0
AJ
870 ExternalACLEntry *e = const_cast<ExternalACLEntry *>(entry.getRaw()); // XXX: make hash a std::map of Pointer.
871 hash_remove_link(def->cache, e);
872 dlinkDelete(&e->lru, &def->lru_list);
873 e->unlock(); // unlock on behalf of the hash
d9572179 874 def->cache_entries -= 1;
d9572179 875}
876
877/******************************************************************
878 * external_acl helpers
879 */
880
f963b531
AJ
881class externalAclState
882{
883 CBDATA_CLASS(externalAclState);
884
885public:
886 externalAclState(external_acl* aDef, const char *aKey) :
887 callback(NULL),
888 callback_data(NULL),
889 key(xstrdup(aKey)),
890 def(cbdataReference(aDef)),
891 queue(NULL)
892 {}
893 ~externalAclState();
62e76326 894
d9572179 895 EAH *callback;
896 void *callback_data;
897 char *key;
898 external_acl *def;
899 dlink_node list;
900 externalAclState *queue;
901};
902
f963b531
AJ
903CBDATA_CLASS_INIT(externalAclState);
904
905externalAclState::~externalAclState()
d9572179 906{
f963b531
AJ
907 xfree(key);
908 cbdataReferenceDone(callback_data);
909 cbdataReferenceDone(def);
d9572179 910}
911
d9572179 912/*
913 * The helper program receives queries on stdin, one
07eca7e0 914 * per line, and must return the result on on stdout
d9572179 915 *
916 * General result syntax:
917 *
918 * OK/ERR keyword=value ...
919 *
920 * Keywords:
921 *
4a972fa2 922 * user= The users name (login)
923 * message= Message describing the reason
f53969cc
SM
924 * tag= A string tag to be applied to the request that triggered the acl match.
925 * applies to both OK and ERR responses.
926 * Won't override existing request tags.
927 * log= A string to be used in access logging
d9572179 928 *
929 * Other keywords may be added to the protocol later
930 *
05e52854
AJ
931 * value needs to be URL-encoded or enclosed in double quotes (")
932 * with \-escaping on any whitespace, quotes, or slashes (\).
d9572179 933 */
d9572179 934static void
24438ec5 935externalAclHandleReply(void *data, const Helper::Reply &reply)
d9572179 936{
e6ccf245 937 externalAclState *state = static_cast<externalAclState *>(data);
d9572179 938 externalAclState *next;
1e5562e3 939 ExternalACLEntryData entryData;
d9572179 940
0272dd08 941 debugs(82, 2, HERE << "reply=" << reply);
d9572179 942
2428ce02 943 if (reply.result == Helper::Okay)
0272dd08 944 entryData.result = ACCESS_ALLOWED;
194ccc9c
CT
945 else if (reply.result == Helper::Error)
946 entryData.result = ACCESS_DENIED;
947 else //BrokenHelper,TimedOut or Unknown. Should not cached.
948 entryData.result = ACCESS_DUNNO;
62e76326 949
24438ec5 950 // XXX: make entryData store a proper Helper::Reply object instead of copying.
ab332e27 951
a0592634
AJ
952 entryData.notes.append(&reply.notes);
953
cf9f0261
CT
954 const char *label = reply.notes.findFirst("tag");
955 if (label != NULL && *label != '\0')
956 entryData.tag = label;
62e76326 957
cf9f0261
CT
958 label = reply.notes.findFirst("message");
959 if (label != NULL && *label != '\0')
960 entryData.message = label;
62e76326 961
cf9f0261
CT
962 label = reply.notes.findFirst("log");
963 if (label != NULL && *label != '\0')
964 entryData.log = label;
62e76326 965
2f1431ea 966#if USE_AUTH
cf9f0261
CT
967 label = reply.notes.findFirst("user");
968 if (label != NULL && *label != '\0')
969 entryData.user = label;
7bbefa01 970
cf9f0261
CT
971 label = reply.notes.findFirst("password");
972 if (label != NULL && *label != '\0')
973 entryData.password = label;
2f1431ea 974#endif
62e76326 975
d9572179 976 dlinkDelete(&state->list, &state->def->queue);
62e76326 977
abdd93d0 978 ExternalACLEntryPointer entry;
194ccc9c
CT
979 if (cbdataReferenceValid(state->def))
980 entry = external_acl_cache_add(state->def, state->key, entryData);
d9572179 981
982 do {
62e76326 983 void *cbdata;
47b0c1fa 984 if (state->callback && cbdataReferenceValidDone(state->callback_data, &cbdata))
62e76326 985 state->callback(cbdata, entry);
986
987 next = state->queue;
f963b531 988 state->queue = NULL;
d9572179 989
f963b531 990 delete state;
d9572179 991
62e76326 992 state = next;
d9572179 993 } while (state);
994}
995
996void
e0f7153c 997ACLExternal::ExternalAclLookup(ACLChecklist *checklist, ACLExternal * me)
d9572179 998{
e0f7153c
AR
999 ExternalACLLookup::Start(checklist, me->data, false);
1000}
c8e7608c 1001
e0f7153c
AR
1002void
1003ExternalACLLookup::Start(ACLChecklist *checklist, external_acl_data *acl, bool inBackground)
1004{
1005 external_acl *def = acl->def;
c0f81932 1006
c0941a6a 1007 ACLFilledChecklist *ch = Filled(checklist);
c8e7608c 1008 const char *key = makeExternalAclKey(ch, acl);
6f58d7d7 1009 assert(key); // XXX: will fail if EXT_ACL_IDENT case needs an async lookup
62e76326 1010
e0f7153c
AR
1011 debugs(82, 2, HERE << (inBackground ? "bg" : "fg") << " lookup in '" <<
1012 def->name << "' for '" << key << "'");
62e76326 1013
47b0c1fa 1014 /* Check for a pending lookup to hook into */
c69ce640 1015 // only possible if we are caching results.
e0f7153c 1016 externalAclState *oldstate = NULL;
c69ce640 1017 if (def->cache_size > 0) {
e0f7153c 1018 for (dlink_node *node = def->queue.head; node; node = node->next) {
c69ce640 1019 externalAclState *oldstatetmp = static_cast<externalAclState *>(node->data);
62e76326 1020
c69ce640
AJ
1021 if (strcmp(key, oldstatetmp->key) == 0) {
1022 oldstate = oldstatetmp;
1023 break;
1024 }
47b0c1fa 1025 }
1026 }
62e76326 1027
e0f7153c
AR
1028 // A background refresh has no need to piggiback on a pending request:
1029 // When the pending request completes, the cache will be refreshed anyway.
1030 if (oldstate && inBackground) {
1031 debugs(82, 7, HERE << "'" << def->name << "' queue is already being refreshed (ch=" << ch << ")");
47b0c1fa 1032 return;
1033 }
62e76326 1034
f963b531 1035 externalAclState *state = new externalAclState(def, key);
62e76326 1036
e0f7153c
AR
1037 if (!inBackground) {
1038 state->callback = &ExternalACLLookup::LookupDone;
1039 state->callback_data = cbdataReference(checklist);
d9572179 1040 }
62e76326 1041
47b0c1fa 1042 if (oldstate) {
1043 /* Hook into pending lookup */
1044 state->queue = oldstate->queue;
1045 oldstate->queue = state;
1046 } else {
e0f7153c
AR
1047 /* No pending lookup found. Sumbit to helper */
1048
e0f7153c 1049 MemBuf buf;
2fe7eff9 1050 buf.init();
4391cd15 1051 buf.appendf("%s\n", key);
bf8fe701 1052 debugs(82, 4, "externalAclLookup: looking up for '" << key << "' in '" << def->name << "'.");
ab321f4b 1053
6825b101
CT
1054 if (!def->theHelper->trySubmit(buf.buf, externalAclHandleReply, state)) {
1055 debugs(82, 7, HERE << "'" << def->name << "' submit to helper failed");
1056 assert(inBackground); // or the caller should have checked
f963b531 1057 delete state;
6825b101
CT
1058 return;
1059 }
62e76326 1060
47b0c1fa 1061 dlinkAdd(state, &state->list, &def->queue);
62e76326 1062
2fe7eff9 1063 buf.clean();
47b0c1fa 1064 }
62e76326 1065
bf8fe701 1066 debugs(82, 4, "externalAclLookup: will wait for the result of '" << key <<
1067 "' in '" << def->name << "' (ch=" << ch << ").");
d9572179 1068}
1069
1070static void
1071externalAclStats(StoreEntry * sentry)
1072{
f963b531 1073 for (external_acl *p = Config.externalAclHelperList; p; p = p->next) {
62e76326 1074 storeAppendPrintf(sentry, "External ACL Statistics: %s\n", p->name);
1075 storeAppendPrintf(sentry, "Cache size: %d\n", p->cache->count);
bf3e8d5a
AJ
1076 assert(p->theHelper);
1077 p->theHelper->packStatsInto(sentry);
62e76326 1078 storeAppendPrintf(sentry, "\n");
d9572179 1079 }
1080}
1081
6b7d87bb
FC
1082static void
1083externalAclRegisterWithCacheManager(void)
1084{
8822ebee 1085 Mgr::RegisterAction("external_acl",
d9fc6862
A
1086 "External ACL stats",
1087 externalAclStats, 0, 1);
6b7d87bb
FC
1088}
1089
d9572179 1090void
1091externalAclInit(void)
1092{
f963b531 1093 for (external_acl *p = Config.externalAclHelperList; p; p = p->next) {
62e76326 1094 if (!p->cache)
30abd221 1095 p->cache = hash_create((HASHCMP *) strcmp, hashPrime(1024), hash4);
62e76326 1096
1097 if (!p->theHelper)
48d54e4d 1098 p->theHelper = new helper(p->name);
62e76326 1099
1100 p->theHelper->cmdline = p->cmdline;
1101
1af735c7 1102 p->theHelper->childs.updateLimits(p->children);
07eca7e0 1103
62e76326 1104 p->theHelper->ipc_type = IPC_TCP_SOCKET;
1105
cc192b50 1106 p->theHelper->addr = p->local_addr;
1107
62e76326 1108 helperOpenServers(p->theHelper);
d9572179 1109 }
62e76326 1110
ea391f18 1111 externalAclRegisterWithCacheManager();
d9572179 1112}
1113
1114void
1115externalAclShutdown(void)
1116{
1117 external_acl *p;
62e76326 1118
d9572179 1119 for (p = Config.externalAclHelperList; p; p = p->next) {
62e76326 1120 helperShutdown(p->theHelper);
d9572179 1121 }
1122}
225b7b10 1123
1124ExternalACLLookup ExternalACLLookup::instance_;
1125ExternalACLLookup *
1126ExternalACLLookup::Instance()
1127{
1128 return &instance_;
1129}
1130
1131void
1132ExternalACLLookup::checkForAsync(ACLChecklist *checklist)const
1133{
b0dd28ba 1134 /* TODO: optimise this - we probably have a pointer to this
1135 * around somewhere */
97427e90 1136 ACL *acl = ACL::FindByName(AclMatchedName);
ab321f4b 1137 assert(acl);
b0dd28ba 1138 ACLExternal *me = dynamic_cast<ACLExternal *> (acl);
1139 assert (me);
e0f7153c 1140 ACLExternal::ExternalAclLookup(checklist, me);
225b7b10 1141}
1142
e0f7153c 1143/// Called when an async lookup returns
225b7b10 1144void
abdd93d0 1145ExternalACLLookup::LookupDone(void *data, const ExternalACLEntryPointer &result)
225b7b10 1146{
c0941a6a 1147 ACLFilledChecklist *checklist = Filled(static_cast<ACLChecklist*>(data));
abdd93d0 1148 checklist->extacl_entry = result;
6f58d7d7 1149 checklist->resumeNonBlockingCheck(ExternalACLLookup::Instance());
225b7b10 1150}
b0dd28ba 1151
b0dd28ba 1152ACL *
1153ACLExternal::clone() const
1154{
1155 return new ACLExternal(*this);
1156}
1157
86c63190 1158ACLExternal::ACLExternal(char const *theClass) : data(NULL), class_(xstrdup(theClass))
b0dd28ba 1159{}
1160
86c63190 1161ACLExternal::ACLExternal(ACLExternal const & old) : data(NULL), class_(old.class_ ? xstrdup(old.class_) : NULL)
b0dd28ba 1162{
1163 /* we don't have copy constructors for the data yet */
86c63190 1164 assert(!old.data);
b0dd28ba 1165}
1166
b0dd28ba 1167char const *
1168ACLExternal::typeString() const
1169{
1170 return class_;
1171}
1172
e870b1f8 1173bool
1174ACLExternal::isProxyAuth() const
1175{
2f1431ea 1176#if USE_AUTH
e870b1f8 1177 return data->def->require_auth;
2f1431ea
AJ
1178#else
1179 return false;
1180#endif
e870b1f8 1181}
f53969cc 1182