comparison src/context.cpp @ 167:9b129ed78d7d stable-6-0-6

actually use spamassassin result, allow build without spam assassin, only call it if some recipient needs it.
author carl
date Mon, 27 Aug 2007 20:49:19 -0700
parents 5809bcdc325b
children 6bac960af6b4
comparison
equal deleted inserted replaced
166:7161d8451fcf 167:9b129ed78d7d
644 return default_context; 644 return default_context;
645 } 645 }
646 646
647 647
648 void CONFIG::dump() { 648 void CONFIG::dump() {
649 if (default_context) default_context->dump(true); 649 bool spamass = false;
650 if (default_context) default_context->dump(true, spamass);
650 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) { 651 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
651 CONTEXTP c = *i; 652 CONTEXTP c = *i;
652 CONTEXTP p = c->get_parent(); 653 CONTEXTP p = c->get_parent();
653 if (!p && (c != default_context)) c->dump(false); 654 if (!p && (c != default_context)) c->dump(false, spamass);
654 } 655 }
655 char buf[maxlen]; 656 char buf[maxlen];
656 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) { 657 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) {
657 char *to = (*i).first; 658 char *to = (*i).first;
658 CONTEXTP con = (*i).second; 659 CONTEXTP con = (*i).second;
659 printf("// envelope to %s \t-> context %s \n", to, con->get_full_name(buf,maxlen)); 660 printf("// envelope to %s \t-> context %s \n", to, con->get_full_name(buf,maxlen));
661 }
662 if (spamass && (spamc == spamc_empty)) {
663 printf("// *** warning - spamassassin filtering requested, but spamc not found by autoconf.\n");
660 } 664 }
661 } 665 }
662 666
663 667
664 CONTEXT::CONTEXT(CONTEXTP parent_, char *name_) { 668 CONTEXT::CONTEXT(CONTEXTP parent_, char *name_) {
861 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list(); 865 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list();
862 return dnsbl_list; 866 return dnsbl_list;
863 } 867 }
864 868
865 869
866 bool CONTEXT::acceptable_content(recorder &memory, int score, char *&msg) { 870 bool CONTEXT::acceptable_content(recorder &memory, int score, string& msg) {
867 if (spamassassin_limit && (score > spamassassin_limit)) { 871 if (spamassassin_limit && (score > spamassassin_limit)) {
868 msg = "Mail rejected by spam assassin"; 872 char buf[maxlen];
873 snprintf(buf, sizeof(buf), "Mail rejected - spam assassin score %d", score);
874 msg = string(buf);
875 return false;
869 } 876 }
870 if (memory.excessive_bad_tags(tag_limit)) { 877 if (memory.excessive_bad_tags(tag_limit)) {
871 msg = tag_limit_message; 878 msg = string(tag_limit_message);
872 return false; 879 return false;
873 } 880 }
874 if (!host_random && memory.excessive_hosts(host_limit)) { 881 if (!host_random && memory.excessive_hosts(host_limit)) {
875 msg = host_limit_message; 882 msg = string(host_limit_message);
876 return false; 883 return false;
877 } 884 }
878 return true; 885 return true;
879 } 886 }
880 887
881 888
882 void CONTEXT::dump(bool isdefault, int level) { 889 void CONTEXT::dump(bool isdefault, bool &spamass, int level) {
883 char indent[maxlen]; 890 char indent[maxlen];
884 int i = min(maxlen-1, level*4); 891 int i = min(maxlen-1, level*4);
885 memset(indent, ' ', i); 892 memset(indent, ' ', i);
886 indent[i] = '\0'; 893 indent[i] = '\0';
887 char buf[maxlen]; 894 char buf[maxlen];
958 else { 965 else {
959 printf("%s html_limit off; \n", indent); 966 printf("%s html_limit off; \n", indent);
960 } 967 }
961 printf("%s spamassassin %d; \n", indent, spamassassin_limit); 968 printf("%s spamassassin %d; \n", indent, spamassassin_limit);
962 printf("%s }; \n", indent); 969 printf("%s }; \n", indent);
970 spamass |= (spamassassin_limit != 0);
963 } 971 }
964 else { 972 else {
965 printf("%s content off {}; \n", indent, env_from_default); 973 printf("%s content off {}; \n", indent, env_from_default);
966 } 974 }
967 975
979 printf("%s autowhite %d %s; \n", indent, whitelister->get_days(), autowhite_file); 987 printf("%s autowhite %d %s; \n", indent, whitelister->get_days(), autowhite_file);
980 } 988 }
981 989
982 for (context_map::iterator i=children.begin(); i!=children.end(); i++) { 990 for (context_map::iterator i=children.begin(); i!=children.end(); i++) {
983 CONTEXTP c = (*i).second; 991 CONTEXTP c = (*i).second;
984 c->dump(false, level+1); 992 c->dump(false, spamass, level+1);
985 } 993 }
986 994
987 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname); 995 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname);
988 if (!env_from.empty()) { 996 if (!env_from.empty()) {
989 printf("%s // white/black/unknown \n", indent); 997 printf("%s // white/black/unknown \n", indent);