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 = ""; |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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 */ |
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 |
|
|
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 |
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) |
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) |