-# $Cambridge: exim/src/OS/Makefile-Base,v 1.1.2.1 2004/11/26 14:17:33 tom Exp $
+# $Cambridge: 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
# 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 \
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
-/* $Cambridge: exim/src/src/acl.c,v 1.5.2.1 2004/11/25 15:33:55 tom Exp $ */
+/* $Cambridge: exim/src/src/acl.c,v 1.5.2.2 2004/11/30 15:18:58 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
#endif
ACLC_RECIPIENTS,
#ifdef WITH_CONTENT_SCAN
- ACLC_REGEX
+ ACLC_REGEX,
#endif
ACLC_SENDER_DOMAINS, ACLC_SENDERS, ACLC_SET,
#ifdef WITH_CONTENT_SCAN
uschar *log_message = NULL;
uschar *p;
int rc = OK;
+#ifdef WITH_CONTENT_SCAN
+int sep = '/';
+#endif
for (; cb != NULL; cb = cb->next)
{
-/* $Cambridge: exim/src/src/config.h.defaults,v 1.2 2004/10/18 09:16:57 ph10 Exp $ */
+/* $Cambridge: 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 *
#define USE_TCP_WRAPPERS
#define USE_TDB
+#define WITH_CONTENT_SCAN
+
/* Things that are not routinely changed but are nevertheless configurable
just in case. */
-/* $Cambridge: exim/src/src/exim.h,v 1.3 2004/11/24 15:43:36 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.h,v 1.2.2.1 2004/11/30 15:18:58 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
#endif
/* We use the private type T_ZNS for retrieving the nameservers for the
-enclosing zone of a domain, and the private type T_MXH for retrieving
-the MX hostnames only (without their priorities). */
+enclosing zone of a domain. */
#define T_ZNS (-1)
-#define T_MXH (-2)
/* The resolv.h header defines __P(x) on some Solaris 2.5.1 systems (without
checking that it is already defined, in fact). This conflicts with other
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"
-/* $Cambridge: exim/src/src/functions.h,v 1.6 2004/11/25 13:54:31 ph10 Exp $ */
+/* $Cambridge: exim/src/src/functions.h,v 1.5.2.1 2004/11/30 15:18:58 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
extern int filter_interpret(uschar *, int, address_item **, uschar **);
extern BOOL filter_personal(string_item *, BOOL);
-extern BOOL filter_runtest(int, uschar *, BOOL, BOOL);
+extern BOOL filter_runtest(int, BOOL, BOOL);
extern BOOL filter_system_interpret(address_item **, uschar **);
extern void header_add(int, char *, ...);
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 **,
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 *);
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);
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 *);
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 *);
extern int verify_check_dnsbl(uschar **);
-/* $Cambridge: exim/src/src/macros.h,v 1.2.2.1 2004/11/25 15:33:55 tom Exp $ */
+/* $Cambridge: exim/src/src/macros.h,v 1.2.2.2 2004/11/30 15:18:58 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
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, /* ) */
ACL_WHERE_PREDATA, /* ) There are several tests for "in message", */
-/* $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
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;
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
-/* $Cambridge: exim/src/src/mime.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 2004 */
/* License: GPL */
#include "exim.h"
+#ifdef WITH_CONTENT_SCAN
#include "mime.h"
#include <sys/stat.h>
-/* $Cambridge: exim/src/src/mime.h,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 2004 */
/* License: GPL */
+#ifdef WITH_CONTENT_SCAN
#define MIME_MAX_HEADER_SIZE 8192
#define MIME_MAX_LINE_LENGTH 32768
-/* $Cambridge: exim/src/src/regex.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 2003-???? */
/* License: GPL */
Called from acl.c. */
#include "exim.h"
+#ifdef WITH_CONTENT_SCAN
#include <unistd.h>
#include <sys/mman.h>
-/* $Cambridge: exim/src/src/spam.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 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];
-/* $Cambridge: exim/src/src/spam.h,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 2003-???? */
/* License: GPL */
/* spam defines */
+#ifdef WITH_CONTENT_SCAN
+
/* timeout for reading from spamd */
#define SPAMD_READ_TIMEOUT 3600
-/* $Cambridge: exim/src/src/spool_mbox.c,v 1.1.2.2 2004/11/26 16:04:26 tom Exp $ */
+/* $Cambridge: 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@duncanthrax.net> 2003-???? */
/* License: GPL */
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;
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;