diff --git a/opendkim/opendkim-spam.1.in b/opendkim/opendkim-spam.1.in index 7b0bb81..45a1fa0 100644 --- a/opendkim/opendkim-spam.1.in +++ b/opendkim/opendkim-spam.1.in @@ -67,6 +67,11 @@ The default is "opendkim". Specifies the port number where the database server is listening. The default depends on which backend is in use. .TP +.I -r reporter +Provides the name of the site reporting the spam. If not provided, an attempt +will be made to extract this information from the topmost Received header +field from the input message. +.TP .I -s column Names the database column whose value should be set to "1" as a result of this user action. The default is "uspam". @@ -118,6 +123,9 @@ are as follows; see above for descriptions: .I DatabaseUser \-u .TP +.I ReporterID +\-r +.TP .I StatisticsFile \-o .SH NOTES diff --git a/opendkim/opendkim-spam.c b/opendkim/opendkim-spam.c index 52197e6..5730713 100644 --- a/opendkim/opendkim-spam.c +++ b/opendkim/opendkim-spam.c @@ -35,7 +35,7 @@ /* definitions, macros, etc. */ #define BUFRSZ 1024 -#define CMDLINEOPTS "b:c:d:fh:o:p:P:s:u:vV" +#define CMDLINEOPTS "b:c:d:fh:o:p:P:r:s:u:vV" #define DEFDBBACKEND SQL_BACKEND #undef DEFCONFFILE #define DEFCONFFILE CONFIG_BASE "/opendkim-spam.conf" @@ -68,6 +68,7 @@ struct configdef spam_config[] = { "DatabasePassword", CONFIG_TYPE_STRING, FALSE }, { "DatabaseSpamColumn", CONFIG_TYPE_STRING, FALSE }, { "DatabaseUser", CONFIG_TYPE_STRING, FALSE }, + { "ReporterID", CONFIG_TYPE_STRING, FALSE }, { "StatisticsFile", CONFIG_TYPE_STRING, FALSE }, { NULL, (u_int) -1, FALSE } }; @@ -96,6 +97,7 @@ usage(void) "\t-P dbport \tdatabase port [%s]\n" "\t-s dbspamcol\tdatabase spam column name [%s]\n" "\t-u dbuser \tdatabase user [%s]\n" + "\t-r reporter \treporter id (reporting host name)\n" "\t-v \tbe more verbose\n" "\t-V \tprint version number and exit\n", progname, progname, @@ -198,6 +200,10 @@ main(int argc, char **argv) dbuser = optarg; break; + case 'r': + reporter = optarg; + break; + case 'v': verbose++; break; @@ -280,6 +286,12 @@ main(int argc, char **argv) &dbuser, sizeof dbuser); } + if (reporter == NULL) + { + (void) config_get(conf, "ReporterID", + &reporterid, sizeof reporterid); + } + if (statsfile == NULL) { (void) config_get(conf, "StatisticsFile", @@ -427,7 +439,8 @@ main(int argc, char **argv) { if (strcasecmp(prev, "id") == 0) job = p; - else if (strcasecmp(prev, "by") == 0) + else if (reporter == NULL && + strcasecmp(prev, "by") == 0) reporter = p; }