--------------------- PatchSet 1799 Date: 2001/03/31 11:07:22 Author: rbcollins Branch: generic_modules Tag: (none) Log: Overdue fix for acl finding code Members: src/acl.c:1.21.4.3->1.21.4.4 src/cache_cf.c:1.18.4.20->1.18.4.21 src/protos.h:1.18.4.17->1.18.4.18 src/structs.h:1.24.4.15->1.24.4.16 src/typedefs.h:1.15.4.13->1.15.4.14 src/auth/ntlm/auth_ntlm.c:1.7.6.6->1.7.6.7 Index: squid/src/acl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/acl.c,v retrieving revision 1.21.4.3 retrieving revision 1.21.4.4 diff -u -r1.21.4.3 -r1.21.4.4 --- squid/src/acl.c 31 Mar 2001 09:52:18 -0000 1.21.4.3 +++ squid/src/acl.c 31 Mar 2001 11:07:22 -0000 1.21.4.4 @@ -1,6 +1,6 @@ /* - * $Id: acl.c,v 1.21.4.3 2001/03/31 09:52:18 rbcollins Exp $ + * $Id: acl.c,v 1.21.4.4 2001/03/31 11:07:22 rbcollins Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -36,6 +36,9 @@ #include "squid.h" #include "splay.h" +/* this is the parent instance_name that acls live under */ +static void * aclinstances = NULL; + static int aclFromFile = 0; static FILE *aclFile; @@ -296,10 +299,17 @@ static acl * aclFindByName(const char *name) { + instance_node *acl_instance; +#if NEVER acl *a; for (a = Config.aclList; a; a = a->next) if (!strcasecmp(a->name, name)) return a; +#endif + acl_instance=InstanceByNameStr(aclinstances,name); + if (acl_instance) + return acl_instance->data; + return NULL; } @@ -722,6 +732,7 @@ squid_acl acltype; int new_acl = 0; + #if NEVER /* snarf the ACL name */ if ((t = strtok(NULL, w_space)) == NULL) { @@ -774,7 +785,10 @@ * Here we set AclMatchedName in case we need to use it in a * warning message in aclDomainCompare(). */ -// AclMatchedName = aclname; /* ugly */ +/* AclMatchedName = aclname; */ /* ugly */ +/* FIXME: the sub type should be registered via a one off instance - no new registrations + * Allowed. Ideally this is declaritive (list the allowed types, sepcificy one type per + * child */ switch (A->type) { case ACL_SRC_IP: case ACL_DST_IP: @@ -3018,3 +3032,14 @@ // parserRegisterName("acl",parserTypeByName("instance_node"),&Config.aclList2,default_if_none_acl,name_document_acl, NULL); // parserRegisterInstanceType(" } + + +void +aclParserRegister(void) +{ + if (aclinstances) + debug(3,0)("bwahhahhahaha\n\n"); + aclinstances = parserRegisterInstanceName("acl", parserTypeByName("acl"), NULL, NULL); + + parserRegisterName(NULL, "acl", parserTypeByName("instance_node"), aclinstances, default_if_none_acl, name_document_acl, NULL); +} Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18.4.20 retrieving revision 1.18.4.21 diff -u -r1.18.4.20 -r1.18.4.21 --- squid/src/cache_cf.c 31 Mar 2001 09:52:19 -0000 1.18.4.20 +++ squid/src/cache_cf.c 31 Mar 2001 11:07:22 -0000 1.18.4.21 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18.4.20 2001/03/31 09:52:19 rbcollins Exp $ + * $Id: cache_cf.c,v 1.18.4.21 2001/03/31 11:07:22 rbcollins Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -1177,7 +1177,7 @@ if (type == MOD_NONE) self_destruct(); - node = CBDATA_ALLOC(modNode, NULL); + node = cbdataAlloc(modNode); assert(node); node->type = type; node->namestr = xstrdup(name_str); @@ -2341,7 +2341,7 @@ while (link && link->next) link=link->next; - tmp_link=CBDATA_ALLOC(includefile_t,NULL); + tmp_link=cbdataAlloc(includefile_t); tmp_link->next=NULL; tmp_link->filename=tempstr; @@ -2393,10 +2393,12 @@ void *parserRegisterInstanceName(const char *, parserTypeNode *, PARSER_DEFAULT_NONE *, PARSER_POST_PARSE *); +#if 0 static void * aclinstances = NULL; #define default_if_none_acl NULL #define name_document_acl NULL +#endif PARSER_DEFAULT_NONE default_if_no_instances; @@ -2409,14 +2411,19 @@ /* ACL.C routines: should be in acl.c */ + aclParserRegister(); + // parserRegisterName("acl",parserTypeByName("instance_node"),&Config.aclList2,default_if_none_acl,name_document_acl, NULL); +#if 0 if (aclinstances) debug(3,0)("bwahhahhahaha\n\n"); aclinstances = parserRegisterInstanceName("acl", parserTypeByName("acl"), name_document_acl, NULL); parserRegisterName(NULL, "acl", parserTypeByName("instance_node"), aclinstances, default_if_none_acl, name_document_acl, NULL); +#endif + /* instance called acl to parse use type foo */ @@ -2534,32 +2541,13 @@ parserNameNode *parserNameByNodeName(dlink_list *, const char *); - -typedef struct _instance_name instance_name; -typedef struct _instance_node instance_node; - CBDATA_TYPE(instance_name); CBDATA_TYPE(instance_node); -struct _instance_name { - dlink_node node; - dlink_list instances; - char *namestr; - parserTypeNode *type; - PARSER_DEFAULT_NONE *default_none; - PARSER_NAME_DOCUMENT *documentfunc; - PARSER_POST_PARSE *post_parse_func; -}; - -struct _instance_node { - dlink_node node; - dlink_list *head; - char *namestr; - void *data; - parserNameNode *parserName; - instance_name *name; -}; - +/* this code is broken. The fault is that not all instances will start at root. + * the solution is to store the instance list as the config data for the parent nore + * of the instance + */ static dlink_list instance_names = {NULL,NULL}; void @@ -2584,6 +2572,8 @@ cbdataUnlock(Name->type); } + +/* FIXME: this may need a parent option */ instance_name * parserInstanceNameByName(const char *name) { @@ -2606,8 +2596,8 @@ /* register the type */ debug(3,3)("parserRegisterInstanceName new name '%s'\n",Name); if (instance_names.head==NULL) - CBDATA_INIT_TYPE(instance_name); - Name=CBDATA_ALLOC(instance_name,parserInstanceNameFree); + CBDATA_INIT_TYPE_FREECB(instance_name,parserInstanceNameFree); + Name=cbdataAlloc(instance_name); Name->namestr=xstrdup(namestr); Name->type=parserType; cbdataLock(parserType); @@ -2616,7 +2606,7 @@ dlinkAddTail(Name,&Name->node,&instance_names); return Name; } else { - debug(3,0)("parserRegisterName already registered name '%s'\n",Name); + debug(3,0)("parserRegisterInstanceName already registered name '%s'\n",Name); return NULL; /* TODO: fatal this */ } @@ -2645,6 +2635,7 @@ return NULL; } +/* Called when an unrecognised child of an "instance" type is seen */ static void parse_instance_node(parserNameNode *parserName, void * data) { @@ -2661,10 +2652,10 @@ if ((instance=InstanceByNameStr(Name,token))==NULL) { /* register me */ if (Name->instances.head==NULL) - CBDATA_INIT_TYPE(instance_node); - instance=CBDATA_ALLOC(instance_node,InstanceNodeFree); + CBDATA_INIT_TYPE_FREECB(instance_node,InstanceNodeFree); + instance=cbdataAlloc(instance_node); - debug(3,0)("parsing got token %s\n",token); + debug(3,0)("parsing new instance name %s\n",token); instance->namestr=xstrdup(token); instance->head=&Name->instances; @@ -2738,8 +2729,8 @@ /* register the type */ debug(3,3)("parserRegisterType new type '%s'\n",typestr); if (parserTypes.head==NULL) - CBDATA_INIT_TYPE(parserTypeNode); - parserType=CBDATA_ALLOC(parserTypeNode,parserTypeFree); + CBDATA_INIT_TYPE_FREECB(parserTypeNode,parserTypeFree); + parserType=cbdataAlloc(parserTypeNode); parserType->typestr=typestr; parserType->parsefunc=parsefunc; parserType->freefunc=freefunc; @@ -2842,8 +2833,8 @@ /* register the type */ debug(3,3)("parserRegisterName new name '%s'\n",name); if (parserNames.head==NULL) - CBDATA_INIT_TYPE(parserNameNode); - parserName=CBDATA_ALLOC(parserNameNode,parserNameFree); + CBDATA_INIT_TYPE_FREECB(parserNameNode,parserNameFree); + parserName=cbdataAlloc(parserNameNode); parserName->namestr=name; parserName->type=parserType; cbdataLock(parserType); @@ -3050,7 +3041,10 @@ dlink_node *node; node=parserNames.head; while (node) { - ((parserNameNode *)node->data)->documentfunc(); + if (((parserNameNode *)node->data)->documentfunc) + ((parserNameNode *)node->data)->documentfunc(); + else + printf("directive '%s' has no documented options\n",((parserNameNode *)node->data)->namestr); node=node->next; } } else { @@ -3059,7 +3053,10 @@ docoptionNode *node=DoDocumentOptions->head; while (node) { if ((parserName = parserNameByName(node->name))) - parserName->documentfunc(); + if (parserName->documentfunc) + parserName->documentfunc(); + else + printf("directive '%s' has no documented options\n",node->name); else printf("directive '%s' not found.\n",node->name); node=node->next; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.18.4.17 retrieving revision 1.18.4.18 diff -u -r1.18.4.17 -r1.18.4.18 --- squid/src/protos.h 31 Mar 2001 09:52:20 -0000 1.18.4.17 +++ squid/src/protos.h 31 Mar 2001 11:07:23 -0000 1.18.4.18 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.18.4.17 2001/03/31 09:52:20 rbcollins Exp $ + * $Id: protos.h,v 1.18.4.18 2001/03/31 11:07:23 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -47,6 +47,7 @@ char *log_quote(const char *header); /* acl.c */ +extern void aclParserRegister(void); extern aclCheck_t *aclChecklistCreate(const struct _acl_access *, request_t *, const char *ident); @@ -114,6 +115,7 @@ void * parserRegisterInstanceName(const char *, parserTypeNode *, PARSER_DEFAULT_NONE *, PARSER_POST_PARSE *); +extern instance_node *InstanceByNameStr(instance_name *, const char *); /* * cbdata.c Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.24.4.15 retrieving revision 1.24.4.16 diff -u -r1.24.4.15 -r1.24.4.16 --- squid/src/structs.h 11 Mar 2001 21:43:09 -0000 1.24.4.15 +++ squid/src/structs.h 31 Mar 2001 11:07:23 -0000 1.24.4.16 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.24.4.15 2001/03/11 21:43:09 rbcollins Exp $ + * $Id: structs.h,v 1.24.4.16 2001/03/31 11:07:23 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -299,6 +299,25 @@ dlink_list modules; }; +struct _instance_name { + dlink_node node; + dlink_list instances; + char *namestr; + parserTypeNode *type; + PARSER_DEFAULT_NONE *default_none; + PARSER_NAME_DOCUMENT *documentfunc; + PARSER_POST_PARSE *post_parse_func; +}; + +struct _instance_node { + dlink_node node; + dlink_list *head; + char *namestr; + void *data; + parserNameNode *parserName; + instance_name *name; +}; + struct _parserTypeNode { dlink_node node; const char *typestr; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.15.4.13 retrieving revision 1.15.4.14 diff -u -r1.15.4.13 -r1.15.4.14 --- squid/src/typedefs.h 31 Mar 2001 09:52:20 -0000 1.15.4.13 +++ squid/src/typedefs.h 31 Mar 2001 11:07:23 -0000 1.15.4.14 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.15.4.13 2001/03/31 09:52:20 rbcollins Exp $ + * $Id: typedefs.h,v 1.15.4.14 2001/03/31 11:07:23 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -203,6 +203,8 @@ typedef struct _parserTypeNode parserTypeNode; typedef struct _parserNameNode parserNameNode; typedef struct _includefile_t includefile_t; +typedef struct _instance_name instance_name; +typedef struct _instance_node instance_node; typedef void PARSER_PARSE(parserNameNode *, void *); typedef void PARSER_FREE (parserNameNode *, void *); /* the next one is different to the cache_cf entries, because it has to be */ Index: squid/src/auth/ntlm/auth_ntlm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/auth_ntlm.c,v retrieving revision 1.7.6.6 retrieving revision 1.7.6.7 diff -u -r1.7.6.6 -r1.7.6.7 --- squid/src/auth/ntlm/auth_ntlm.c 31 Mar 2001 09:52:20 -0000 1.7.6.6 +++ squid/src/auth/ntlm/auth_ntlm.c 31 Mar 2001 11:07:23 -0000 1.7.6.7 @@ -636,8 +636,8 @@ debug(29, 4) ("authenticateNTLMChangeChallenge: Challenge uses (%d) exceeded max uses (%d)\n", helperstate->challengeuses, ntlmConfig.challengeuses); return 1; } - if (helperstate->renewed + ntlmConfig->challengelifetime < squid_curtime) { - debug(29, 4) ("authenticateNTLMChangeChallenge: Challenge exceeded max lifetime by %d seconds\n", squid_curtime - (helperstate->renewed + ntlmConfig->challengelifetime)); + if (helperstate->renewed + ntlmConfig.challengelifetime < squid_curtime) { + debug(29, 4) ("authenticateNTLMChangeChallenge: Challenge exceeded max lifetime by %d seconds\n", squid_curtime - (helperstate->renewed + ntlmConfig.challengelifetime)); return 1; } debug(29, 9) ("Challenge is to be reused\n");