From b8ad20c62da583362708a2a23b7717e0338571d5 Mon Sep 17 00:00:00 2001 From: epg <> Date: Wed, 19 Apr 2006 19:41:22 +0000 Subject: [PATCH] Ouch, was bombing when talking to spamd failed for any reason, leaving messages in mdp. spamd failures aren't hard failures, just consider messages where that happens not to be spam. --- processor.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/processor.c b/processor.c index 2c015c6..2ebca53 100644 --- a/processor.c +++ b/processor.c @@ -28,6 +28,8 @@ static int flags = SPAMC_CHECK_ONLY | SPAMC_RAW_MODE; #define err(n, ...) _err(n, true, __FILE__, __LINE__, __VA_ARGS__) #define errx(n, ...) _err(n, false, __FILE__, __LINE__, __VA_ARGS__) +#define warn(...) _err(0, true, __FILE__, __LINE__, __VA_ARGS__) +#define warnx(...) _err(0, false, __FILE__, __LINE__, __VA_ARGS__) void _err(int exitcode, bool want_strerror, char *fn, int lineno, char *format, ...) @@ -95,7 +97,7 @@ logname() return p->pw_name; } -static void +static bool get_transport(struct transport *t) { int status; @@ -106,11 +108,14 @@ get_transport(struct transport *t) t->port = T_PORT; if ((status = transport_setup(t, 0)) != EX_OK) { - errx(status, "transport_setup"); + warnx("non-fatal: transport_setup"); + return false; } + + return true; } -static void +static bool get_message(char *fn, struct message *m) { int fd; @@ -127,8 +132,11 @@ get_message(char *fn, struct message *m) } if ((status = message_read(fd, flags, m)) != EX_OK) { - errx(status, "message_read"); + warnx("non-fatal: message_read"); + return false; } + + return true; } static bool @@ -138,11 +146,16 @@ is_spam(char *message) struct message m; int status; - get_transport(&t); - get_message(message, &m); + if (!get_transport(&t)) { + return false; + } + if (!get_message(message, &m)) { + return false; + } if ((status = message_filter(&t, logname(), flags, &m)) != EX_OK) { - errx(status, "message_filter"); + warnx("non-fatal: message_filter"); + return false; } if (m.is_spam == EX_ISSPAM) { @@ -151,8 +164,7 @@ is_spam(char *message) return false; } - errx(m.is_spam, "message_filter"); - /*NOTREACHED*/ + warnx("non-fatal: message_filter returned %d", m.is_spam); return false; } @@ -164,6 +176,7 @@ process(char *tmp) /* 5 for spam/ and 1 for terminating null */ char *new = malloc(len + 5 + 1); + /* Nothing to do about a malloc failure but dump core. */ strcpy(errfn, "err"); strcat(errfn, tmp + 3); -- 2.48.1