/*
- * $Id: ACL.h,v 1.12 2004/08/30 05:12:30 robertc Exp $
+ * $Id: ACL.h,v 1.13 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual int match(ACLChecklist * checklist) = 0;
virtual wordlist *dumpGeneric() const;
virtual wordlist *dump() const = 0;
- virtual bool valid () const =0;
+ virtual bool empty () const = 0;
+ virtual bool valid () const;
int checklistMatches(ACLChecklist *);
int cacheMatchAcl(dlink_list * cache, ACLChecklist *);
/*
- * $Id: ACLARP.cc,v 1.12 2005/04/18 21:52:41 hno Exp $
+ * $Id: ACLARP.cc,v 1.13 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
}
bool
-ACLARP::valid () const
+ACLARP::empty () const
{
return data != NULL;
}
/*
- * $Id: ACLARP.h,v 1.3 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLARP.h,v 1.4 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual void parse();
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
protected:
static Prototype RegistryProtoype;
/*
- * $Id: ACLDestinationDomain.cc,v 1.7 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLDestinationDomain.cc,v 1.8 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
}
bool
-ACLDestinationDomain::valid () const
+ACLDestinationDomain::empty () const
{
return data != NULL;
}
/*
- * $Id: ACLDestinationDomain.h,v 1.6 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLDestinationDomain.h,v 1.7 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual void parse();
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
virtual bool requiresRequest() const {return true;}
virtual ACL *clone()const;
/*
- * $Id: ACLExtUser.cc,v 1.5 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLExtUser.cc,v 1.6 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
}
bool
-ACLExtUser::valid () const
+ACLExtUser::empty () const
{
return data != NULL;
}
/*
- * $Id: ACLExtUser.h,v 1.4 2005/03/30 23:04:09 hno Exp $
+ * $Id: ACLExtUser.h,v 1.5 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
virtual ACL *clone()const;
private:
if (safe_inet_addr(asc, mask))
return 1;
- debug(28, 0) ("DecodeAddress: Invalid IP address: '%s'\n", asc);
-
return 0;
}
if ((hp = gethostbyname(addr1)) == NULL) {
debug(28, 0) ("aclParseIpData: Bad host/IP: '%s'\n", t);
- delete q;
- return NULL;
+ self_destruct();
}
Q = &q;
r->addr2.s_addr = 0;
- DecodeMask(mask, &r->mask);
+ if (!DecodeMask(mask, &r->mask)) {
+ debug(28, 0) ("aclParseIpData: unknown netmask '%s' in '%s'\n", mask, t);
+ delete r;
+ *Q = NULL;
+ self_destruct();
+ continue;
+ }
+
Q = &r->next;
if (*Q != NULL) {
debug(28, 0) ("aclParseIpData: Bad host/IP: '%s'\n", t);
- delete q;
- return NULL;
+ self_destruct();
}
return q;
/* Decode addr1 */
if (!safe_inet_addr(addr1, &q->addr1)) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
- debug(28, 0) ("aclParseIpData: Ignoring invalid IP acl entry: unknown first address '%s'\n", addr1);
+ debug(28, 0) ("aclParseIpData: unknown first address in '%s'\n", t);
delete q;
+ self_destruct();
return NULL;
}
/* Decode addr2 */
if (!safe_inet_addr(addr2, &q->addr2)) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
- debug(28, 0) ("aclParseIpData: Ignoring invalid IP acl entry: unknown second address '%s'\n", addr2);
+ debug(28, 0) ("aclParseIpData: unknown second address in '%s'\n", t);
delete q;
+ self_desctruct();
return NULL;
}
/* Decode mask */
if (!DecodeMask(mask, &q->mask)) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
- debug(28, 0) ("aclParseIpData: Ignoring invalid IP acl entry: unknown netmask '%s'\n", mask);
+ debug(28, 0) ("aclParseIpData: unknown netmask '%s' in '%s'\n", mask, t);
delete q;
+ self_destruct();
return NULL;
}
}
bool
-ACLIP::valid () const
+ACLIP::empty () const
{
return data != NULL;
}
// virtual bool isProxyAuth() const {return true;}
virtual int match(ACLChecklist *checklist) = 0;
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
protected:
}
bool
-ACLIdent::valid () const
+ACLIdent::empty () const
{
return data != NULL;
}
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
virtual ACL *clone()const;
private:
/*
- * $Id: ACLMaxConnection.cc,v 1.4 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLMaxConnection.cc,v 1.5 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
return new ACLMaxConnection(*this);
}
-ACLMaxConnection::ACLMaxConnection (char const *theClass) : class_ (theClass), limit(0)
+ACLMaxConnection::ACLMaxConnection (char const *theClass) : class_ (theClass), limit(-1)
{}
ACLMaxConnection::ACLMaxConnection (ACLMaxConnection const & old) :class_ (old.class_), limit (old.limit)
return class_;
}
+bool
+ACLMaxConnection::empty () const
+{
+ return false;
+}
+
bool
ACLMaxConnection::valid () const
{
- return limit != 0;
+ return limit > 0;
}
void
ACLMaxConnection::parse()
{
char *t = strtokFile();
+
+ if (!t)
+ return;
+
limit = (atoi (t));
- /* suck out file contents */
- while ((t = strtokFile()))
+ /* suck out file contents */
- ;
+ while ((t = strtokFile())) {
+ limit = 0;
+ }
}
int
/*
- * $Id: ACLMaxConnection.h,v 1.3 2004/08/30 05:12:31 robertc Exp $
+ * $Id: ACLMaxConnection.h,v 1.4 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual void parse();
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
+ virtual bool empty () const;
virtual bool valid () const;
virtual void prepareForUse();
/*
- * $Id: ACLMaxUserIP.cc,v 1.7 2005/04/18 21:52:41 hno Exp $
+ * $Id: ACLMaxUserIP.cc,v 1.8 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
return new ACLMaxUserIP(*this);
}
-ACLMaxUserIP::ACLMaxUserIP (char const *theClass) : class_ (theClass), maximum(0)
+ACLMaxUserIP::ACLMaxUserIP (char const *theClass) : class_ (theClass), maximum(-1)
{}
ACLMaxUserIP::ACLMaxUserIP (ACLMaxUserIP const & old) :class_ (old.class_), maximum (old.maximum), flags (old.flags)
return class_;
}
+bool
+ACLMaxUserIP::empty () const
+{
+ return false;
+}
+
bool
ACLMaxUserIP::valid () const
{
- return maximum != 0;
+ return maximum > 0;
}
void
char *t = strtokFile();
if (!t)
- fatal("aclParseUserMaxIP: Malformed ACL\n");
+ return;
debug(28, 5) ("aclParseUserMaxIP: First token is %s\n", t);
}
if (!t)
- fatal("aclParseUserMaxIP: Malformed ACL\n");
+ return;
maximum = atoi(t);
/*
- * $Id: ACLMaxUserIP.h,v 1.5 2005/04/18 21:52:41 hno Exp $
+ * $Id: ACLMaxUserIP.h,v 1.6 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
int match(auth_user_request_t *, struct IN_ADDR const &);
char const *class_;
- size_t maximum;
+ int maximum;
struct Flags
{
void
ACLProxyAuth::parse()
{
- if (authenticateSchemeCount() == 0) {
- debug(28, 0) ("aclProxyAuth::parse: IGNORING: Proxy Auth ACL '%s' "
- "because no authentication schemes were compiled.\n", cfgline);
- return;
- }
-
- if (authenticateActiveSchemeCount() == 0) {
- debug(28, 0) ("aclProxyAuth::parse: IGNORING: Proxy Auth ACL '%s' "
- "because no authentication schemes are fully configured.\n", cfgline);
- return;
- }
-
data->parse();
}
}
bool
-ACLProxyAuth::valid () const
+ACLProxyAuth::empty () const
{
return data != NULL;
}
+bool
+ACLProxyAuth::valid () const
+{
+ if (authenticateSchemeCount() == 0) {
+ debug(28, 0) ("Can't use proxy auth because no authentication schemes were compiled.\n");
+ return false;
+ }
+
+ if (authenticateActiveSchemeCount() == 0) {
+ debug(28, 0) ("Can't use proxy auth because no authentication schemes are fully configured.\n");
+ return false;
+ }
+
+ return true;
+}
+
ProxyAuthNeeded ProxyAuthNeeded::instance_;
ProxyAuthNeeded *
virtual int match(ACLChecklist *checklist);
virtual wordlist *dump() const;
virtual bool valid () const;
+ virtual bool empty () const;
virtual bool requiresRequest() const {return true;}
virtual ACL *clone()const;
/*
- * $Id: ACLStrategised.h,v 1.8 2004/12/24 08:57:59 robertc Exp $
+ * $Id: ACLStrategised.h,v 1.9 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual int match(ACLChecklist *checklist);
virtual int match (M const &);
virtual wordlist *dump() const;
- virtual bool valid () const;
+ virtual bool empty () const;
virtual ACL *clone()const;
private:
template <class MatchType>
bool
-ACLStrategised<MatchType>::valid () const
+ACLStrategised<MatchType>::empty () const
{
- return data != NULL;
+ return data == NULL;
}
template <class MatchType>
/*
- * $Id: ACLTimeData.cc,v 1.8 2004/12/20 16:30:32 robertc Exp $
+ * $Id: ACLTimeData.cc,v 1.9 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
/* assume its time-of-day spec */
if (sscanf(t, "%d:%d-%d:%d", &h1, &m1, &h2, &m2) < 4) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
- debug(28, 0) ("aclParseTimeSpec: IGNORING Bad time range\n");
+ debug(28, 0) ("aclParseTimeSpec: Bad time range '%s'\n", t);
+ self_destruct();
if (q != this)
delete q;
weekbits = 0;
if (q->start > q->stop) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
- debug(28, 0) ("aclParseTimeSpec: IGNORING Reversed time range\n");
+ debug(28, 0) ("aclParseTimeSpec: Reversed time range\n");
+ self_destruct();
if (q != this)
delete q;
/*
- * $Id: AuthUserRequest.cc,v 1.3 2005/04/18 21:52:41 hno Exp $
+ * $Id: AuthUserRequest.cc,v 1.4 2005/05/06 01:57:55 hno Exp $
*
* DO NOT MODIFY NEXT 2 LINES:
* arch-tag: 6803fde1-d5a2-4c29-9034-1c0c9f650eb4
auth_user_request->user()->clearIp();
}
-size_t
+int
authenticateAuthUserRequestIPCount(auth_user_request_t * auth_user_request)
{
assert(auth_user_request);
/*
- * $Id: AuthUserRequest.h,v 1.2 2005/04/18 21:52:41 hno Exp $
+ * $Id: AuthUserRequest.h,v 1.3 2005/05/06 01:57:55 hno Exp $
*
* DO NOT MODIFY NEXT 2 LINES:
* arch-tag: 674533af-8b21-4641-b71a-74c4639072a0
extern void authenticateAuthUserRequestRemoveIp(auth_user_request_t *, struct IN_ADDR);
extern void authenticateAuthUserRequestClearIp(auth_user_request_t *);
-extern size_t authenticateAuthUserRequestIPCount(auth_user_request_t *);
+extern int authenticateAuthUserRequestIPCount(auth_user_request_t *);
extern int authenticateDirection(auth_user_request_t *);
extern int authenticateUserAuthenticated(auth_user_request_t *);
/*
- * $Id: ExternalACL.h,v 1.7 2005/03/30 23:08:19 hno Exp $
+ * $Id: ExternalACL.h,v 1.8 2005/05/06 01:57:55 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
virtual bool isProxyAuth() const;
virtual wordlist *dump() const;
virtual bool valid () const;
+ virtual bool empty () const;
protected:
static Prototype RegistryProtoype;
/*
- * $Id: acl.cc,v 1.314 2004/08/30 05:12:31 robertc Exp $
+ * $Id: acl.cc,v 1.315 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
ACL::ACL () {}
+bool ACL::valid () const
+{
+ return true;
+}
+
void
ACL::ParseAclLine(ACL ** head)
{
/* snarf the ACL name */
if ((t = strtok(NULL, w_space)) == NULL) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
debug(28, 0) ("aclParseAclLine: missing ACL name.\n");
+ self_destruct();
return;
}
char *theType;
if ((theType = strtok(NULL, w_space)) == NULL) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
debug(28, 0) ("aclParseAclLine: missing ACL type.\n");
+ self_destruct();
return;
}
if (!Prototype::Registered (theType)) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
debug(28, 0) ("aclParseAclLine: Invalid ACL type '%s'\n", theType);
+ self_destruct();
return;
}
new_acl = 1;
} else {
if (strcmp (A->typeString(),theType) ) {
- debug(28, 0) ("aclParseAclLine: ACL '%s' already exists with different type, skipping.\n", A->name);
+ debug(28, 0) ("aclParseAclLine: ACL '%s' already exists with different type.\n", A->name);
+ self_destruct();
return;
}
if (!new_acl)
return;
- if (!A->valid()) {
- debug(28, 0) ("aclParseAclLine: IGNORING invalid ACL: %s\n",
+ if (A->empty()) {
+ debug(28, 0) ("Warning: empty ACL: %s\n",
A->cfgline);
- delete A;
- /* Do we need this? */
- A = NULL;
- return;
+ }
+
+ if (!A->valid()) {
+ fatalf("ERROR: Invalid ACL: %s\n",
+ A->cfgline);
}
/* append */
a = ACL::FindByName(t);
if (a == NULL) {
- debug(28, 0) ("%s line %d: %s\n",
- cfg_filename, config_lineno, config_input_line);
debug(28, 0) ("aclParseAccessLine: ACL name '%s' not found.\n", t);
delete L;
+ self_destruct();
continue;
}
/*
- * $Id: cache_cf.cc,v 1.472 2005/05/01 08:11:47 serassio Exp $
+ * $Id: cache_cf.cc,v 1.473 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
void
self_destruct(void)
{
+ shutting_down = 1;
fatalf("Bungled %s line %d: %s",
cfg_filename, config_lineno, config_input_line);
}
/*
- * $Id: external_acl.cc,v 1.62 2005/03/30 23:08:19 hno Exp $
+ * $Id: external_acl.cc,v 1.63 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 82 External ACL
* AUTHOR: Henrik Nordstrom, MARA Systems AB
#endif
#include "client_side.h"
#include "HttpRequest.h"
+#include "authenticate.h"
#ifndef DEFAULT_EXTERNAL_ACL_TTL
#define DEFAULT_EXTERNAL_ACL_TTL 1 * 60 * 60
}
}
+bool
+ACLExternal::valid () const
+{
+ if (data->def->require_auth) {
+ if (authenticateSchemeCount() == 0) {
+ debug(28, 0) ("Can't use proxy auth because no authentication schemes were compiled.\n");
+ return false;
+ }
+
+ if (authenticateActiveSchemeCount() == 0) {
+ debug(28, 0) ("Can't use proxy auth because no authentication schemes are fully configured.\n");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool
+ACLExternal::empty () const
+{
+ return false;
+}
+
ACLExternal::~ACLExternal()
{
cbdataFree(data);
return class_;
}
-bool
-ACLExternal::valid () const
-{
- return data != NULL;
-}
-
bool
ACLExternal::isProxyAuth() const
{
/*
- * $Id: tools.cc,v 1.255 2005/04/25 18:43:00 serassio Exp $
+ * $Id: tools.cc,v 1.256 2005/05/06 01:57:55 hno Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
storeDirWriteCleanLogs(0);
- PrintRusage();
+ if (!shutting_down) {
+ PrintRusage();
- dumpMallocStats();
+ dumpMallocStats();
+ }
if (squid_curtime - SQUID_RELEASE_TIME < 864000) {
/* skip if more than 10 days old */
fatal_common(message);
if (shutting_down)
- exit(0);
+ exit(1);
else
abort();
}