-urN dspam/src/dspam.c dspam.new/src/dspam.c --- dspam/src/dspam.c 2006-06-01 21:23:10.000000000 +0200 +++ dspam.new/src/dspam.c 2006-08-06 22:30:46.000000000 +0200 @@ -397,6 +397,7 @@ { if (has_virus(message)) { char ip[32]; + char *sender = _ds_find_header(CTX->message, "From", 0); CTX->result = DSR_ISSPAM; CTX->probability = 1.0; CTX->confidence = 1.0; @@ -407,6 +408,10 @@ if (!dspam_getsource (CTX, ip, sizeof (ip))) { LOG(LOG_WARNING, "virus warning: infected message from %s", ip); + if (_ds_match_attribute(agent_config, "VirusNotifications", "on")) { + LOGDEBUG("sending virus notification to %s: %s", + CTX->username, strerror(errno)); + send_notice(ATX, "virusnotification.txt", ATX->mailer_args, CTX->username, ip, sender); } } } @@ -1439,7 +1444,7 @@ /* * send_notice(AGENT_CTX *ATX, const char *filename, const char *mailer_args, - * const char *username) + * const char *username, const char *ip, const char *sender) * * DESCRIPTION * Sends a canned notice to the destination user @@ -1449,6 +1454,8 @@ * filename Filename of canned notice * mailer_args Local agent arguments * username Destination user + * ip Sender IP (optional) + * sender Sender address (optional) * * RETURN VALUES * returns 0 on success, standard errors on failure @@ -1490,6 +1497,8 @@ while(fgets(buf, sizeof(buf), f)!=NULL) { char *s = buf; char *w = strstr(buf, "$u"); + char *x = strstr(buf, "$i"); + char *y = strstr(buf, "$s"); while(w != NULL) { w[0] = 0; buffer_cat(b, s); @@ -1497,6 +1506,20 @@ s = w+2; w = strstr(s, "$u"); } + while(x != NULL) { + x[0] = 0; + buffer_cat(b, s); + buffer_cat(b, ip); + s = x+2; + x = strstr(s, "$i"); + } + while(y != NULL) { + y[0] = 0; + buffer_cat(b, s); + buffer_cat(b, sender); + s = y+2; + y = strstr(s, "$s"); + } buffer_cat(b, s); } fclose(f); @@ -3388,6 +3411,7 @@ { if (CTX->totals.innocent_learned + CTX->totals.innocent_classified > 2500) { if (CTX->result == DSR_ISSPAM && + strcmp(CTX->class, LANG_CLASS_VIRUS) != 0 && _ds_match_attribute(agent_config, "TrackSources", "spam")) { FILE *file; char dropfile[MAX_FILENAME_LENGTH]; @@ -3870,7 +3894,7 @@ if (file == NULL) { LOGDEBUG("sending firstrun.txt to %s (%s): %s", CTX->username, filename, strerror(errno)); - send_notice(ATX, "firstrun.txt", ATX->mailer_args, CTX->username); + send_notice(ATX, "firstrun.txt", ATX->mailer_args, CTX->username, NULL, NULL); file = fopen(filename, "w"); if (file) { fprintf(file, "%ld\n", (long) time(NULL)); @@ -3885,6 +3909,7 @@ /* First spam notification */ if (CTX->result == DSR_ISSPAM && + strcmp(CTX->class, LANG_CLASS_VIRUS) != 0 && _ds_match_attribute(agent_config, "Notifications", "on")) { _ds_userdir_path(filename, @@ -3894,7 +3919,7 @@ if (file == NULL) { LOGDEBUG("sending firstspam.txt to %s (%s): %s", CTX->username, filename, strerror(errno)); - send_notice(ATX, "firstspam.txt", ATX->mailer_args, CTX->username); + send_notice(ATX, "firstspam.txt", ATX->mailer_args, CTX->username, NULL, NULL); file = fopen(filename, "w"); if (file) { fprintf(file, "%ld\n", (long) time(NULL)); @@ -3925,7 +3950,7 @@ fprintf(f, "%ld", (long) time(NULL)); fclose(f); - send_notice(ATX, "quarantinefull.txt", ATX->mailer_args, CTX->username); + send_notice(ATX, "quarantinefull.txt", ATX->mailer_args, CTX->username, NULL, NULL); } } } diff -urN dspam/src/dspam.h dspam.new/src/dspam.h --- dspam/src/dspam.h 2006-05-13 03:12:59.000000000 +0200 +++ dspam.new/src/dspam.h 2006-08-06 22:30:59.000000000 +0200 @@ -48,7 +48,8 @@ int user_classify (AGENT_CTX *ATX, const char *username, struct _ds_spam_signature *SIG, const char *message); int send_notice (AGENT_CTX *ATX, const char *filename, - const char *mailer_args, const char *username); + const char *mailer_args, const char *username, + const char *ip, const char *sender); int write_web_stats (AGENT_CTX *ATX, const char *username, const char *group, struct _ds_spam_totals *totals); int ensure_confident_result (DSPAM_CTX *CTX, AGENT_CTX *ATX, int result);