v. 2021.08.14 Patch for simscan-1.4.1 (https://github.com/qmail/simscan/releases) by Roberto Puzzanghera More info at https://notes.sagredo.eu/en/qmail-notes-185/simscan-38.html Simscan doesn't pass messages over 250k to spamassassin. This patch let the administrator set the attachments' size limit in bytes by setting the /var/qmail/control/simsizelimit file. Furthermore, events where simscan is not activated are now logged at smtpd level (it was logged only when debug is active). Note: this patch is alternative to this one https://notes.sagredo.eu/files/qmail/patches/simscan/simscan-1.4.1_attachments-size-limit.patch which sets the limit at compilation time. =================================================================================================== diff -ruN ../simscan-1.4.1_original/simscan.c simscan-1.4.1/simscan.c --- ../simscan-1.4.1_original/simscan.c 2015-01-23 09:57:43.000000000 +0100 +++ simscan-1.4.1/simscan.c 2021-08-14 11:29:23.134153119 +0200 @@ -253,6 +253,11 @@ int i = 0; int gotrcpt = 0; int gotfrom = 0; + /* attachments-size-limit patch */ + char ch, simsizelimit_file[300], buf[32]; + FILE *simsizelimit; + int size_limit=250000, buflen=0, ibuf; + /* end attachments-size-limit patch */ /* print out version information if requested */ if ( argc > 1 && strcmp(argv[1],"-v" )==0 ) { @@ -546,11 +551,33 @@ #endif #ifdef ENABLE_SPAM -if (msgsize >= 250000) { - if ( DebugFlag > 0 ) { - fprintf(stderr, "simscan: big file (%lu bytes); skipping SpamAssassin\n", - (unsigned long) msgsize); +/* attachments-size-limit patch */ +// read control/simsizelimit file +snprintf(simsizelimit_file, sizeof(simsizelimit_file), "%s/simsizelimit", CONTROLDIR); +simsizelimit = fopen(simsizelimit_file, "r"); +if( simsizelimit != NULL ) { + while(1) { + ch = fgetc(simsizelimit); + if(ch==EOF || ch==' ' || ch=='\n' || ch=='\t' || ch=='\r') { + ibuf = atoi(buf); + // returns 0 if it's not an integer + if (ibuf > 0) size_limit = ibuf; + break; + } + else { + buf[buflen] = ch; + buflen++; + } } + fclose(simsizelimit); +} +if ( DebugFlag > 0 ) fprintf(stderr, "simscan: size limit is %d bytes\n", size_limit); +if (msgsize >= size_limit) { +// if ( DebugFlag > 0 ) { // now logging also when debug is off + fprintf(stderr, "simscan: big file (%lu bytes); size limit is %d bytes; skipping SpamAssassin\n", + (unsigned long) msgsize, size_limit); +// } +/* end attachments-size-limit patch */ } else { /* re-open the file read only */ if ( (fd = open(message_name, O_RDONLY)) == -1 ) {