summaryrefslogtreecommitdiff
path: root/libexec/spamd/spamd.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2007-03-26 15:20:44 +0000
committerBob Beck <beck@cvs.openbsd.org>2007-03-26 15:20:44 +0000
commit4f48b372a1d4de8c946abe5992cf8050108b0105 (patch)
treeb61732a0d75ba2dc48a5a4dce3e7c7a8dd46ee0f /libexec/spamd/spamd.c
parente8406066099be958b42be029c3795c8a13424c13 (diff)
A couple of spamd improvements
1) Implement the NOOP command, which now seems necessary for certain windows mail wrappers and sender verification schemes. Tested by me and sidcarter@symonds.net, who noticed the problem on his site. ok millert@ 2) Change the behaviour of the maxblack parameter, instead of hanging up immediately on new blacklisted connections when the maxblack parameter is reached, we instead make spamd not stutter at them, so the connection is instead completed quickly. This seems to handle peaks and spikes much better than the old way of doing this. ok deraadt@, with some man page changes by jmc@
Diffstat (limited to 'libexec/spamd/spamd.c')
-rw-r--r--libexec/spamd/spamd.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index 80b43933384..45e39cd63cf 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.98 2007/03/07 11:30:43 jmc Exp $ */
+/* $OpenBSD: spamd.c,v 1.99 2007/03/26 15:20:43 beck Exp $ */
/*
* Copyright (c) 2002 Theo de Raadt. All rights reserved.
@@ -658,10 +658,8 @@ initcon(struct con *cp, int fd, struct sockaddr *sa)
clients++;
if (cp->blacklists != NULL) {
blackcount++;
- if (greylist && blackcount > maxblack) {
- closecon(cp); /* close and free */
- return;
- }
+ if (greylist && blackcount > maxblack)
+ cp->stutter = 0;
cp->lists = strdup(loglists(cp));
}
else
@@ -842,20 +840,29 @@ nextstate(struct con *cp)
syslog_r(LOG_DEBUG, &sdata,"setsockopt: %m");
/* don't fail if this doesn't work. */
}
+ cp->ip = cp->ibuf;
+ cp->il = sizeof(cp->ibuf) - 1;
+ cp->op = cp->obuf;
+ cp->ol = strlen(cp->op);
+ cp->w = t + cp->stutter;
+ if (greylist && cp->blacklists == NULL) {
+ cp->laststate = cp->state;
+ cp->state = 98;
+ goto done;
+ }
} else {
- snprintf(cp->obuf, cp->osize,
- "500 5.5.1 Command unrecognized\r\n");
+ if (match(cp->ibuf, "NOOP"))
+ snprintf(cp->obuf, cp->osize,
+ "250 2.0.0 OK I did nothing\r\n");
+ else
+ snprintf(cp->obuf, cp->osize,
+ "500 5.5.1 Command unrecognized\r\n");
cp->state = cp->laststate;
- }
- cp->ip = cp->ibuf;
- cp->il = sizeof(cp->ibuf) - 1;
- cp->op = cp->obuf;
- cp->ol = strlen(cp->op);
- cp->w = t + cp->stutter;
- if (greylist && cp->blacklists == NULL) {
- cp->laststate = cp->state;
- cp->state = 98;
- goto done;
+ cp->ip = cp->ibuf;
+ cp->il = sizeof(cp->ibuf) - 1;
+ cp->op = cp->obuf;
+ cp->ol = strlen(cp->op);
+ cp->w = t + cp->stutter;
}
break;
case 60: