[exim-cvs] cvs commit: exim/exim-src/OS Makefile-Base exim/…

Pàgina inicial
Delete this message
Reply to this message
Autor: Tom Kistner
Data:  
A: exim-cvs
Assumpte: [exim-cvs] cvs commit: exim/exim-src/OS Makefile-Base exim/exim-src/src acl.c config.h.defaults exim.h functions.h macros.h malware.c mime.c mime.h regex.c spam.c spam.h spool_mbox.c
tom 2004/11/30 15:18:58 GMT

  Modified files:        (Branch: EXISCAN)
    exim-src/OS          Makefile-Base 
    exim-src/src         acl.c config.h.defaults exim.h 
                         functions.h macros.h malware.c mime.c 
                         mime.h regex.c spam.c spam.h spool_mbox.c 
  Log:
  WITH_CONTENT_SCAN checkin - compiles OK now


  Revision  Changes    Path
  1.1.2.2   +2 -2      exim/exim-src/OS/Makefile-Base
  1.5.2.2   +4 -1      exim/exim-src/src/acl.c
  1.2.2.1   +2 -0      exim/exim-src/src/config.h.defaults
  1.2.2.1   +1 -1      exim/exim-src/src/exim.h
  1.5.2.1   +21 -0     exim/exim-src/src/functions.h
  1.2.2.2   +2 -0      exim/exim-src/src/macros.h
  1.1.2.3   +2 -97     exim/exim-src/src/malware.c
  1.1.2.3   +1 -2      exim/exim-src/src/mime.c
  1.1.2.3   +1 -2      exim/exim-src/src/mime.h
  1.1.2.3   +1 -2      exim/exim-src/src/regex.c
  1.1.2.3   +1 -2      exim/exim-src/src/spam.c
  1.1.2.3   +2 -2      exim/exim-src/src/spam.h
  1.1.2.3   +6 -2      exim/exim-src/src/spool_mbox.c


  Index: Makefile-Base
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/OS/Makefile-Base,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Makefile-Base    26 Nov 2004 14:17:33 -0000    1.1.2.1
  +++ Makefile-Base    30 Nov 2004 15:18:58 -0000    1.1.2.2
  @@ -1,4 +1,4 @@
  -# $Cambridge: exim/exim-src/OS/Makefile-Base,v 1.1.2.1 2004/11/26 14:17:33 tom Exp $
  +# $Cambridge: exim/exim-src/OS/Makefile-Base,v 1.1.2.2 2004/11/30 15:18:58 tom Exp $


# This file is the basis of the main makefile for Exim and friends. The
# makefile at the top level arranges to build the main makefile by calling
@@ -287,7 +287,7 @@
# Targets for final binaries; the main one has a build number which is
# updated each time. We don't bother with that for the auxiliaries.

-OBJ_WITH_CONTENT_SCAN = malware.o mime.o regex.o spam.o spool-mbox.o
+OBJ_WITH_CONTENT_SCAN = malware.o mime.o regex.o spam.o spool_mbox.o

   OBJ_EXIM = acl.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o \
           directory.o dns.o drtables.o enq.o exim.o expand.o filter.o \
  @@ -555,7 +555,7 @@
   mime.o:          $(HDRS) mime.c
   regex.o:         $(HDRS) regex.c
   spam.o:          $(HDRS) spam.c
  -spool-mbox.o:    $(HDRS) spool_mbox.c
  +spool_mbox.o:    $(HDRS) spool_mbox.c



# The module containing tables of available lookups, routers, auths, and

  Index: acl.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/acl.c,v
  retrieving revision 1.5.2.1
  retrieving revision 1.5.2.2
  diff -u -r1.5.2.1 -r1.5.2.2
  --- acl.c    25 Nov 2004 15:33:55 -0000    1.5.2.1
  +++ acl.c    30 Nov 2004 15:18:58 -0000    1.5.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/acl.c,v 1.5.2.1 2004/11/25 15:33:55 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/acl.c,v 1.5.2.2 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -49,7 +49,7 @@
   #endif
          ACLC_RECIPIENTS,
   #ifdef WITH_CONTENT_SCAN
  -       ACLC_REGEX
  +       ACLC_REGEX,
   #endif
          ACLC_SENDER_DOMAINS, ACLC_SENDERS, ACLC_SET,
   #ifdef WITH_CONTENT_SCAN
  @@ -1384,6 +1384,9 @@
   uschar *log_message = NULL;
   uschar *p;
   int rc = OK;
  +#ifdef WITH_CONTENT_SCAN
  +int sep = '/';
  +#endif


   for (; cb != NULL; cb = cb->next)
     {


  Index: config.h.defaults
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/config.h.defaults,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- config.h.defaults    18 Oct 2004 09:16:57 -0000    1.2
  +++ config.h.defaults    30 Nov 2004 15:18:58 -0000    1.2.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/config.h.defaults,v 1.2 2004/10/18 09:16:57 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/config.h.defaults,v 1.2.2.1 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -137,6 +137,8 @@
   #define USE_READLINE
   #define USE_TCP_WRAPPERS
   #define USE_TDB
  +
  +#define WITH_CONTENT_SCAN


/* Things that are not routinely changed but are nevertheless configurable
just in case. */

  Index: exim.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/exim.h,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- exim.h    19 Nov 2004 09:45:54 -0000    1.2
  +++ exim.h    30 Nov 2004 15:18:58 -0000    1.2.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/exim.h,v 1.2 2004/11/19 09:45:54 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/exim.h,v 1.2.2.1 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -381,8 +381,8 @@
   mytypes.h and store.h, so we don't need to mention them explicitly. */


#include "local_scan.h"
-#include "macros.h"
#include "config.h"
+#include "macros.h"
#include "dbstuff.h"
#include "structs.h"
#include "globals.h"

  Index: functions.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/functions.h,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- functions.h    19 Nov 2004 09:45:54 -0000    1.5
  +++ functions.h    30 Nov 2004 15:18:58 -0000    1.5.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/functions.h,v 1.5 2004/11/19 09:45:54 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/functions.h,v 1.5.2.1 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -126,6 +126,9 @@
   extern uschar *local_part_quote(uschar *lpart);
   extern void    log_close_all(void);


  +#ifdef WITH_CONTENT_SCAN
  +extern int     malware(uschar **);
  +#endif
   extern int     match_address_list(uschar *, BOOL, BOOL, uschar **,
                    unsigned int *, int, int, uschar **);
   extern int     match_check_list(uschar **, int, tree_node **, unsigned int **,
  @@ -139,6 +142,13 @@
   extern void    md5_mid(md5 *, const uschar *);
   extern void    md5_start(md5 *);
   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_decode(uschar **);
  +extern int     mime_regex(uschar **);
  +#endif
   extern uschar *moan_check_errorcopy(uschar *);
   extern BOOL    moan_skipped_syntax_errors(uschar *, error_block *, uschar *,
                    BOOL, uschar *);
  @@ -183,6 +193,9 @@
   extern BOOL    receive_msg(BOOL);
   extern int     receive_statvfs(BOOL, int *); 
   extern void    receive_swallow_smtp(void);
  +#ifdef WITH_CONTENT_SCAN
  +extern int     regex(uschar **);
  +#endif
   extern BOOL    regex_match_and_setup(const pcre *, uschar *, int, int);
   extern const pcre *regex_must_compile(uschar *, BOOL, BOOL);
   extern void    retry_add_item(address_item *, uschar *, int);
  @@ -243,6 +256,10 @@
   extern BOOL    smtp_start_session(void);
   extern int     smtp_ungetc(int);
   extern int     smtp_write_command(smtp_outblock *, BOOL, char *, ...);
  +#ifdef WITH_CONTENT_SCAN
  +extern int     spam(uschar **);
  +extern FILE   *spool_mbox(unsigned long long *);
  +#endif
   extern BOOL    spool_move_message(uschar *, uschar *, uschar *, uschar *);
   extern BOOL    spool_open_datafile(uschar *);
   extern int     spool_open_temp(uschar *);
  @@ -293,6 +310,10 @@
   extern int     tree_insertnode(tree_node **, tree_node *);
   extern tree_node *tree_search(tree_node *, uschar *);
   extern void    tree_write(tree_node *, FILE *);
  +
  +#ifdef WITH_CONTENT_SCAN
  +extern void    unspool_mbox(void);
  +#endif


   extern int     verify_address(address_item *, FILE *, int, int, int, int,
                    uschar *, uschar *, BOOL *);


  Index: macros.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/macros.h,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- macros.h    25 Nov 2004 15:33:55 -0000    1.2.2.1
  +++ macros.h    30 Nov 2004 15:18:58 -0000    1.2.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/macros.h,v 1.2.2.1 2004/11/25 15:33:55 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/macros.h,v 1.2.2.2 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -733,6 +733,8 @@
   "control" modifiers, by means of a maximum "where" value. Do not modify this
   order without checking carefully! Furthermore, remember to keep these in step
   with the tables of names and response codes in globals.c. */
  +
  +/* FIXME: the #ifdef below does not work here. Why? */


   enum { ACL_WHERE_RCPT,       /* Some controls are for RCPT only */
          ACL_WHERE_MAIL,       /* )                                           */


  Index: malware.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/malware.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- malware.c    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ malware.c    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,21 +1,19 @@
  -/* $Cambridge: exim/exim-src/src/malware.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/malware.c,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2003-???? */
/* License: GPL */

/* Code for calling virus (malware) scanners. Called from acl.c. */

#include "exim.h"
+#ifdef WITH_CONTENT_SCAN

/* declaration of private routines */
int mksd_scan_packed(int sock);
-int mksd_scan_unpacked(int sock, int maxproc);

/* SHUT_WR seems to be undefined on Unixware? */
#ifndef SHUT_WR
@@ -1150,10 +1148,7 @@

         malware_name = NULL;


  -      /* choose the appropriate scan routine */
  -      retval = demime_ok ?
  -               mksd_scan_unpacked(sock, mksd_maxproc) :
  -               mksd_scan_packed(sock);
  +      retval = mksd_scan_packed(sock);


         if (retval != OK)
           return retval;
  @@ -1322,96 +1317,6 @@
     close (sock);


     return mksd_parse_line (CS av_buffer);
  -}
  -
  -int mksd_scan_unpacked (int sock, int maxproc)
  -{
  -  struct iovec iov[5];
  -  char *cmd = "\nSQ/";
  -  DIR *unpdir;
  -  struct dirent *entry;
  -  int pending = 0;
  -  uschar *line;
  -  int i, offset;
  -  uschar mbox_name[1024];
  -  uschar unpackdir[1024];
  -  uschar av_buffer[16384];
  -  
  -  snprintf (CS mbox_name, sizeof (mbox_name), "%s.eml", CS message_id);
  -  snprintf (CS unpackdir, sizeof (unpackdir), "%s/scan/%s", CS spool_directory, CS message_id);
  -  
  -  if ((unpdir = opendir (CS unpackdir)) == NULL) {
  -    close (sock);
  -    log_write(0, LOG_MAIN|LOG_PANIC,
  -              "malware acl condition: unable to scan spool directory");
  -    return DEFER;
  -  }
  -  
  -  iov[0].iov_base = cmd;
  -  iov[0].iov_len = 3;
  -  iov[1].iov_base = CS unpackdir;
  -  iov[1].iov_len = Ustrlen (unpackdir);
  -  iov[2].iov_base = cmd + 3;
  -  iov[2].iov_len = 1;
  -  iov[4].iov_base = cmd;
  -  iov[4].iov_len = 1;
  -  
  -  /* main loop */
  -  while ((unpdir != NULL) || (pending > 0)) {
  -  
  -    /* write loop */
  -    while ((pending < maxproc) && (unpdir != NULL)) {
  -      if ((entry = readdir (unpdir)) != NULL) {
  -        if ((Ustrcmp (entry->d_name, ".") != 0) &&
  -            (Ustrcmp (entry->d_name, "..") != 0) &&
  -            (Ustrcmp (entry->d_name, mbox_name) != 0)) {
  -          iov[3].iov_base = entry->d_name;
  -          iov[3].iov_len = strlen (entry->d_name);
  -          if (mksd_writev (sock, iov, 5) < 0) {
  -            closedir (unpdir);
  -            return DEFER;
  -          }
  -          iov[0].iov_base = cmd + 1;
  -          iov[0].iov_len = 2;
  -          pending++;
  -        }
  -      } else {
  -        closedir (unpdir);
  -        unpdir = NULL;
  -      }
  -    }
  -    
  -    /* read and parse */
  -    if (pending > 0) {
  -      if ((offset = mksd_read_lines (sock, av_buffer, sizeof (av_buffer))) < 0) {
  -        if (unpdir != NULL)
  -          closedir (unpdir);
  -        return DEFER;
  -      }
  -      line = av_buffer;
  -      do {
  -        if (((i = mksd_parse_line (CS line)) != OK) || (malware_name != NULL)) {
  -          close (sock);
  -          if (unpdir != NULL)
  -            closedir (unpdir);
  -          return i;
  -        }
  -        pending--;
  -        if ((line = Ustrchr (line, '\n')) == NULL) {
  -          close (sock);
  -          if (unpdir != NULL)
  -            closedir (unpdir);
  -          log_write(0, LOG_MAIN|LOG_PANIC,
  -                    "malware acl condition: unterminated line received from mksd");
  -          return DEFER;
  -        }
  -      } while (++line != (av_buffer + offset));
  -      offset = 0;
  -    }
  -  }
  -  
  -  close (sock);
  -  return OK;
   }


#endif

  Index: mime.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/mime.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- mime.c    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ mime.c    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,15 +1,14 @@
  -/* $Cambridge: exim/exim-src/src/mime.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/mime.c,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2004 */
/* License: GPL */

#include "exim.h"
+#ifdef WITH_CONTENT_SCAN
#include "mime.h"
#include <sys/stat.h>


  Index: mime.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/mime.h,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- mime.h    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ mime.h    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,14 +1,13 @@
  -/* $Cambridge: exim/exim-src/src/mime.h,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/mime.h,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2004 */
/* License: GPL */

+#ifdef WITH_CONTENT_SCAN

#define MIME_MAX_HEADER_SIZE 8192
#define MIME_MAX_LINE_LENGTH 32768

  Index: regex.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/regex.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- regex.c    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ regex.c    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,11 +1,9 @@
  -/* $Cambridge: exim/exim-src/src/regex.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/regex.c,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2003-???? */
/* License: GPL */

  @@ -13,6 +11,7 @@
    Called from acl.c. */


#include "exim.h"
+#ifdef WITH_CONTENT_SCAN
#include <unistd.h>
#include <sys/mman.h>


  Index: spam.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/spam.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- spam.c    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ spam.c    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,17 +1,16 @@
  -/* $Cambridge: exim/exim-src/src/spam.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spam.c,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2003-???? */
/* License: GPL */

/* Code for calling spamassassin's spamd. Called from acl.c. */

#include "exim.h"
+#ifdef WITH_CONTENT_SCAN
#include "spam.h"

uschar spam_score_buffer[16];

  Index: spam.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/spam.h,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- spam.h    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ spam.h    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,15 +1,15 @@
  -/* $Cambridge: exim/exim-src/src/spam.h,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spam.h,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2003-???? */
/* License: GPL */

/* spam defines */
+
+#ifdef WITH_CONTENT_SCAN

/* timeout for reading from spamd */
#define SPAMD_READ_TIMEOUT 3600

  Index: spool_mbox.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/Attic/spool_mbox.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- spool_mbox.c    26 Nov 2004 16:04:26 -0000    1.1.2.2
  +++ spool_mbox.c    30 Nov 2004 15:18:58 -0000    1.1.2.3
  @@ -1,11 +1,9 @@
  -/* $Cambridge: exim/exim-src/src/spool_mbox.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spool_mbox.c,v 1.1.2.3 2004/11/30 15:18:58 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
   *************************************************/


-#ifdef WITH_CONTENT_SCAN
-
/* Copyright (c) Tom Kistner <tom@???> 2003-???? */
/* License: GPL */

@@ -13,10 +11,13 @@
sub directory of exim's spool directory. */

#include "exim.h"
+#ifdef WITH_CONTENT_SCAN

/* externals, we must reset them on unspooling */
+#ifdef WITH_OLD_DEMIME
extern int demime_ok;
extern struct file_extension *file_extensions;
+#endif

extern int malware_ok;
extern int spam_ok;
@@ -126,10 +127,13 @@
void unspool_mbox(void) {

     /* reset all exiscan state variables */
  +  #ifdef WITH_OLD_DEMIME
     demime_ok = 0;
     demime_errorlevel = 0;
     demime_reason = NULL;
     file_extensions = NULL;
  +  #endif
  +  
     spam_ok = 0;
     malware_ok = 0;