WITH_CONTENT_SCAN checkin - compiles OK now
[users/jgh/exim.git] / src / src / malware.c
index a24d0de87587b466ab6d95b1c9753af4d4268e71..972bad37fdbf109940f4c4c4d64c3eb9f4c9ad04 100644 (file)
@@ -1,21 +1,19 @@
-/* $Cambridge: exim/src/src/malware.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 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 @@ int malware(uschar **listptr) {
       
       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;
@@ -1324,94 +1319,4 @@ int mksd_scan_packed (int 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