... | ... |
@@ -58,11 +58,13 @@ static char *rejectfmt = NULL; |
58 | 58 |
int addxvirus = 0; /* 0 - don't add | 1 - replace | 2 - add */ |
59 | 59 |
char xvirushdr[255]; |
60 | 60 |
char *viraction = NULL; |
61 |
-enum { |
|
62 |
- LOGINF_NONE, |
|
63 |
- LOGINF_BASIC, |
|
64 |
- LOGINF_FULL |
|
65 |
-} loginfected; |
|
61 |
+ |
|
62 |
+#define LOGINF_NONE 0 |
|
63 |
+#define LOGINF_BASIC 1 |
|
64 |
+#define LOGINF_FULL 2 |
|
65 |
+#define LOGCLN_BASIC 4 |
|
66 |
+#define LOGCLN_FULL 8 |
|
67 |
+int loginfected; |
|
66 | 68 |
|
67 | 69 |
#define CLAMFIBUFSZ 1424 |
68 | 70 |
static const char *HDR_UNAVAIL = "UNKNOWN"; |
... | ... |
@@ -218,7 +220,7 @@ sfsistat clamfi_header(SMFICTX *ctx, char *headerf, char *headerv) { |
218 | 218 |
|
219 | 219 |
if(!headerf) return SMFIS_CONTINUE; /* just in case */ |
220 | 220 |
|
221 |
- if(loginfected == LOGINF_FULL || viraction) { |
|
221 |
+ if((loginfected & (LOGINF_FULL | LOGCLN_FULL)) || viraction) { |
|
222 | 222 |
if(!cf->msg_subj && !strcasecmp(headerf, "Subject")) |
223 | 223 |
cf->msg_subj = strdup(headerv ? headerv : ""); |
224 | 224 |
if(!cf->msg_date && !strcasecmp(headerf, "Date")) |
... | ... |
@@ -317,10 +319,23 @@ sfsistat clamfi_eom(SMFICTX *ctx) { |
317 | 317 |
len = strlen(reply); |
318 | 318 |
if(len>5 && !strcmp(reply + len - 5, ": OK\n")) { |
319 | 319 |
if(addxvirus) add_x_header(ctx, "Clean", cf->scanned_count, cf->status_count); |
320 |
+ if(loginfected & LOGCLN_FULL) { |
|
321 |
+ const char *id = smfi_getsymval(ctx, "{i}"); |
|
322 |
+ const char *from = smfi_getsymval(ctx, "{mail_addr}"); |
|
323 |
+ const char *to = smfi_getsymval(ctx, "{rcpt_addr}"); |
|
324 |
+ const char *msg_subj = makesanehdr(cf->msg_subj); |
|
325 |
+ const char *msg_date = makesanehdr(cf->msg_date); |
|
326 |
+ const char *msg_id = makesanehdr(cf->msg_id); |
|
327 |
+ logg("~Clean message %s from <%s> to <%s> with subject '%s' message-id '%s' date '%s'\n", id, from, to, msg_subj, msg_id, msg_date); |
|
328 |
+ } else if(loginfected & LOGCLN_BASIC) { |
|
329 |
+ const char *from = smfi_getsymval(ctx, "{mail_addr}"); |
|
330 |
+ const char *to = smfi_getsymval(ctx, "{rcpt_addr}"); |
|
331 |
+ logg("~Clean message from <%s> to <%s>\n", from, to); |
|
332 |
+ } |
|
320 | 333 |
ret = CleanAction(ctx); |
321 | 334 |
} else if (len>7 && !strcmp(reply + len - 7, " FOUND\n")) { |
322 | 335 |
cf->virusname = NULL; |
323 |
- if(loginfected || addxvirus || rejectfmt || viraction) { |
|
336 |
+ if((loginfected & (LOGINF_BASIC | LOGINF_FULL)) || addxvirus || rejectfmt || viraction) { |
|
324 | 337 |
char *vir; |
325 | 338 |
|
326 | 339 |
reply[len-7] = '\0'; |
... | ... |
@@ -344,7 +359,7 @@ sfsistat clamfi_eom(SMFICTX *ctx) { |
344 | 344 |
|
345 | 345 |
if(!from) from = HDR_UNAVAIL; |
346 | 346 |
if(!to) to = HDR_UNAVAIL; |
347 |
- if(loginfected == LOGINF_FULL || viraction) { |
|
347 |
+ if((loginfected & LOGINF_FULL) || viraction) { |
|
348 | 348 |
const char *id = smfi_getsymval(ctx, "{i}"); |
349 | 349 |
const char *msg_subj = makesanehdr(cf->msg_subj); |
350 | 350 |
const char *msg_date = makesanehdr(cf->msg_date); |
... | ... |
@@ -352,7 +367,7 @@ sfsistat clamfi_eom(SMFICTX *ctx) { |
352 | 352 |
|
353 | 353 |
if(!id) id = HDR_UNAVAIL; |
354 | 354 |
|
355 |
- if(loginfected == LOGINF_FULL) |
|
355 |
+ if(loginfected & LOGINF_FULL) |
|
356 | 356 |
logg("~Message %s from <%s> to <%s> with subject '%s' message-id '%s' date '%s' infected by %s\n", id, from, to, msg_subj, msg_id, msg_date, vir); |
357 | 357 |
|
358 | 358 |
if(viraction) { |
... | ... |
@@ -406,7 +421,7 @@ sfsistat clamfi_eom(SMFICTX *ctx) { |
406 | 406 |
free(e_msg_id); |
407 | 407 |
} |
408 | 408 |
} |
409 |
- if(loginfected == LOGINF_BASIC) |
|
409 |
+ if(loginfected & LOGINF_BASIC) |
|
410 | 410 |
logg("~Message from <%s> to <%s> infected by %s\n", from, to, vir); |
411 | 411 |
} |
412 | 412 |
} |
... | ... |
@@ -511,6 +526,17 @@ int init_actions(struct optstruct *opts) { |
511 | 511 |
return 1; |
512 | 512 |
} |
513 | 513 |
|
514 |
+ if((opt = optget(opts, "LogClean"))->enabled) { |
|
515 |
+ if(!strcasecmp(opt->strarg, "Basic")) |
|
516 |
+ loginfected |= LOGCLN_BASIC; |
|
517 |
+ else if(!strcasecmp(opt->strarg, "Full")) |
|
518 |
+ loginfected |= LOGCLN_FULL; |
|
519 |
+ else if(strcasecmp(opt->strarg, "Off")) { |
|
520 |
+ logg("!Invalid setting %s for option LogInfected\n", opt->strarg); |
|
521 |
+ return 1; |
|
522 |
+ } |
|
523 |
+ } |
|
524 |
+ |
|
514 | 525 |
if((opt = optget(opts, "VirusAction"))->enabled) |
515 | 526 |
viraction = strdup(opt->strarg); |
516 | 527 |
|
... | ... |
@@ -212,15 +212,22 @@ Enable verbose logging. |
212 | 212 |
Default: no |
213 | 213 |
.TP |
214 | 214 |
\fBLogInfected STRING\fR |
215 |
-Specify the type of syslog messages \- please refer to 'man syslog' for facility names. |
|
216 |
-.br |
|
217 |
-This option allows to tune what is logged when a message is infected. Possible values are Off (the default - nothing is logged), Basic (minimal info logged), Full (verbose info logged) |
|
215 |
+This option allows to tune what is logged when a message is infected. Possible values are Off (the default \- nothing is logged), Basic (minimal info logged), Full (verbose info logged) |
|
218 | 216 |
.br |
219 | 217 |
Note: For this to work properly in sendmail, make sure the msg_id, mail_addr, rcpt_addr and i macroes are available in eom. In other words add a line like: Milter.macros.eom={msg_id}, {mail_addr}, {rcpt_addr}, i to your .cf file. Alternatively use the macro: define(`confMILTER_MACROS_EOM', `{msg_id}, {mail_addr}, {rcpt_addr}, i') |
220 | 218 |
.br |
221 | 219 |
Postfix should be working fine with the default settings. |
222 | 220 |
.br |
223 | 221 |
Default: disabled |
222 |
+.TP |
|
223 |
+\fBLogClean STRING\fR |
|
224 |
+This option allows to tune what is logged when no threat is found in a scanned message. |
|
225 |
+.br |
|
226 |
+See LogInfected for possible values and caveats. |
|
227 |
+.br |
|
228 |
+Useful in debugging but drastically increases the log size. |
|
229 |
+.br |
|
230 |
+Default: disabled |
|
224 | 231 |
.SH "NOTES" |
225 | 232 |
.LP |
226 | 233 |
All options expressing a size are limited to max 4GB. Values in excess will be resetted to the maximum. |
... | ... |
@@ -265,3 +265,9 @@ Example |
265 | 265 |
# Default: disabled |
266 | 266 |
#LogInfected Basic |
267 | 267 |
|
268 |
+# This option allows to tune what is logged when no threat is found in a scanned message. |
|
269 |
+# See LogInfected for possible values and caveats. |
|
270 |
+# Useful in debugging but drastically increases the log size. |
|
271 |
+# Default: disabled |
|
272 |
+#LogClean Basic |
|
273 |
+ |
... | ... |
@@ -445,6 +445,8 @@ const struct clam_option __clam_options[] = { |
445 | 445 |
|
446 | 446 |
{ "LogInfected", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "This option allows to tune what is logged when a message is infected.\nPossible values are Off (the default - nothing is logged),\nBasic (minimal info logged), Full (verbose info logged)\nNote:\nFor this to work properly in sendmail, make sure the msg_id, mail_addr,\nrcpt_addr and i macroes are available in eom. In other words add a line like:\nMilter.macros.eom={msg_id}, {mail_addr}, {rcpt_addr}, i\nto your .cf file. Alternatively use the macro:\ndefine(`confMILTER_MACROS_EOM', `{msg_id}, {mail_addr}, {rcpt_addr}, i')\nPostfix should be working fine with the default settings.", "Basic" }, |
447 | 447 |
|
448 |
+ { "LogClean", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "This option allows to tune what is logged when no threat is found in a scanned message.\nSee LogInfected for possible values and caveats.\nUseful in debugging but drastically increases the log size.", "Basic" }, |
|
449 |
+ |
|
448 | 450 |
/* Deprecated milter options */ |
449 | 451 |
|
450 | 452 |
{ "ArchiveBlockEncrypted", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" }, |