aboutsummaryrefslogtreecommitdiffstats
path: root/mailtrain.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2011-02-27 11:35:01 +0100
committerJohannes Berg <johannes@sipsolutions.net>2011-02-27 11:42:45 +0100
commitd52daf7e31928c1b52bef6e57ec316f5f057d85a (patch)
treee69b6fc65e9f80054f8f8ea79a044d9c7c76cc2c /mailtrain.c
parent8ed65ea1566b8479536181c2520f8309ba14364e (diff)
downloaddovecot-antispam-d52daf7e31928c1b52bef6e57ec316f5f057d85a.tar.gz
dovecot-antispam-d52daf7e31928c1b52bef6e57ec316f5f057d85a.tar.xz
dovecot-antispam-d52daf7e31928c1b52bef6e57ec316f5f057d85a.zip
rename mailtrain to pipe
Diffstat (limited to '')
-rw-r--r--pipe.c (renamed from mailtrain.c)60
1 files changed, 35 insertions, 25 deletions
diff --git a/mailtrain.c b/pipe.c
index e1c7bab..309f8d9 100644
--- a/mailtrain.c
+++ b/pipe.c
@@ -30,14 +30,14 @@
#include "antispam-plugin.h"
-static const char *spamaddr = NULL;
-static const char *hamaddr = NULL;
-static const char *sendmail_binary = "/usr/sbin/sendmail";
+static const char *spam_arg = NULL;
+static const char *ham_arg = NULL;
+static const char *pipe_binary = "/usr/sbin/sendmail";
static const char *tmpdir = "/tmp";
static char **extra_args = NULL;
static int extra_args_num = 0;
-static int run_sendmail(int mailfd, enum classification wanted)
+static int run_pipe(int mailfd, enum classification wanted)
{
const char *dest;
pid_t pid;
@@ -45,10 +45,10 @@ static int run_sendmail(int mailfd, enum classification wanted)
switch (wanted) {
case CLASS_SPAM:
- dest = spamaddr;
+ dest = spam_arg;
break;
case CLASS_NOTSPAM:
- dest = hamaddr;
+ dest = ham_arg;
break;
}
@@ -60,7 +60,7 @@ static int run_sendmail(int mailfd, enum classification wanted)
if (pid == -1)
return -1;
- debug("running mailtrain backend program %s", sendmail_binary);
+ debug("running mailtrain backend program %s", pipe_binary);
if (pid) {
if (waitpid(pid, &status, 0) == -1)
@@ -76,7 +76,7 @@ static int run_sendmail(int mailfd, enum classification wanted)
argv = i_malloc(sz);
memset(argv, 0, sz);
- argv[0] = (char *) sendmail_binary;
+ argv[0] = (char *) pipe_binary;
for (i = 0; i < extra_args_num; i++)
argv[i + 1] = (char *) extra_args[i];
@@ -88,7 +88,7 @@ static int run_sendmail(int mailfd, enum classification wanted)
dup2(fd, 1);
dup2(fd, 2);
close(fd);
- execv(sendmail_binary, argv);
+ execv(pipe_binary, argv);
_exit(1);
/* not reached */
return -1;
@@ -143,7 +143,7 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx,
fd = open(buf, O_RDONLY);
read(fd, &wanted, sizeof(wanted));
- if ((rc = run_sendmail(fd, wanted))) {
+ if ((rc = run_pipe(fd, wanted))) {
mail_storage_set_error(ctx->box->storage,
ME(TEMP)
"failed to send mail");
@@ -228,7 +228,7 @@ static int backend_handle_mail(struct mailbox_transaction_context *t,
return -1;
}
- if (!hamaddr || !spamaddr) {
+ if (!ham_arg || !spam_arg) {
mail_storage_set_error(t->box->storage,
ME(NOTPOSSIBLE)
"antispam plugin not configured");
@@ -315,38 +315,48 @@ static void backend_init(pool_t pool __attr_unused__)
const char *tmp;
int i;
- tmp = get_setting("MAIL_SPAM");
+ tmp = get_setting("PIPE_PROGRAM_SPAM_ARG");
+ if (!tmp)
+ tmp = get_setting("MAIL_SPAM");
if (tmp) {
- spamaddr = tmp;
- debug("mail backend spam address %s\n", tmp);
+ spam_arg = tmp;
+ debug("pipe backend spam argument = %s\n", tmp);
}
- tmp = get_setting("MAIL_NOTSPAM");
+ tmp = get_setting("PIPE_PROGRAM_NOTSPAM_ARG");
+ if (!tmp)
+ tmp = get_setting("MAIL_NOTSPAM");
if (tmp) {
- hamaddr = tmp;
- debug("mail backend not-spam address %s\n", tmp);
+ ham_arg = tmp;
+ debug("pipe backend not-spam argument = %s\n", tmp);
}
- tmp = get_setting("MAIL_SENDMAIL");
+ tmp = get_setting("PIPE_PROGRAM");
+ if (!tmp)
+ tmp = get_setting("MAIL_SENDMAIL");
if (tmp) {
- sendmail_binary = tmp;
- debug("mail backend sendmail %s\n", tmp);
+ pipe_binary = tmp;
+ debug("pipe backend program = %s\n", tmp);
}
- tmp = get_setting("MAIL_SENDMAIL_ARGS");
+ tmp = get_setting("PIPE_PROGRAM_ARGS");
+ if (!tmp)
+ tmp = get_setting("MAIL_SENDMAIL_ARGS");
if (tmp) {
extra_args = p_strsplit(pool, tmp, ";");
extra_args_num = str_array_length(
(const char *const *)extra_args);
for (i = 0; i < extra_args_num; i++)
- debug("mail backend sendmail arg %s\n",
- extra_args[i]);
+ debug("pipe backend program arg[%d] = %s\n",
+ i, extra_args[i]);
}
- tmp = get_setting("MAIL_TMPDIR");
+ tmp = get_setting("PIPE_TMPDIR");
+ if (!tmp)
+ tmp = get_setting("MAIL_TMPDIR");
if (tmp)
tmpdir = tmp;
- debug("mail backend tmpdir %s\n", tmpdir);
+ debug("pipe backend tmpdir %s\n", tmpdir);
}
static void backend_exit(void)