Re: [Exim] too large messages don't get logged

Top Page
Delete this message
Reply to this message
Author: Pete Naylor
Date:  
To: Philip Hazel
CC: Hirling Endre, exim-users@exim.org
Subject: Re: [Exim] too large messages don't get logged

Philip Hazel wrote...

> On Fri, 16 Jun 2000, Pete Naylor wrote:
>
> > Hirling Endre wrote...
> >
> > > Recently I saw that exim doesn't log messages rejected
> > > because of their size if the sender supports ESMTP and tells
> > > the message's size at the end of the MAIL FROM command.
> >
> > With the default configuration such rejections are logged both to the main
> > and the reject log - grep for " message too large:".
>
> That message happens only if the message exceeds the maximum size while
> it is being read. Hirling Endre is correct in stating that there is no
> logging if the MAIL FROM command is rejected because the SIZE parameter
> is over the limit. I should probably do something about that.


Hrm. That should teach me not to respond before reading a message twice.

I started to build what I thought would be a very simple patch for this,
but it got a bit messy. Seems like the logged message should indicate the
sender_address, but sender_address is not parsed until after the ESMTP
options - so I moved the checking of SIZE against message_size_limit to be
right after the parsing/rewriting of sender_address. Then I had to move
the checking of spool space to happen after that check. Anyway, patch
attached - perhaps it'll save you a little time Philip, and might be
useful to Hirling in the meantime.

--
Pete Naylor
*** smtp_in.c.bak    Sun Apr 30 01:16:22 2000
--- smtp_in.c    Sat Jun 17 14:37:55 2000
***************
*** 2177,2209 ****


        if (!extract_option(&name, &value)) break;


!       /* Handle SIZE=. If there is a configured size limit for mail, check that
!       this message doesn't exceed it. */


        if (strcmpic(name, "SIZE") == 0 &&
            ((size = (int)strtoul(value, &end, 10)), *end == 0))
          {
!         if (message_size_limit > 0 && size > message_size_limit)
!           {
!           smtp_printf("552 Message size exceeds maximum permitted\r\n");
!           goto COMMAND_LOOP;
!           }
! 
!         /* Check there is enough space on the disc unless configured not to.
!         The check is for message_size_limit plus the argument - i.e. we accept
!         the message only if it won't reduce the space below the threshold. Add
!         5000 to the size to allow for overheads such as the Received line and
!         storing of recipients, etc. */
! 
!         if (smtp_check_spool_space)
!           {
!           if (!accept_check_fs(size + 5000))
!             {
!             smtp_printf("452 space shortage, please try later\r\n");
!             goto COMMAND_LOOP;
!             }
!           size_checked = TRUE;    /* No need to check again below */
!           }
          }


        /* If this session was initiated with EHLO and accept_8bitmime is set,
--- 2177,2188 ----


        if (!extract_option(&name, &value)) break;


!       /* Handle SIZE= */


        if (strcmpic(name, "SIZE") == 0 &&
            ((size = (int)strtoul(value, &end, 10)), *end == 0))
          {
!     message_size = size;
          }


        /* If this session was initiated with EHLO and accept_8bitmime is set,
***************
*** 2265,2282 ****
        }



-     /* Check that there is enough disc space, if configured to do so. There
-     doesn't seem to be an ideal place to put this check, but putting it here
-     does permit VRFY and EXPN etc. to be used when space is short. We don't
-     need to do the check if it has already happened as a result of the SIZE
-     parameter on a message. */
- 
-     if (!size_checked && !accept_check_fs(0))
-       {
-       smtp_printf("452 space shortage, please try later\r\n");
-       break;
-       }
- 
      /* Now extract the address, first applying any SMTP-time rewriting. The
      TRUE flag allows "<>" as a sender address. */


--- 2244,2249 ----
***************
*** 2299,2304 ****
--- 2266,2321 ----

      sender_address = raw_sender;


+     /* If there is a configured size limit for mail, check that
+     this message doesn't exceed it. */
+ 
+     if (message_size_limit > 0 && message_size > message_size_limit)
+       {
+       smtp_printf("552 Message size exceeds maximum permitted\r\n");
+       log_write(2, LOG_MAIN|LOG_REJECT, "rejected%s%s%s%s%s <%s>: "
+           "message too large: size=%d max=%d",
+           (sender_fullhost == NULL)? "" : " from ",
+           (sender_fullhost == NULL)? "" : sender_fullhost,
+           (sender_ident == NULL)? "" : " (",
+           (sender_ident == NULL)? "" : sender_ident,
+           (sender_ident == NULL)? "" : ")",
+           sender_address,
+           message_size,
+           message_size_limit);
+       goto COMMAND_LOOP;
+       }
+ 
+     /* Check there is enough space on the disc unless configured not to.
+     The check is for message_size_limit plus the argument - i.e. we accept
+     the message only if it won't reduce the space below the threshold. Add
+     5000 to the size to allow for overheads such as the Received line and
+     storing of recipients, etc. */
+ 
+     if (smtp_check_spool_space)
+       {
+       if (!accept_check_fs(message_size + 5000))
+         {
+         smtp_printf("452 space shortage, please try later\r\n");
+         goto COMMAND_LOOP;
+         }
+       size_checked = TRUE;    /* No need to check again below */
+       }
+ 
+     message_size = 0;
+ 
+     /* Check that there is enough disc space, if configured to do so. There
+     doesn't seem to be an ideal place to put this check, but putting it here
+     does permit VRFY and EXPN etc. to be used when space is short. We don't
+     need to do the check if it has already happened as a result of the SIZE
+     parameter on a message. */
+ 
+     if (!size_checked && !accept_check_fs(0))
+       {
+       smtp_printf("452 space shortage, please try later\r\n");
+       break;
+       }
+ 
+ 
      /* If sender_address is unqualified, reject it, unless this is a
      locally generated message, in which case it will be ignored anyway.
      However, if the sending host or net is listed as permitted to send