diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2011-02-27 10:49:15 +0100 |
---|---|---|
committer | Johannes Berg <johannes@sipsolutions.net> | 2011-02-27 10:55:21 +0100 |
commit | fe3ee5123602ac2b8af8d1209087c2c61274c8c5 (patch) | |
tree | cf321cc73a23bc698f349e51e24fbe092e1d6f48 | |
parent | 04453737f2a63720b020fe8d4d73f3b81d9a5db0 (diff) | |
download | dovecot-antispam-fe3ee5123602ac2b8af8d1209087c2c61274c8c5.tar.gz dovecot-antispam-fe3ee5123602ac2b8af8d1209087c2c61274c8c5.tar.xz dovecot-antispam-fe3ee5123602ac2b8af8d1209087c2c61274c8c5.zip |
mailtrain: redirect stdout/stderr to /dev/null for execv
This fixes a bug where sa-learn and similar tools fail
because they cannot write to stdout or stderr at all,
and propagate the error (EBADF or such).
-rw-r--r-- | mailtrain.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mailtrain.c b/mailtrain.c index 41071bc..5529f03 100644 --- a/mailtrain.c +++ b/mailtrain.c @@ -71,7 +71,7 @@ static int run_sendmail(int mailfd, enum classification wanted) } else { char **argv; int sz = sizeof(char *) * (2 + extra_args_num + 1); - int i; + int i, fd; argv = i_malloc(sz); memset(argv, 0, sz); @@ -84,8 +84,10 @@ static int run_sendmail(int mailfd, enum classification wanted) argv[i + 1] = (char *) dest; dup2(mailfd, 0); - close(1); - close(2); + fd = open("/dev/null", O_WRONLY); + dup2(fd, 1); + dup2(fd, 2); + close(fd); execv(sendmail_binary, argv); _exit(1); /* not reached */ |