[READ-ONLY] Mirror of https://github.com/VibeDevelopers/Comet.
0

Configure Feed

Select the types of activity you want to include in your feed.

authd: fix crash/restart breaking DNSBL lookups (#394)

authd child processes are only told about configured DNSBLs when the
configuration is being parsed.

This is bad, because when authd crashes or is killed, IRCd will restart
it, but will not tell it about any configured DNSBLs until IRCd is next
rehashed.

We already have a dictionary that stores configured DNSBLs (for hit
statistics for `STATS n'), so store the additional needed fields in
that structure, and loop over that dictionary's entries when authd is
restarted, sending the fields just as if the configuration were being
reloaded.

Reported-By: @Unit193

authored by

Aaron Jones and committed by
GitHub
(Jan 11, 2023, 1:28 AM UTC) fbc97166 32d37a16

+38 -20
+3 -1
include/authproc.h
··· 30 30 #include "rb_dictionary.h" 31 31 #include "client.h" 32 32 33 - struct DNSBLEntryStats 33 + struct DNSBLEntry 34 34 { 35 35 char *host; 36 + char *reason; 37 + char *filters; 36 38 uint8_t iptype; 37 39 unsigned int hits; 38 40 };
+29 -13
ircd/authproc.c
··· 348 348 } 349 349 else 350 350 opm_check_enable(false); 351 + 352 + /* Configure DNSBLs */ 353 + rb_dictionary_iter iter; 354 + struct DNSBLEntry *entry; 355 + RB_DICTIONARY_FOREACH(entry, &iter, dnsbl_stats) 356 + { 357 + rb_helper_write(authd_helper, "O rbl %s %hhu %s :%s", entry->host, 358 + entry->iptype, entry->filters, entry->reason); 359 + } 351 360 } 352 361 353 362 static void ··· 584 593 add_dnsbl_entry(const char *host, const char *reason, uint8_t iptype, rb_dlink_list *filters) 585 594 { 586 595 rb_dlink_node *ptr; 587 - struct DNSBLEntryStats *stats = rb_malloc(sizeof(*stats)); 596 + struct DNSBLEntry *entry = rb_malloc(sizeof(*entry)); 588 597 char filterbuf[BUFSIZE] = "*"; 589 598 size_t s = 0; 590 599 ··· 610 619 if(s) 611 620 filterbuf[s - 1] = '\0'; 612 621 613 - stats->host = rb_strdup(host); 614 - stats->iptype = iptype; 615 - stats->hits = 0; 616 - rb_dictionary_add(dnsbl_stats, stats->host, stats); 622 + entry->host = rb_strdup(host); 623 + entry->reason = rb_strdup(reason); 624 + entry->filters = rb_strdup(filterbuf); 625 + entry->iptype = iptype; 626 + entry->hits = 0; 617 627 628 + rb_dictionary_add(dnsbl_stats, entry->host, entry); 618 629 rb_helper_write(authd_helper, "O rbl %s %hhu %s :%s", host, iptype, filterbuf, reason); 619 630 } 620 631 ··· 622 633 void 623 634 del_dnsbl_entry(const char *host) 624 635 { 625 - struct DNSBLEntryStats *stats = rb_dictionary_retrieve(dnsbl_stats, host); 626 - if(stats != NULL) 636 + struct DNSBLEntry *entry = rb_dictionary_retrieve(dnsbl_stats, host); 637 + 638 + if(entry != NULL) 627 639 { 628 - rb_dictionary_delete(dnsbl_stats, host); 629 - rb_free(stats->host); 630 - rb_free(stats); 640 + rb_dictionary_delete(dnsbl_stats, entry->host); 641 + rb_free(entry->host); 642 + rb_free(entry->reason); 643 + rb_free(entry->filters); 644 + rb_free(entry); 631 645 } 632 646 633 647 rb_helper_write(authd_helper, "O rbl_del %s", host); ··· 636 650 static void 637 651 dnsbl_delete_elem(rb_dictionary_element *delem, void *unused) 638 652 { 639 - struct DNSBLEntryStats *stats = delem->data; 653 + struct DNSBLEntry *entry = delem->data; 640 654 641 - rb_free(stats->host); 642 - rb_free(stats); 655 + rb_free(entry->host); 656 + rb_free(entry->reason); 657 + rb_free(entry->filters); 658 + rb_free(entry); 643 659 } 644 660 645 661 /* Delete all the DNSBL entries. */
+3 -3
ircd/s_user.c
··· 215 215 { 216 216 case 'B': /* DNSBL */ 217 217 { 218 - struct DNSBLEntryStats *stats; 218 + struct DNSBLEntry *entry; 219 219 char *dnsbl_name = source_p->preClient->auth.data; 220 220 221 221 if(dnsbl_stats != NULL) 222 - if((stats = rb_dictionary_retrieve(dnsbl_stats, dnsbl_name)) != NULL) 223 - stats->hits++; 222 + if((entry = rb_dictionary_retrieve(dnsbl_stats, dnsbl_name)) != NULL) 223 + entry->hits++; 224 224 225 225 if(IsExemptKline(source_p) || IsConfExemptDNSBL(aconf)) 226 226 {
+3 -3
modules/m_stats.c
··· 727 727 stats_dnsbl(struct Client *source_p) 728 728 { 729 729 rb_dictionary_iter iter; 730 - struct DNSBLEntryStats *stats; 730 + struct DNSBLEntry *entry; 731 731 732 732 if(dnsbl_stats == NULL) 733 733 return; 734 734 735 - RB_DICTIONARY_FOREACH(stats, &iter, dnsbl_stats) 735 + RB_DICTIONARY_FOREACH(entry, &iter, dnsbl_stats) 736 736 { 737 737 /* use RPL_STATSDEBUG for now -- jilles */ 738 738 sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s", 739 - stats->hits, (const char *)iter.cur->key); 739 + entry->hits, entry->host); 740 740 } 741 741 } 742 742