ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/hostmask.c
(Generate patch)

Comparing ircd-hybrid-8/src/hostmask.c (file contents):
Revision 1369 by michael, Wed Apr 25 19:04:19 2012 UTC vs.
Revision 1371 by michael, Wed Apr 25 19:32:21 2012 UTC

# Line 455 | Line 455 | get_mask_hash(const char *text)
455   */
456   struct AccessItem *
457   find_conf_by_address(const char *name, struct irc_ssaddr *addr, unsigned int type,
458 <                     int fam, const char *username, const char *password)
458 >                     int fam, const char *username, const char *password, int do_match)
459   {
460    unsigned int hprecv = 0;
461    dlink_node *ptr = NULL;
462    struct AccessItem *hprec = NULL;
463    struct AddressRec *arec;
464    int b;
465 +  int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp;
466  
467    if (username == NULL)
468      username = "";
# Line 485 | Line 486 | find_conf_by_address(const char *name, s
486                arec->masktype == HM_IPV6 &&
487                match_ipv6(addr, &arec->Mask.ipa.addr,
488                           arec->Mask.ipa.bits) &&
489 <              (type & 0x1 || match(arec->username, username)) &&
489 >              (type & 0x1 || cmpfunc(arec->username, username) == do_match) &&
490                (IsNeedPassword(arec->aconf) || arec->aconf->passwd == NULL ||
491                 match_conf_password(password, arec->aconf)))
492            {
# Line 510 | Line 511 | find_conf_by_address(const char *name, s
511                arec->masktype == HM_IPV4 &&
512                match_ipv4(addr, &arec->Mask.ipa.addr,
513                           arec->Mask.ipa.bits) &&
514 <              (type & 0x1 || match(arec->username, username)) &&
514 >              (type & 0x1 || cmpfunc(arec->username, username) == do_match) &&
515                (IsNeedPassword(arec->aconf) || arec->aconf->passwd == NULL ||
516                 match_conf_password(password, arec->aconf)))
517            {
# Line 534 | Line 535 | find_conf_by_address(const char *name, s
535            if ((arec->type == (type & ~0x1)) &&
536              arec->precedence > hprecv &&
537              (arec->masktype == HM_HOST) &&
538 <            match(arec->Mask.hostname, name) &&
539 <            (type & 0x1 || match(arec->username, username)) &&
538 >            cmpfunc(arec->Mask.hostname, name) == do_match &&
539 >            (type & 0x1 || cmpfunc(arec->username, username) == do_match) &&
540              (IsNeedPassword(arec->aconf) || arec->aconf->passwd == NULL ||
541               match_conf_password(password, arec->aconf)))
542          {
# Line 556 | Line 557 | find_conf_by_address(const char *name, s
557        if (arec->type == (type & ~0x1) &&
558            arec->precedence > hprecv &&
559            arec->masktype == HM_HOST &&
560 <          match(arec->Mask.hostname, name) &&
561 <          (type & 0x1 || match(arec->username, username)) &&
560 >          cmpfunc(arec->Mask.hostname, name) == do_match &&
561 >          (type & 0x1 || cmpfunc(arec->username, username) == do_match) &&
562            (IsNeedPassword(arec->aconf) || arec->aconf->passwd == NULL ||
563             match_conf_password(password, arec->aconf)))
564        {
# Line 584 | Line 585 | find_address_conf(const char *host, cons
585  
586    /* Find the best I-line... If none, return NULL -A1kmm */
587    if ((iconf = find_conf_by_address(host, ip, CONF_CLIENT, aftype, user,
588 <                                    password)) == NULL)
588 >                                    password, 1)) == NULL)
589      return NULL;
590  
591    /* If they are exempt from K-lines, return the best I-line. -A1kmm */
# Line 592 | Line 593 | find_address_conf(const char *host, cons
593      return iconf;
594  
595    /* Find the best K-line... -A1kmm */
596 <  kconf = find_conf_by_address(host, ip, CONF_KLINE, aftype, user, NULL);
596 >  kconf = find_conf_by_address(host, ip, CONF_KLINE, aftype, user, NULL, 1);
597  
598    /* If they are K-lined, return the K-line. Otherwise, return the
599     * I-line. -A1kmm */
600    if (kconf != NULL)
601      return kconf;
602  
603 <  kconf = find_conf_by_address(host, ip, CONF_GLINE, aftype, user, NULL);
603 >  kconf = find_conf_by_address(host, ip, CONF_GLINE, aftype, user, NULL, 1);
604    if (kconf != NULL && !IsConfExemptGline(iconf))
605      return kconf;
606  
# Line 613 | Line 614 | find_gline_conf(const char *host, const
614    struct AccessItem *eline;
615  
616    eline = find_conf_by_address(host, ip, CONF_EXEMPTKLINE, aftype,
617 <                               user, NULL);
617 >                               user, NULL, 1);
618    if (eline != NULL)
619      return eline;
620  
621 <  return find_conf_by_address(host, ip, CONF_GLINE, aftype, user, NULL);
621 >  return find_conf_by_address(host, ip, CONF_GLINE, aftype, user, NULL, 1);
622   }
623  
624   /* find_kline_conf
# Line 635 | Line 636 | find_kline_conf(const char *host, const
636    struct AccessItem *eline;
637  
638    eline = find_conf_by_address(host, ip, CONF_EXEMPTKLINE, aftype,
639 <                               user, NULL);
639 >                               user, NULL, 1);
640    if (eline != NULL)
641      return eline;
642  
643 <  return find_conf_by_address(host, ip, CONF_KLINE, aftype, user, NULL);
643 >  return find_conf_by_address(host, ip, CONF_KLINE, aftype, user, NULL, 1);
644   }
645  
646   /* struct AccessItem* find_dline_conf(struct irc_ssaddr*, int)
# Line 654 | Line 655 | find_dline_conf(struct irc_ssaddr *addr,
655    struct AccessItem *eline;
656  
657    eline = find_conf_by_address(NULL, addr, CONF_EXEMPTDLINE | 1, aftype,
658 <                               NULL, NULL);
658 >                               NULL, NULL, 1);
659    if (eline != NULL)
660      return eline;
661  
662 <  return find_conf_by_address(NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
662 >  return find_conf_by_address(NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL, 1);
663   }
664  
665   /* void add_conf_by_address(int, struct AccessItem *aconf)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines