summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Kistner <tom@duncanthrax.net>2005-06-06 18:49:35 +0000
committerTom Kistner <tom@duncanthrax.net>2005-06-06 18:49:35 +0000
commit7e274b4bd7498937f95fbceb691e0d430bc2a146 (patch)
tree9b4c7f24dcaac6b1d5423da2ac131aad882d3375
parent4990831e0e254577797f04b2b939be2870a0841a (diff)
Merged patched from Alex Miller: 1) Improve aveserver failure handling 2) Write proper mbox delimiter in .eml files. 3) add X-Envelope-Sender and X-Envelope-To headers to .eml file
-rw-r--r--src/src/malware.c42
-rw-r--r--src/src/spool_mbox.c46
2 files changed, 83 insertions, 5 deletions
diff --git a/src/src/malware.c b/src/src/malware.c
index 153670d0e..53dcb3aec 100644
--- a/src/src/malware.c
+++ b/src/src/malware.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/malware.c,v 1.8 2005/05/24 08:15:02 tom Exp $ */
+/* $Cambridge: exim/src/src/malware.c,v 1.9 2005/06/06 18:49:35 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -409,6 +409,7 @@ int malware(uschar **listptr) {
uschar buf[32768];
struct sockaddr_un server;
int sock;
+ int result;
if ((kav_options = string_nextinlist(&av_scanner_work, &sep,
kav_options_buffer,
@@ -456,19 +457,52 @@ int malware(uschar **listptr) {
}
malware_name = NULL;
+ result = 0;
/* read response lines, find malware name and final response */
while (recv_line(sock, buf, 32768) > 0) {
debug_printf("aveserver: %s\n", buf);
- if (buf[0] == '2') break;
- if (Ustrncmp(buf,"322",3) == 0) {
+ if (buf[0] == '2') {
+ break;
+ } else if (buf[0] == '5') {
+ /* aveserver is having problems */
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "malware acl condition: unable to scan file %s/scan/%s/%s.eml (Responded: %s).",
+ spool_directory, message_id, message_id, buf);
+ result = DEFER;
+ break;
+ } else if (Ustrncmp(buf,"322",3) == 0) {
uschar *p = Ustrchr(&buf[4],' ');
*p = '\0';
Ustrcpy(malware_name_buffer,&buf[4]);
malware_name = malware_name_buffer;
- };
+ };
}
+ /* prepare our command */
+ snprintf(CS buf, 32768, "quit\r\n");
+
+ /* and send it */
+ if (send(sock, buf, Ustrlen(buf), 0) < 0) {
+ close(sock);
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "malware acl condition: unable to write to aveserver UNIX socket (%s)", kav_options);
+ return DEFER;
+ }
+
+ /* read aveserver's greeting and see if it is ready (2xx greeting) */
+ recv_line(sock, buf, 32768);
+
+ if (buf[0] != '2') {
+ /* aveserver is having problems */
+ close(sock);
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "malware acl condition: unable to quit aveserver dialogue (Responded: %s).", ((buf[0] != 0) ? buf : (uschar *)"nothing") );
+ return DEFER;
+ };
+
close(sock);
+
+ if (result == DEFER) return DEFER;
}
/* "fsecure" scanner type ------------------------------------------------- */
else if (strcmpic(scanner_name,US"fsecure") == 0) {
diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c
index d787c5767..d1cae29a1 100644
--- a/src/src/spool_mbox.c
+++ b/src/src/spool_mbox.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/spool_mbox.c,v 1.5 2005/05/24 08:15:02 tom Exp $ */
+/* $Cambridge: exim/src/src/spool_mbox.c,v 1.6 2005/06/06 18:49:35 tom Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -36,6 +36,9 @@ FILE *spool_mbox(unsigned long *mbox_file_size) {
header_line *my_headerlist;
struct stat statbuf;
int i,j;
+ uschar *mbox_delimiter;
+ uschar *envelope_from;
+ uschar *envelope_to;
if (!spool_mbox_ok) {
/* create scan directory, if not present */
@@ -60,6 +63,47 @@ FILE *spool_mbox(unsigned long *mbox_file_size) {
return NULL;
};
+ /* Generate mailbox delimiter */
+ mbox_delimiter = expand_string(US"From ${sender_address} ${tod_bsdinbox}\n");
+ if (mbox_delimiter != NULL) {
+ if (mbox_delimiter[0] != 0) {
+ i = fwrite(mbox_delimiter, 1, Ustrlen(mbox_delimiter), mbox_file);
+ if (i != Ustrlen(mbox_delimiter)) {
+ debug_printf("error/short write on writing in: %s", mbox_path);
+ fclose(mbox_file);
+ return NULL;
+ };
+ };
+ };
+ /* Generate X-Envelope-From header */
+ envelope_from = expand_string(US"${sender_address}");
+ if (envelope_from != NULL) {
+ if (envelope_from[0] != 0) {
+ uschar *my_envelope_from;
+ my_envelope_from = string_sprintf("X-Envelope-From: <%s>\n", envelope_from);
+ i = fwrite(my_envelope_from, 1, Ustrlen(my_envelope_from), mbox_file);
+ if (i != Ustrlen(my_envelope_from)) {
+ debug_printf("error/short write on writing in: %s", mbox_path);
+ fclose(mbox_file);
+ return NULL;
+ };
+ };
+ };
+ /* Generate X-Envelope-To header */
+ envelope_to = expand_string(US"${if def:received_for{$received_for}}");
+ if (envelope_to != NULL) {
+ if (envelope_to[0] != 0) {
+ uschar *my_envelope_to;
+ my_envelope_to = string_sprintf("X-Envelope-To: <%s>\n", envelope_to);
+ i = fwrite(my_envelope_to, 1, Ustrlen(my_envelope_to), mbox_file);
+ if (i != Ustrlen(my_envelope_to)) {
+ debug_printf("error/short write on writing in: %s", mbox_path);
+ fclose(mbox_file);
+ return NULL;
+ };
+ };
+ };
+
/* write all header lines to mbox file */
my_headerlist = header_list;
while (my_headerlist != NULL) {