-/* $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 *
uschar buf[32768];
struct sockaddr_un server;
int sock;
+ int result;
if ((kav_options = string_nextinlist(&av_scanner_work, &sep,
kav_options_buffer,
}
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) {
-/* $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 *
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 */
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) {