[exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog NewSt…

Pàgina inicial
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
A: exim-cvs
Assumptes nous: [exim-dev] Re: [exim-cvs] cvs commit: exim/exim-src/src/receive.c
Assumpte: [exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog NewStuff OptionLists.txt exim/exim-src/src functions.h globals.c globals.h mime.c readconf.c receive.c exim/exim-test-orig/AutoTest/confs 598
ph10 2005/04/04 11:33:49 BST

  Modified files:
    exim-doc/doc-txt     ChangeLog NewStuff OptionLists.txt 
    exim-src/src         functions.h globals.c globals.h mime.c 
                         readconf.c receive.c 
    exim-test-orig/AutoTest/confs 598 
    exim-test-orig/AutoTest/log 598 
    exim-test-orig/AutoTest/mail 598.ph10 
    exim-test-orig/AutoTest/scripts 598 
  Log:
  Added acl_not_smtp_mime. This involved a bit of refactoring of the
  content scanning code. Also, updated doc/OptionList.txt with all the
  content-scanning options (none had been added.)


  Revision  Changes    Path
  1.107     +2 -0      exim/exim-doc/doc-txt/ChangeLog
  1.32      +4 -0      exim/exim-doc/doc-txt/NewStuff
  1.7       +4 -0      exim/exim-doc/doc-txt/OptionLists.txt
  1.13      +2 -2      exim/exim-src/src/functions.h
  1.21      +3 -0      exim/exim-src/src/globals.c
  1.14      +3 -0      exim/exim-src/src/globals.h
  1.7       +5 -5      exim/exim-src/src/mime.c
  1.6       +3 -0      exim/exim-src/src/readconf.c
  1.13      +188 -145  exim/exim-src/src/receive.c
  1.3       +1 -0      exim/exim-test-orig/AutoTest/confs/598
  1.6       +9 -6      exim/exim-test-orig/AutoTest/log/598
  1.6       +138 -6    exim/exim-test-orig/AutoTest/mail/598.ph10
  1.3       +55 -0     exim/exim-test-orig/AutoTest/scripts/598


  Index: ChangeLog
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- ChangeLog    29 Mar 2005 15:53:12 -0000    1.106
  +++ ChangeLog    4 Apr 2005 10:33:49 -0000    1.107
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.106 2005/03/29 15:53:12 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.107 2005/04/04 10:33:49 ph10 Exp $


   Change log file for Exim from version 4.21
   -------------------------------------------
  @@ -116,6 +116,8 @@
         (an event I could not check), uninitialized data bytes were printed.
         There were reports of junk text (parts of files, etc) appearing after
         "input=".
  +
  +PH/21 Added acl_not_smtp_mime to allow for MIME scanning for non-SMTP messages.



A note about Exim versions 4.44 and 4.50

  Index: NewStuff
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- NewStuff    29 Mar 2005 14:19:21 -0000    1.31
  +++ NewStuff    4 Apr 2005 10:33:49 -0000    1.32
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.31 2005/03/29 14:19:21 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.32 2005/04/04 10:33:49 ph10 Exp $


   New Features in Exim
   --------------------
  @@ -95,6 +95,10 @@
         Local/Makefile. It is RADIUSCLIENTNEW, and it requests that the new API,
         in use from radiusclient 0.4.0 onwards, be used. It does not appear to be
         possible to detect the different versions automatically.
  +
  +PH/04 There is a new option called acl_not_smtp_mime that allows you to scan
  +      MIME parts in non-SMTP messages. It operates in exactly the same way as
  +      acl_smtp_mime



Version 4.50

  Index: OptionLists.txt
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/OptionLists.txt,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OptionLists.txt    3 Mar 2005 08:54:59 -0000    1.6
  +++ OptionLists.txt    4 Apr 2005 10:33:49 -0000    1.7
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.6 2005/03/03 08:54:59 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.7 2005/04/04 10:33:49 ph10 Exp $


   LISTS OF EXIM OPTIONS
   ---------------------
  @@ -52,6 +52,7 @@
   -----------------------------------------------------------------------------------------
   accept_8bitmime                      boolean         false         main              1.60
   acl_not_smtp                         string*         unset         main              4.11
  +acl_not_smtp_mime                    string*         unset         main              4.51 with content scan
   acl_smtp_auth                        string*         unset         main              4.00
   acl_smtp_connect                     string*         unset         main              4.11
   acl_smtp_data                        string*         unset         main              4.00
  @@ -60,6 +61,7 @@
   acl_smtp_helo                        string*         unset         main              4.20
   acl_smtp_mail                        string*         unset         main              4.11
   acl_smtp_mailauth                    string*         unset         main              4.21
  +acl_smtp_mime                        string*         unset         main              4.50 with content scan
   acl_smtp_predata                     string*         unset         main              4.43
   acl_smtp_quit                        string*         unset         main              4.43
   acl_smtp_rcpt                        string*         unset         main              4.00
  @@ -83,6 +85,7 @@
   authenticated_sender                 string*         unset         smtp              4.14
   authenticate_hosts                   host list       unset         smtp              3.13
   auto_thaw                            time            0s            main
  +av_scanner                           string*         +             main              4.50 with content scan
   batch_id                             string          unset         appendfile        4.00
                                                        unset         lmtp              4.00
                                                        unset         pipe              4.00
  @@ -466,6 +469,7 @@
   smtp_reserve_hosts                   host list       unset         main
   smtp_return_error_details            boolean         false         main              4.11
   socket                               string*         unset         lmtp              4.11
  +spamd_address                        string          +             main              4.50 with content scan
   split_spool_directory                boolean         false         main              1.70
   spool_directory                      string          ++            main
   srv_fail_domains                     domain list     unset         dnslookup         4.43


  Index: functions.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/functions.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- functions.h    8 Mar 2005 15:32:02 -0000    1.12
  +++ functions.h    4 Apr 2005 10:33:49 -0000    1.13
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/functions.h,v 1.12 2005/03/08 15:32:02 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/functions.h,v 1.13 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -152,8 +152,8 @@
   extern void    millisleep(int);
   #ifdef WITH_CONTENT_SCAN
   struct mime_boundary_context;
  -extern int     mime_acl_check(FILE *f, struct mime_boundary_context *,
  -                              uschar **, uschar **);
  +extern int     mime_acl_check(uschar *acl, FILE *f,
  +                 struct mime_boundary_context *, uschar **, uschar **);
   extern int     mime_decode(uschar **);
   extern int     mime_regex(uschar **);
   #endif


  Index: globals.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/globals.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- globals.c    22 Mar 2005 14:11:54 -0000    1.20
  +++ globals.c    4 Apr 2005 10:33:49 -0000    1.21
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/globals.c,v 1.20 2005/03/22 14:11:54 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/globals.c,v 1.21 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -160,6 +160,9 @@


   tree_node *acl_anchor          = NULL;
   uschar *acl_not_smtp           = NULL;
  +#ifdef WITH_CONTENT_SCAN
  +uschar *acl_not_smtp_mime      = NULL;
  +#endif
   uschar *acl_smtp_auth          = NULL;
   uschar *acl_smtp_connect       = NULL;
   uschar *acl_smtp_data          = NULL;


  Index: globals.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/globals.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- globals.h    22 Mar 2005 14:11:54 -0000    1.13
  +++ globals.h    4 Apr 2005 10:33:49 -0000    1.14
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/globals.h,v 1.13 2005/03/22 14:11:54 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/globals.h,v 1.14 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -102,6 +102,9 @@
   extern BOOL    accept_8bitmime;        /* Allow *BITMIME incoming */
   extern tree_node *acl_anchor;          /* Tree of named ACLs */
   extern uschar *acl_not_smtp;           /* ACL run for non-SMTP messages */
  +#ifdef WITH_CONTENT_SCAN
  +extern uschar *acl_not_smtp_mime;      /* For MIME parts of ditto */
  +#endif
   extern uschar *acl_smtp_auth;          /* ACL run for AUTH */
   extern uschar *acl_smtp_connect;       /* ACL run on SMTP connection */
   extern uschar *acl_smtp_data;          /* ACL run after DATA received */


  Index: mime.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/mime.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mime.c    8 Mar 2005 16:57:28 -0000    1.6
  +++ mime.c    4 Apr 2005 10:33:49 -0000    1.7
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/mime.c,v 1.6 2005/03/08 16:57:28 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/mime.c,v 1.7 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -502,8 +502,8 @@
   }



  -int mime_acl_check(FILE *f, struct mime_boundary_context *context, uschar
  -                   **user_msgptr, uschar **log_msgptr) {
  +int mime_acl_check(uschar *acl, FILE *f, struct mime_boundary_context *context,
  +                   uschar **user_msgptr, uschar **log_msgptr) {
     int rc = OK;
     uschar *header = NULL;
     struct mime_boundary_context nested_context;
  @@ -512,7 +512,7 @@
     header = (uschar *)malloc(MIME_MAX_HEADER_SIZE+1);
     if (header == NULL) {
       log_write(0, LOG_PANIC,
  -                 "acl_smtp_mime: can't allocate %d bytes of memory.", MIME_MAX_HEADER_SIZE+1);
  +                 "MIME ACL: can't allocate %d bytes of memory.", MIME_MAX_HEADER_SIZE+1);
       return DEFER;
     };


  @@ -659,7 +659,7 @@
       mime_is_coverletter = !(context && context->context == MBC_ATTACHMENT);


       /* call ACL handling function */
  -    rc = acl_check(ACL_WHERE_MIME, NULL, acl_smtp_mime, user_msgptr, log_msgptr);
  +    rc = acl_check(ACL_WHERE_MIME, NULL, acl, user_msgptr, log_msgptr);


       mime_stream = NULL;
       mime_current_boundary = NULL;
  @@ -680,7 +680,7 @@
         else
           nested_context.context = MBC_COVERLETTER_ONESHOT;


  -      rc = mime_acl_check(f, &nested_context, user_msgptr, log_msgptr);
  +      rc = mime_acl_check(acl, f, &nested_context, user_msgptr, log_msgptr);
         if (rc != OK) break;
       }
       else if ( (mime_content_type != NULL) &&


  Index: readconf.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/readconf.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- readconf.c    17 Feb 2005 11:58:26 -0000    1.5
  +++ readconf.c    4 Apr 2005 10:33:49 -0000    1.6
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/readconf.c,v 1.5 2005/02/17 11:58:26 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/readconf.c,v 1.6 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -135,6 +135,9 @@
     { "*set_system_filter_user",  opt_bool|opt_hidden, &system_filter_uid_set },
     { "accept_8bitmime",          opt_bool,        &accept_8bitmime },
     { "acl_not_smtp",             opt_stringptr,   &acl_not_smtp },
  +#ifdef WITH_CONTENT_SCAN
  +  { "acl_not_smtp_mime",        opt_stringptr,   &acl_not_smtp_mime },
  +#endif
     { "acl_smtp_auth",            opt_stringptr,   &acl_smtp_auth },
     { "acl_smtp_connect",         opt_stringptr,   &acl_smtp_connect },
     { "acl_smtp_data",            opt_stringptr,   &acl_smtp_data },


  Index: receive.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/receive.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- receive.c    8 Mar 2005 15:32:02 -0000    1.12
  +++ receive.c    4 Apr 2005 10:33:49 -0000    1.13
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/receive.c,v 1.12 2005/03/08 15:32:02 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/receive.c,v 1.13 2005/04/04 10:33:49 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -510,7 +510,7 @@
       {
       if ((--recipients_count - count) > 0)
         memmove(recipients_list + count, recipients_list + count + 1,
  -           (recipients_count - count)*sizeof(recipient_item));
  +        (recipients_count - count)*sizeof(recipient_item));
       return TRUE;
       }
     }
  @@ -1009,6 +1009,146 @@



   /*************************************************
  +*       Run the MIME ACL on a message            *
  +*************************************************/
  +
  +/* This code is in a subroutine so that it can be used for both SMTP
  +and non-SMTP messages. It is called with a non-NULL ACL pointer.
  +
  +Arguments:
  +  acl                The ACL to run (acl_smtp_mime or acl_not_smtp_mime)
  +  smtp_yield_ptr     Set FALSE to kill messages after dropped connection
  +  smtp_reply_ptr     Where SMTP reply is being built
  +  blackholed_by_ptr  Where "blackholed by" message is being built
  +
  +Returns:             TRUE to carry on; FALSE to abandon the message
  +*/
  +
  +static BOOL
  +run_mime_acl(uschar *acl, BOOL *smtp_yield_ptr, uschar **smtp_reply_ptr,
  +  uschar **blackholed_by_ptr)
  +{
  +FILE *mbox_file;
  +uschar rfc822_file_path[2048];
  +unsigned long mbox_size;
  +header_line *my_headerlist;
  +uschar *user_msg, *log_msg;
  +int mime_part_count_buffer = -1;
  +int rc;
  +
  +memset(CS rfc822_file_path,0,2048);
  +
  +/* check if it is a MIME message */
  +my_headerlist = header_list;
  +while (my_headerlist != NULL) {
  +  /* skip deleted headers */
  +  if (my_headerlist->type == '*') {
  +    my_headerlist = my_headerlist->next;
  +    continue;
  +  };
  +  if (strncmpic(my_headerlist->text, US"Content-Type:", 13) == 0) {
  +    DEBUG(D_receive) debug_printf("Found Content-Type: header - executing acl_smtp_mime.\n");
  +    goto DO_MIME_ACL;
  +  };
  +  my_headerlist = my_headerlist->next;
  +};
  +
  +DEBUG(D_receive) debug_printf("No Content-Type: header - presumably not a MIME message.\n");
  +return TRUE;
  +
  +DO_MIME_ACL:
  +/* make sure the eml mbox file is spooled up */
  +mbox_file = spool_mbox(&mbox_size);
  +if (mbox_file == NULL) {
  +  /* error while spooling */
  +  log_write(0, LOG_MAIN|LOG_PANIC,
  +         "acl_smtp_mime: error while creating mbox spool file, message temporarily rejected.");
  +  Uunlink(spool_name);
  +  unspool_mbox();
  +  smtp_respond(451, TRUE, US"temporary local problem");
  +  message_id[0] = 0;            /* Indicate no message accepted */
  +  *smtp_reply_ptr = US"";       /* Indicate reply already sent */
  +  return FALSE;                 /* Indicate skip to end of receive function */
  +};
  +
  +mime_is_rfc822 = 0;
  +
  +MIME_ACL_CHECK:
  +mime_part_count = -1;
  +rc = mime_acl_check(acl, mbox_file, NULL, &user_msg, &log_msg);
  +fclose(mbox_file);
  +
  +if (Ustrlen(rfc822_file_path) > 0) {
  +  mime_part_count = mime_part_count_buffer;
  +
  +  if (unlink(CS rfc822_file_path) == -1) {
  +    log_write(0, LOG_PANIC,
  +         "acl_smtp_mime: can't unlink RFC822 spool file, skipping.");
  +      goto END_MIME_ACL;
  +  };
  +};
  +
  +/* check if we must check any message/rfc822 attachments */
  +if (rc == OK) {
  +  uschar temp_path[1024];
  +  int n;
  +  struct dirent *entry;
  +  DIR *tempdir;
  +
  +  snprintf(CS temp_path, 1024, "%s/scan/%s", spool_directory, message_id);
  +
  + tempdir = opendir(CS temp_path);
  + n = 0;
  + do {
  +   entry = readdir(tempdir);
  +   if (entry == NULL) break;
  +    if (strncmpic(US entry->d_name,US"__rfc822_",9) == 0) {
  +      snprintf(CS rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name);
  +     debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n", rfc822_file_path);
  +     break;
  +    };
  + } while (1);
  + closedir(tempdir);
  +
  +  if (entry != NULL) {
  +    mbox_file = Ufopen(rfc822_file_path,"r");
  +    if (mbox_file == NULL) {
  +      log_write(0, LOG_PANIC,
  +         "acl_smtp_mime: can't open RFC822 spool file, skipping.");
  +      unlink(CS rfc822_file_path);
  +      goto END_MIME_ACL;
  +    };
  +    /* set RFC822 expansion variable */
  +    mime_is_rfc822 = 1;
  +    mime_part_count_buffer = mime_part_count;
  +    goto MIME_ACL_CHECK;
  +  };
  +};
  +
  +END_MIME_ACL:
  +add_acl_headers(US"MIME");
  +if (rc == DISCARD)
  +  {
  +  recipients_count = 0;
  +  *blackholed_by_ptr = US"MIME ACL";
  +  }
  +else if (rc != OK)
  +  {
  +  Uunlink(spool_name);
  +  unspool_mbox();
  +  if (smtp_handle_acl_fail(ACL_WHERE_MIME, rc, user_msg, log_msg) != 0)
  +    *smtp_yield_ptr = FALSE;    /* No more messsages after dropped connection */
  +  *smtp_reply_ptr = US"";       /* Indicate reply already sent */
  +  message_id[0] = 0;            /* Indicate no message accepted */
  +  return FALSE;                 /* Cause skip to end of receive function */
  +  };
  +
  +return TRUE;
  +}
  +
  +
  +
  +/*************************************************
   *                 Receive message                *
   *************************************************/


