aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-junk-filter.c
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2004-02-07 01:44:54 +0800
committerRadek Doulik <rodo@src.gnome.org>2004-02-07 01:44:54 +0800
commit7b38fcff8316a9efcb83e4b8e93829117399a3cd (patch)
treeb3416cb244785a00e4e9d4e97cb096f2efab2102 /mail/em-junk-filter.c
parent5868c475f966ee06afa7cf17296c1f85e0434dc8 (diff)
downloadgsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar.gz
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar.bz2
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar.lz
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar.xz
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.tar.zst
gsoc2013-evolution-7b38fcff8316a9efcb83e4b8e93829117399a3cd.zip
move to the next message after mark not junk as well
2004-02-06 Radek Doulik <rodo@ximian.com> * em-folder-view.c (emfv_popup_mark_nojunk): move to the next message after mark not junk as well * em-junk-filter.c (em_junk_sa_test_spamd): split into spamassassin and spamd tests (em_junk_sa_is_available): test spamd only if spamd usage enabled (pipe_to_sa_with_error): extended pipe_to_sa, last added parametr specifies return value if an error occured (em_junk_sa_check_junk): don't use /bin/sh -c when running spamassassin, it's not needed and we need to avoid getting 126,127 exit codes from the shell (em_junk_sa_check_junk): pass 0 rv_err to pipe_to_sa_with_error to avoid false positives in case someone removes/uninstalls SA while evolution runs svn path=/trunk/; revision=24651
Diffstat (limited to 'mail/em-junk-filter.c')
-rw-r--r--mail/em-junk-filter.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/mail/em-junk-filter.c b/mail/em-junk-filter.c
index 29e618205f..8c178a0fe9 100644
--- a/mail/em-junk-filter.c
+++ b/mail/em-junk-filter.c
@@ -95,7 +95,7 @@ em_junk_sa_get_daemon_port ()
}
static int
-pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
+pipe_to_sa_with_error (CamelMimeMessage *msg, const char *in, char **argv, int rv_err)
{
int result, status, errnosav, fds[2];
CamelStream *stream;
@@ -116,7 +116,7 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
errnosav = errno;
d(printf ("failed to create a pipe (for use with spamassassin: %s\n", strerror (errno)));
errno = errnosav;
- return -1;
+ return rv_err;
}
if (!(pid = fork ())) {
@@ -128,7 +128,7 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
if (dup2 (fds[0], STDIN_FILENO) == -1 ||
dup2 (nullfd, STDOUT_FILENO) == -1 ||
dup2 (nullfd, STDERR_FILENO) == -1)
- _exit (255);
+ _exit (rv_err & 0377);
setsid ();
@@ -137,13 +137,13 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
fcntl (fd, F_SETFD, FD_CLOEXEC);
execvp (argv[0], argv);
- _exit (255);
+ _exit (rv_err & 0377);
} else if (pid < 0) {
errnosav = errno;
close (fds[0]);
close (fds[1]);
errno = errnosav;
- return -1;
+ return rv_err;
}
/* parent process */
@@ -178,7 +178,13 @@ pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
if (result != -1 && WIFEXITED (status))
return WEXITSTATUS (status);
else
- return -1;
+ return rv_err;
+}
+
+static int
+pipe_to_sa (CamelMimeMessage *msg, const char *in, char **argv)
+{
+ return pipe_to_sa_with_error (msg, in, argv, -1);
}
static int
@@ -206,10 +212,9 @@ em_junk_sa_test_spamd_running (int port)
static void
em_junk_sa_test_spamassassin (void)
{
- char *argv[4] = {
- "/bin/sh",
- "-c",
- "spamassassin --version",
+ char *argv [3] = {
+ "spamassassin",
+ "--version",
NULL,
};
@@ -304,7 +309,7 @@ static gboolean
em_junk_sa_check_junk (CamelMimeMessage *msg)
{
char *argv[5], buf[12];
- int i = 0;
+ int i = 0, rv;
d(fprintf (stderr, "em_junk_sa_check_junk\n"));
@@ -320,18 +325,15 @@ em_junk_sa_check_junk (CamelMimeMessage *msg)
argv[i++] = buf;
}
} else {
- argv[i++] = "/bin/sh";
- argv[i++] = "-c";
-
+ argv [i++] = "spamassassin";
+ argv [i++] = "--exit-code";
if (em_junk_sa_get_local_only ())
- argv[i++] = "spamassassin --exit-code --local";
- else
- argv[i++] = "spamassassin --exit-code";
+ argv [i++] = "--local";
}
argv[i] = NULL;
-
- return pipe_to_sa (msg, NULL, argv);
+
+ return pipe_to_sa_with_error (msg, NULL, argv, 0) != 0;
}
static void