comparison src/dnsbl.cpp @ 153:8d7c439bb6fa

add auto whitelisting
author carl
date Sat, 07 Jul 2007 16:10:39 -0700
parents c7fc218686f5
children 89ce226e5383
comparison
equal deleted inserted replaced
152:c7fc218686f5 153:8d7c439bb6fa
1019 if (!rc) { 1019 if (!rc) {
1020 smfi_setreply(ctx, "550", "5.7.1", "no such user"); 1020 smfi_setreply(ctx, "550", "5.7.1", "no such user");
1021 return SMFIS_REJECT; 1021 return SMFIS_REJECT;
1022 } 1022 }
1023 } 1023 }
1024 // we will accept the recipient, but add an auto-whitelist entry
1025 // if needed to ensure we can accept replies
1026 WHITELISTERP w = con2.find_autowhite(priv.mailaddr);
1027 if (w) {
1028 char *loto = to_lower_string(rcptaddr);
1029 w->sent(loto);
1030 free(loto);
1031 }
1024 // accept the recipient 1032 // accept the recipient
1025 if (!con.get_content_filtering()) st = white; 1033 if (!con.get_content_filtering()) st = white;
1026 if (st == oksofar) { 1034 if (st == oksofar) {
1027 // but remember the non-whites 1035 // but remember the non-whites
1028 priv.need_content_filter(rcptaddr, con); 1036 priv.need_content_filter(rcptaddr, con);
1447 // initialize the thread sync objects 1455 // initialize the thread sync objects
1448 pthread_mutex_init(&config_mutex, 0); 1456 pthread_mutex_init(&config_mutex, 0);
1449 pthread_mutex_init(&syslog_mutex, 0); 1457 pthread_mutex_init(&syslog_mutex, 0);
1450 pthread_mutex_init(&resolve_mutex, 0); 1458 pthread_mutex_init(&resolve_mutex, 0);
1451 pthread_mutex_init(&fd_pool_mutex, 0); 1459 pthread_mutex_init(&fd_pool_mutex, 0);
1460 pthread_mutex_init(&verifier_mutex, 0);
1461 pthread_mutex_init(&whitelister_mutex, 0);
1452 1462
1453 // drop root privs 1463 // drop root privs
1454 struct passwd *pw = getpwnam("dnsbl"); 1464 struct passwd *pw = getpwnam("dnsbl");
1455 if (pw) { 1465 if (pw) {
1456 if (setgid(pw->pw_gid) == -1) { 1466 if (setgid(pw->pw_gid) == -1) {
1542 pthread_t tid; 1552 pthread_t tid;
1543 if (pthread_create(&tid, 0, config_loader, 0)) 1553 if (pthread_create(&tid, 0, config_loader, 0))
1544 my_syslog("failed to create config loader thread"); 1554 my_syslog("failed to create config loader thread");
1545 if (pthread_detach(tid)) 1555 if (pthread_detach(tid))
1546 my_syslog("failed to detach config loader thread"); 1556 my_syslog("failed to detach config loader thread");
1557
1547 if (pthread_create(&tid, 0, verify_closer, 0)) 1558 if (pthread_create(&tid, 0, verify_closer, 0))
1548 my_syslog("failed to create verify closer thread"); 1559 my_syslog("failed to create verify closer thread");
1549 if (pthread_detach(tid)) 1560 if (pthread_detach(tid))
1550 my_syslog("failed to detach verify closer thread"); 1561 my_syslog("failed to detach verify closer thread");
1562
1563 if (pthread_create(&tid, 0, whitelister_writer, 0))
1564 my_syslog("failed to create autowhite writer thread");
1565 if (pthread_detach(tid))
1566 my_syslog("failed to detach autowhite writer thread");
1551 1567
1552 time_t starting = time(NULL); 1568 time_t starting = time(NULL);
1553 int rc = smfi_main(); 1569 int rc = smfi_main();
1554 if ((rc != MI_SUCCESS) && (time(NULL) > starting+5*60)) { 1570 if ((rc != MI_SUCCESS) && (time(NULL) > starting+5*60)) {
1555 my_syslog("trying to restart after smfi_main()"); 1571 my_syslog("trying to restart after smfi_main()");