@@ -2754,127 +2894,13 @@
#endif

   #ifdef WITH_CONTENT_SCAN
  -     /* MIME ACL hook */
  -    if (acl_smtp_mime != NULL && recipients_count > 0)
  -      {
  -      FILE *mbox_file;
  -      uschar rfc822_file_path[2048];
  -      unsigned long mbox_size;
  -      header_line *my_headerlist;
  -      uschar *user_msg, *log_msg;
  -      int mime_part_count_buffer = -1;
  -
  -      memset(CS rfc822_file_path,0,2048);
  -
  -      /* check if it is a MIME message */
  -      my_headerlist = header_list;
  -      while (my_headerlist != NULL) {
  -        /* skip deleted headers */
  -        if (my_headerlist->type == '*') {
  -          my_headerlist = my_headerlist->next;
  -          continue;
  -        };
  -        if (strncmpic(my_headerlist->text, US"Content-Type:", 13) == 0) {
  -          DEBUG(D_receive) debug_printf("Found Content-Type: header - executing acl_smtp_mime.\n");
  -          goto DO_MIME_ACL;
  -        };
  -        my_headerlist = my_headerlist->next;
  -      };
  -
  -      DEBUG(D_receive) debug_printf("No Content-Type: header - presumably not a MIME message.\n");
  -      goto NO_MIME_ACL;
  -
  -      DO_MIME_ACL:
  -      /* make sure the eml mbox file is spooled up */
  -      mbox_file = spool_mbox(&mbox_size);
  -      if (mbox_file == NULL) {
  -        /* error while spooling */
  -        log_write(0, LOG_MAIN|LOG_PANIC,
  -               "acl_smtp_mime: error while creating mbox spool file, message temporarily rejected.");
  -        Uunlink(spool_name);
  -        unspool_mbox();
  -        smtp_respond(451, TRUE, US"temporary local problem");
  -        message_id[0] = 0;            /* Indicate no message accepted */
  -        smtp_reply = US"";            /* Indicate reply already sent */
  -        goto TIDYUP;                  /* Skip to end of function */
  -      };
  -
  -      mime_is_rfc822 = 0;
  -
  -      MIME_ACL_CHECK:
  -      mime_part_count = -1;
  -      rc = mime_acl_check(mbox_file, NULL, &user_msg, &log_msg);
  -      fclose(mbox_file);
  -
  -      if (Ustrlen(rfc822_file_path) > 0) {
  -        mime_part_count = mime_part_count_buffer;
  -
  -        if (unlink(CS rfc822_file_path) == -1) {
  -          log_write(0, LOG_PANIC,
  -               "acl_smtp_mime: can't unlink RFC822 spool file, skipping.");
  -            goto END_MIME_ACL;
  -        };
  -      };
  -
  -      /* check if we must check any message/rfc822 attachments */
  -      if (rc == OK) {
  -        uschar temp_path[1024];
  -        int n;
  -        struct dirent *entry;
  -        DIR *tempdir;
  -
  -        snprintf(CS temp_path, 1024, "%s/scan/%s", spool_directory, message_id);
  -
  -       tempdir = opendir(CS temp_path);
  -       n = 0;
  -       do {
  -         entry = readdir(tempdir);
  -         if (entry == NULL) break;
  -          if (strncmpic(US entry->d_name,US"__rfc822_",9) == 0) {
  -            snprintf(CS rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name);
  -           debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n", rfc822_file_path);
  -           break;
  -          };
  -       } while (1);
  -       closedir(tempdir);
  -
  -        if (entry != NULL) {
  -          mbox_file = Ufopen(rfc822_file_path,"r");
  -          if (mbox_file == NULL) {
  -            log_write(0, LOG_PANIC,
  -               "acl_smtp_mime: can't open RFC822 spool file, skipping.");
  -            unlink(CS rfc822_file_path);
  -            goto END_MIME_ACL;
  -          };
  -          /* set RFC822 expansion variable */
  -          mime_is_rfc822 = 1;
  -          mime_part_count_buffer = mime_part_count;
  -          goto MIME_ACL_CHECK;
  -        };
  -      };
  -
  -      END_MIME_ACL:
  -      add_acl_headers(US"MIME");
  -      if (rc == DISCARD)
  -        {
  -        recipients_count = 0;
  -        blackholed_by = US"MIME ACL";
  -        }
  -      else if (rc != OK)
  -        {
  -        Uunlink(spool_name);
  -        unspool_mbox();
  -        if (smtp_handle_acl_fail(ACL_WHERE_MIME, rc, user_msg, log_msg) != 0)
  -          smtp_yield = FALSE;    /* No more messsages after dropped connection */
  -        smtp_reply = US"";       /* Indicate reply already sent */
  -        message_id[0] = 0;       /* Indicate no message accepted */
  -        goto TIDYUP;             /* Skip to end of function */
  -        };
  -      }
  -
  -    NO_MIME_ACL:
  +    if (acl_smtp_mime != NULL &&
  +        !run_mime_acl(acl_smtp_mime, &smtp_yield, &smtp_reply, &blackholed_by))
  +      goto TIDYUP;
   #endif /* WITH_CONTENT_SCAN */


  +    /* Check the recipients count again, as the MIME ACL might have changed
  +    them. */


       if (acl_smtp_data != NULL && recipients_count > 0)
         {
  @@ -2906,38 +2932,55 @@
     /* Handle non-SMTP and batch SMTP (i.e. non-interactive) messages. Note that
     we cannot take different actions for permanent and temporary rejections. */


  -  else if (acl_not_smtp != NULL)
  +  else
       {
  -    uschar *user_msg, *log_msg;
  -    rc = acl_check(ACL_WHERE_NOTSMTP, NULL, acl_not_smtp, &user_msg, &log_msg);
  -    if (rc == DISCARD)
  -      {
  -      recipients_count = 0;
  -      blackholed_by = US"non-SMTP ACL";
  -      if (log_msg != NULL) blackhole_log_msg = string_sprintf(": %s", log_msg);
  -      }
  -    else if (rc != OK)
  -      {
  -      Uunlink(spool_name);
  -      log_write(0, LOG_MAIN|LOG_REJECT, "F=<%s> rejected by non-SMTP ACL: %s",
  -        sender_address, log_msg);
  -      if (user_msg == NULL) user_msg = US"local configuration problem";
  -      if (smtp_batched_input)
  +
  +#ifdef WITH_CONTENT_SCAN
  +    if (acl_not_smtp_mime != NULL &&
  +        !run_mime_acl(acl_not_smtp_mime, &smtp_yield, &smtp_reply,
  +          &blackholed_by))
  +      goto TIDYUP;
  +#endif /* WITH_CONTENT_SCAN */
  +
  +    if (acl_not_smtp != NULL)
  +      {
  +      uschar *user_msg, *log_msg;
  +      rc = acl_check(ACL_WHERE_NOTSMTP, NULL, acl_not_smtp, &user_msg, &log_msg);
  +      if (rc == DISCARD)
           {
  -        moan_smtp_batch(NULL, "%d %s", 550, user_msg);
  -        /* Does not return */
  +        recipients_count = 0;
  +        blackholed_by = US"non-SMTP ACL";
  +        if (log_msg != NULL)
  +          blackhole_log_msg = string_sprintf(": %s", log_msg);
           }
  -      else
  +      else if (rc != OK)
           {
  -        fseek(data_file, (long int)SPOOL_DATA_START_OFFSET, SEEK_SET);
  -        give_local_error(ERRMESS_LOCAL_ACL, user_msg,
  -          US"message rejected by non-SMTP ACL: ", error_rc, data_file,
  -            header_list);
  -        /* Does not return */
  +        Uunlink(spool_name);
  +#ifdef WITH_CONTENT_SCAN
  +        unspool_mbox();
  +#endif
  +        log_write(0, LOG_MAIN|LOG_REJECT, "F=<%s> rejected by non-SMTP ACL: %s",
  +          sender_address, log_msg);
  +        if (user_msg == NULL) user_msg = US"local configuration problem";
  +        if (smtp_batched_input)
  +          {
  +          moan_smtp_batch(NULL, "%d %s", 550, user_msg);
  +          /* Does not return */
  +          }
  +        else
  +          {
  +          fseek(data_file, (long int)SPOOL_DATA_START_OFFSET, SEEK_SET);
  +          give_local_error(ERRMESS_LOCAL_ACL, user_msg,
  +            US"message rejected by non-SMTP ACL: ", error_rc, data_file,
  +              header_list);
  +          /* Does not return */
  +          }
           }
  +      add_acl_headers(US"non-SMTP");
         }
  -    add_acl_headers(US"non-SMTP");
       }
  +
  +  /* The applicable ACLs have been run */


     if (deliver_freeze) frozen_by = US"ACL";     /* for later logging */
     if (queue_only_policy) queued_by = US"ACL";


  Index: 598
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/confs/598,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- 598    29 Dec 2004 16:34:31 -0000    1.2
  +++ 598    4 Apr 2005 10:33:49 -0000    1.3
  @@ -15,6 +15,7 @@
   acl_smtp_data = check_data
   acl_not_smtp  = check_data
   acl_smtp_mime = check_mime
  +acl_not_smtp_mime = check_mime



# ----- ACL -----

  Index: 598
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/log/598,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- 598    4 Jan 2005 11:28:17 -0000    1.5
  +++ 598    4 Apr 2005 10:33:49 -0000    1.6
  @@ -1,18 +1,21 @@
  -1999-03-02 09:44:33 10HmaX-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1080
  +1999-03-02 09:44:33 10HmaX-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1066
   1999-03-02 09:44:33 10HmaX-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
  -1999-03-02 09:44:33 10HmaY-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1198 id=41C2F849.3060203@???
  +1999-03-02 09:44:33 10HmaY-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1184 id=41C2F849.3060203@???
   1999-03-02 09:44:33 10HmaY-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
  -1999-03-02 09:44:33 10HmaZ-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1501 id=abcde
  +1999-03-02 09:44:33 10HmaZ-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1487 id=abcde
   1999-03-02 09:44:33 10HmaZ-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
  -1999-03-02 09:44:33 10HmbA-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1314 id=41C2F849.3060203@???
  +1999-03-02 09:44:33 10HmbA-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=1300 id=41C2F849.3060203@???
   1999-03-02 09:44:33 10HmbA-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
  -1999-03-02 09:44:33 10HmbB-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=4384 id=20041217133501.GA3058@???
  +1999-03-02 09:44:33 10HmbB-0005vi-00 <= ph10@??? U=ph10 P=local-esmtp S=4370 id=20041217133501.GA3058@???
   1999-03-02 09:44:33 10HmbB-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmbB-0005vi-00 Completed
  -1999-03-02 09:44:33 10HmbC-0005vi-00 <= ph10@??? U=ph10 P=local S=1058
  +1999-03-02 09:44:33 10HmbC-0005vi-00 <= ph10@??? U=ph10 P=local S=1044
   1999-03-02 09:44:33 10HmbC-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
   1999-03-02 09:44:33 10HmbC-0005vi-00 Completed
  +1999-03-02 09:44:33 10HmbD-0005vi-00 <= ph10@??? U=ph10 P=local S=4348 id=20041217133501.GA3058@???
  +1999-03-02 09:44:33 10HmbD-0005vi-00 => ph10 <ph10@???> R=r1 T=t1
  +1999-03-02 09:44:33 10HmbD-0005vi-00 Completed


  Index: 598.ph10
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/mail/598.ph10,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- 598.ph10    4 Jan 2005 11:28:17 -0000    1.5
  +++ 598.ph10    4 Apr 2005 10:33:49 -0000    1.6
  @@ -9,7 +9,7 @@
   X-Spam_score: -0.7
   X-Spam_score_int: -6
   X-Spam_bar: /
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -39,7 +39,7 @@
   X-Spam_score: -1.7
   X-Spam_score_int: -16
   X-Spam_bar: -
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -68,7 +68,7 @@
   X-Spam_score: 1.9
   X-Spam_score_int: 19
   X-Spam_bar: +
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -104,7 +104,7 @@
   X-Spam_score: -1.7
   X-Spam_score_int: -16
   X-Spam_bar: -
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -195,7 +195,7 @@
   X-Spam_score: -1.7
   X-Spam_score_int: -16
   X-Spam_bar: -
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -265,7 +265,7 @@
   X-Spam_score: -0.7
   X-Spam_score_int: -6
   X-Spam_bar: /
  -X-Spam_report: Spam detection software, running on the system "xoanon.csi.cam.ac.uk", has
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
       identified this incoming email as possible spam.  The original message
       has been attached to this so you can view it (if it isn't spam) or label
       similar future email.  If you have any questions, see
  @@ -280,4 +280,136 @@
   X-Router-SSint: -6


   A message without any headers.
  +
  +From ph10@??? Tue Mar 02 09:44:33 1999
  +Received: from ph10 by myhost.test.ex with local (Exim x.yz)
  +    id 10HmbD-0005vi-00
  +    for ph10@???; Tue, 2 Mar 1999 09:44:33 +0000
  +Date: Tue, 2 Mar 1999 09:44:33 +0000
  +From: J Caesar <eximusers@???>
  +To: exim-users@???
  +Message-ID: <20041217133501.GA3058@???>
  +Mime-Version: 1.0
  +Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR"
  +Content-Disposition: inline
  +Subject: [exim] Re: Bug#286074: eximstats: uses message count as data for
  +    the "volume" charts
  +X-BeenThere: exim-users@???
  +X-Mailman-Version: 2.1.5
  +Precedence: list
  +Sender: Philip Hazel <ph10@???>
  +X-0-content-type: multipart/mixed
  +X-0-filename: 
  +X-0-charset: 
  +X-0-boundary: T4sUOijqQbZv57TR
  +X-0-content-disposition: inline
  +X-0-content-transfer-encoding: 
  +X-0-content-id: 
  +X-0-content-description: 
  +X-0-is-multipart: 1
  +X-0-is-coverletter: 1
  +X-0-is-rfc822: 0
  +X-0-decode-filename: /source/exim4/AutoTest/spool/scan/10HmbD-0005vi-00/10HmbD-0005vi-00-00000
  +X-0-content-size: 2
  +X-1-content-type: text/plain
  +X-1-filename: 
  +X-1-charset: us-ascii
  +X-1-boundary: 
  +X-1-content-disposition: inline
  +X-1-content-transfer-encoding: 
  +X-1-content-id: 
  +X-1-content-description: 
  +X-1-is-multipart: 0
  +X-1-is-coverletter: 1
  +X-1-is-rfc822: 0
  +X-1-decode-filename: /source/exim4/AutoTest/spool/scan/10HmbD-0005vi-00/10HmbD-0005vi-00-00001
  +X-1-content-size: 1
  +X-2-content-type: text/plain
  +X-2-filename: working-patch
  +X-2-charset: us-ascii
  +X-2-boundary: 
  +X-2-content-disposition: attachment
  +X-2-content-transfer-encoding: 
  +X-2-content-id: 
  +X-2-content-description: 
  +X-2-is-multipart: 0
  +X-2-is-coverletter: 0
  +X-2-is-rfc822: 0
  +X-2-decode-filename: /source/exim4/AutoTest/spool/scan/10HmbD-0005vi-00/10HmbD-0005vi-00-00002
  +X-2-content-size: 1
  +X-3-content-type: text/plain
  +X-3-filename: 
  +X-3-charset: us-ascii
  +X-3-boundary: 
  +X-3-content-disposition: inline
  +X-3-content-transfer-encoding: 7bit
  +X-3-content-id: 
  +X-3-content-description: 
  +X-3-is-multipart: 0
  +X-3-is-coverletter: 0
  +X-3-is-rfc822: 0
  +X-3-decode-filename: /source/exim4/AutoTest/spool/scan/10HmbD-0005vi-00/10HmbD-0005vi-00-00003
  +X-3-content-size: 1
  +X-Spam_score: -1.7
  +X-Spam_score_int: -16
  +X-Spam_bar: -
  +X-Spam_report: Spam detection software, running on the system "xoanon", has
  +    identified this incoming email as possible spam.  The original message
  +    has been attached to this so you can view it (if it isn't spam) or label
  +    similar future email.  If you have any questions, see
  +    the administrator of that system for details.
  +    Content preview:  There was a part of the patch missing, complete one is
  +    attached. sorry for wasting your time --- /usr/sbin/eximstats
  +    2004-12-17 13:36:44.381983753 +0100 +++ eximstats 2004-12-17
  +    13:47:37.763185260 +0100 @@ -1107,11 +1107,11 @@ if (scalar
  +    @chartdatanames < $ntopchart) { push(@chartdatanames, $key); -
  +    push(@chartdatavals, $$m_count{$key}); + push(@chartdatavals,
  +    $$m_data{$key}); } else { - $chartotherval += $$m_count{$key}; +
  +    $chartotherval += $$m_data{$key}; } } push(@chartdatanames, "Other");
  +    [...] 
  +    Content analysis details:   (-1.7 points, 5.0 required)
  +    pts rule name              description
  +    ---- ---------------------- --------------------------------------------------
  +    1.1 DATE_IN_PAST_96_XX     Date: is 96 hours or more before Received: date
  +    -2.8 ALL_TRUSTED            Did not pass through any untrusted hosts
  +X-Router-SSint: -16
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=us-ascii
  +Content-Disposition: inline
  +
  +There was a part of the patch missing, complete one is attached.
  +     sorry for wasting your time
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=us-ascii
  +Content-Disposition: attachment; filename=working-patch
  +
  +--- /usr/sbin/eximstats 2004-12-17 13:36:44.381983753 +0100
  ++++ eximstats    2004-12-17 13:47:37.763185260 +0100
  +@@ -1107,11 +1107,11 @@
  +   if (scalar @chartdatanames < $ntopchart)
  +     {
  +     push(@chartdatanames, $key);
  +-    push(@chartdatavals, $$m_count{$key});
  ++    push(@chartdatavals, $$m_data{$key});
  +     }
  +   else
  +     {
  +-    $chartotherval += $$m_count{$key};
  ++    $chartotherval += $$m_data{$key};
  +     }
  +   }
  + push(@chartdatanames, "Other");
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset="us-ascii"
  +MIME-Version: 1.0
  +Content-Transfer-Encoding: 7bit
  +Content-Disposition: inline
  +
  +-- 
  +## List details at http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##
  +
  +--T4sUOijqQbZv57TR--



  Index: 598
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/scripts/598,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- 598    29 Dec 2004 16:34:31 -0000    1.2
  +++ 598    4 Apr 2005 10:33:49 -0000    1.3
  @@ -123,3 +123,58 @@
   A message without any headers.
   .
   ****
  +# Non-smtp MIME message
  +0
  +exim -odi ph10@???
  +Date: Fri, 17 Dec 2004 14:35:01 +0100
  +From: J Caesar <eximusers@???>
  +To: exim-users@???
  +Message-ID: <20041217133501.GA3058@???>
  +Mime-Version: 1.0
  +Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR"
  +Content-Disposition: inline
  +Subject: [exim] Re: Bug#286074: eximstats: uses message count as data for
  +    the "volume" charts
  +X-BeenThere: exim-users@???
  +X-Mailman-Version: 2.1.5
  +Precedence: list
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=us-ascii
  +Content-Disposition: inline
  +
  +There was a part of the patch missing, complete one is attached.
  +     sorry for wasting your time
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset=us-ascii
  +Content-Disposition: attachment; filename=working-patch
  +
  +--- /usr/sbin/eximstats 2004-12-17 13:36:44.381983753 +0100
  ++++ eximstats    2004-12-17 13:47:37.763185260 +0100
  +@@ -1107,11 +1107,11 @@
  +   if (scalar @chartdatanames < $ntopchart)
  +     {
  +     push(@chartdatanames, $key);
  +-    push(@chartdatavals, $$m_count{$key});
  ++    push(@chartdatavals, $$m_data{$key});
  +     }
  +   else
  +     {
  +-    $chartotherval += $$m_count{$key};
  ++    $chartotherval += $$m_data{$key};
  +     }
  +   }
  + push(@chartdatanames, "Other");
  +
  +--T4sUOijqQbZv57TR
  +Content-Type: text/plain; charset="us-ascii"
  +MIME-Version: 1.0
  +Content-Transfer-Encoding: 7bit
  +Content-Disposition: inline
  +
  +-- 
  +## List details at http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##
  +
  +--T4sUOijqQbZv57TR--
  +****