Patch: Long SMTP response lines

Patrick Ben Koetter p at sys4.de
Wed Jul 11 21:43:23 CEST 2018


The attached patch sets a new length for SMTP response lines and makes the
length configurable at the same time.

It became necessary to develop this patch, to store (and not truncate) SMTP
responses when multiple virus scanners detect malware and all report the
finding and the overall length exceeds the (old) SMTP response length.

In this case only a truncated string would be written to the datebase, which
made it impossible to come up with complete reporting.

p at rick



-- 
[*] sys4 AG
 
https://sys4.de, +49 (89) 30 90 46 64
Schleißheimer Straße 26/MG,80333 München
 
Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer, Wolfgang Stief
Aufsichtsratsvorsitzender: Florian Kirstein
 
-------------- next part --------------
--- amavisd-new-2.11.0/amavisd	2016-04-26 21:24:33.000000000 +0200
+++ amavis-patched/amavisd	2018-07-11 16:27:29.603420699 +0200
@@ -388,6 +388,8 @@
       @listen_sockets $inet_socket_port $inet_socket_bind $listen_queue_size
       $smtpd_recipient_limit $unix_socketname $unix_socket_mode
       $smtp_connection_cache_on_demand $smtp_connection_cache_enable
+      $enable_long_smtp_resp
+      $long_smtp_resp_length
       %smtp_tls_client_options %smtpd_tls_server_options
       $smtpd_tls_cert_file $smtpd_tls_key_file
       $enforce_smtpd_message_size_limit_64kb_min
@@ -990,6 +992,10 @@
 
   $smtpd_recipient_limit = 1100; # max recipients (RCPT TO) - sanity limit
 
+#  $enable_long_smtp_resp = 1; # allow longer smtp responses to be logged to database 
+  # length limit of longer smtp responses
+  $long_smtp_resp_length = 255; # changing this value must be in accordance with database 
+
   # $myhostname is used by SMTP server module in the initial SMTP welcome line,
   # in inserted Received: lines, Message-ID in notifications, log entries, ...
   $myhostname = (POSIX::uname)[1];  # should be a FQDN !
@@ -27472,7 +27478,8 @@
         my $r_content_type =
           $r->setting_by_contents_category(\%ccat_short_name);
         for ($r_content_type) { $_ = ' '  if !defined $_ || /^ *\z/ }
-        substr($resp,255) = ''  if length($resp) > 255;
+	my $respmaxlength=($enable_long_smtp_resp ? $long_smtp_resp_length : 255);
+        substr($resp,$respmaxlength) = ''  if length($resp) > $respmaxlength;
         $resp =~ s/[^\040-\176]/?/gs;  # just in case, only need 7 bit printbl
         # avoid op '?:' on tainted operand in args list, see PR [perl #81028]
         my $recip_local_yn = $r->recip_is_local ? 'Y' : 'N';


More information about the amavis-users mailing list