Changeset 729 for branches/ithildin-1.1


Ignore:
Timestamp:
05/12/06 01:42:19 (6 years ago)
Author:
wd
Message:

ACLs should use lists, not tailqs. This is old bogus stuff from a previous
incarnation of this code that never got fixed...

Location:
branches/ithildin-1.1/modules/ircd/addons
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ithildin-1.1/modules/ircd/addons/acl.c

    r725 r729  
    4545    acl_t *ap, *ap2; 
    4646    char *at, hostcopy[USERLEN + HOSTLEN + 2]; 
    47     struct acl_tq *list; 
     47    struct acl_list *list; 
    4848     
    4949    if ((ap = find_acl(stage, host, type, NULL, NULL)) != NULL) { 
     
    9090        list = acl.stage3_list; 
    9191 
    92     if (TAILQ_EMPTY(list)) 
    93         TAILQ_INSERT_HEAD(list, ap, intlp); 
     92    if (LIST_EMPTY(list)) 
     93        LIST_INSERT_HEAD(list, ap, intlp); 
    9494    else { 
    95         TAILQ_FOREACH(ap2, list, intlp) { 
     95        LIST_FOREACH(ap2, list, intlp) { 
    9696            if (ap2->rule > ap->rule) { 
    97                 TAILQ_INSERT_BEFORE(ap2, ap, intlp); 
     97                LIST_INSERT_BEFORE(ap2, ap, intlp); 
    9898                break; 
    99             } 
    100         } 
    101         if (ap2 == NULL) 
    102             TAILQ_INSERT_TAIL(list, ap, intlp); 
     99            } else if (LIST_NEXT(ap2, intlp) == NULL) 
     100                LIST_INSERT_AFTER(ap2, ap, intlp); 
     101        } 
    103102    } 
    104103 
     
    155154acl_t *find_acl(int stage, char *hostmask, const char *type, char *pass, 
    156155        char *info) { 
    157     struct acl_tq *list; 
     156    struct acl_list *list; 
    158157    char *at, hostcopy[USERLEN + HOSTLEN + 2], user[USERLEN + 1]; 
    159158    char host[HOSTLEN + 1]; 
     
    180179 
    181180    /* now try and find them in the bucket. */ 
    182     TAILQ_FOREACH(ap, list, intlp) { 
     181    LIST_FOREACH(ap, list, intlp) { 
    183182        if (!strcasecmp(ap->user, user) && !strcasecmp(ap->host, host) && 
    184183                !strcasecmp(ap->type, type) && 
     
    202201    /* and remove it from whatever list it's in */ 
    203202    if (ap->stage == ACL_STAGE_CONNECT) 
    204         TAILQ_REMOVE(acl.stage1_list, ap, intlp); 
     203        LIST_REMOVE(ap, intlp); 
    205204    else if (ap->stage == ACL_STAGE_PREREG) 
    206         TAILQ_REMOVE(acl.stage2_list, ap, intlp); 
     205        LIST_REMOVE(ap, intlp); 
    207206    else 
    208         TAILQ_REMOVE(acl.stage3_list, ap, intlp); 
     207        LIST_REMOVE(ap, intlp); 
    209208 
    210209    /* now free the memory */ 
     
    310309    /* now match.  skip over any entries that aren't the default hash or our 
    311310     * hash. */ 
    312     TAILQ_FOREACH(ap, acl.stage1_list, intlp) { 
     311    LIST_FOREACH(ap, acl.stage1_list, intlp) { 
    313312        if (ap->hash != hash && ap->hash != ACL_DEFAULT_HASH) 
    314313            continue; 
     
    349348     * and the ip (using hostmatch and ipmatch).  All together that is four 
    350349     * calls.  Also, our hash space is expanded. */ 
    351     TAILQ_FOREACH(ap, acl.stage2_list, intlp) { 
     350    LIST_FOREACH(ap, acl.stage2_list, intlp) { 
    352351        if (ap->hash != hash && ap->hash != iphash && 
    353352                ap->hash != ACL_DEFAULT_HASH) 
     
    395394     * aren't allowed because of a class being full we actually have to keep on 
    396395     * looking to see if they fit in somewhere else. blechhh. */ 
    397     TAILQ_FOREACH(ap, acl.stage3_list, intlp) { 
     396    LIST_FOREACH(ap, acl.stage3_list, intlp) { 
    398397        if (ap->hash != hash && ap->hash != iphash && 
    399398                ap->hash != ACL_DEFAULT_HASH) 
     
    442441    } 
    443442 
    444     if (ret == NULL && !TAILQ_EMPTY(acl.stage3_list)) 
     443    if (ret == NULL && !LIST_EMPTY(acl.stage3_list)) 
    445444        return "You are not authorised to use this server."; 
    446445    return ret; 
     
    611610     * for ACLs based on four parameters: mask, stage, access, and type. */ 
    612611    acl_t *ap; 
    613     struct acl_tq *list; 
     612    struct acl_list *list; 
    614613    char rpl[XINFO_LEN]; 
    615614    char *mask = NULL, *type = NULL; 
     
    684683    } 
    685684    while (list != NULL) { 
    686         TAILQ_FOREACH(ap, list, intlp) { 
     685        LIST_FOREACH(ap, list, intlp) { 
    687686            if (acc != -1 && ap->access != acc) 
    688687                continue; 
     
    733732 
    734733    LIST_ALLOC(acl.list); 
    735     TAILQ_ALLOC(acl.stage1_list); 
    736     TAILQ_ALLOC(acl.stage2_list); 
    737     TAILQ_ALLOC(acl.stage3_list); 
     734    LIST_ALLOC(acl.stage1_list); 
     735    LIST_ALLOC(acl.stage2_list); 
     736    LIST_ALLOC(acl.stage3_list); 
    738737 
    739738    add_xinfo_handler(xinfo_acl_handler, "ACL", XINFO_HANDLER_OPER, NULL, 
     
    755754        destroy_acl(LIST_FIRST(acl.list)); 
    756755    LIST_FREE(acl.list); 
    757     TAILQ_FREE(acl.stage1_list); 
    758     TAILQ_FREE(acl.stage2_list); 
    759     TAILQ_FREE(acl.stage3_list); 
     756    LIST_FREE(acl.stage1_list); 
     757    LIST_FREE(acl.stage2_list); 
     758    LIST_FREE(acl.stage3_list); 
    760759 
    761760    remove_xinfo_handler(xinfo_acl_handler); 
  • branches/ithildin-1.1/modules/ircd/addons/acl.h

    r725 r729  
    4747                                       NULL otherwise. */ 
    4848 
    49     TAILQ_ENTRY(acl) intlp;         /* list pointers.  intlp is for internal */ 
    50     LIST_ENTRY(acl) lp;             /* use.  lp is part of 'the big list'. */ 
     49    LIST_ENTRY(acl) intlp;          /* list pointers.  intlp is for internal 
     50                                       (stage-segregated) lists */ 
     51    LIST_ENTRY(acl) lp;             /* lp is for the 'big list'. */ 
    5152} acl_t; 
    5253 
    53 TAILQ_HEAD(acl_tq, acl); 
     54LIST_HEAD(acl_list, acl); 
    5455 
    5556extern struct acl_module_data { 
    56     struct acl_tq *stage1_list; 
    57     struct acl_tq *stage2_list; 
    58     struct acl_tq *stage3_list; 
    59     LIST_HEAD(, acl) *list; 
     57    struct acl_list *stage1_list; 
     58    struct acl_list *stage2_list; 
     59    struct acl_list *stage3_list; 
     60    struct acl_list *list; 
    6061 
    6162    unsigned short default_rule; 
Note: See TracChangeset for help on using the changeset viewer.