OK, here goes maxrcpt for qmail 1.03. I've given it its own error code (666 :) ). RFC
fanatics, strip it out yourselves ;-)
One note. The default maxrcpt behavior is to deliver it's max number of messages, and
dropping the others. If you want it to reject everything, change
void err_excessrcpt() { out("666 Too many recipients specified (#5.5.4)\r\n"); }
to
void err_excessrcpt() { out("666 Too many recipients specified (#5.5.4)\r\n");
_exit(1); }
Changing the funcion's name to "die_excessrcpt" would also be adequate, but
funcionally irrelevant.
Regards;
Ricardo
--
+-------------------
| Ricardo Cerqueira - [EMAIL PROTECTED]
| PGP Key fingerprint - B7 05 13 CE 48 0A BF 1E 87 21 83 DB 28 DE 03 42
| FCCN/RCCN - Fundacao para a Computacao Cientifica Nacional
| Av. Brasil, 101 / 1700-066 Lisboa / Portugal *** Tel: (+351) 1 8440100
diff -u qmail-1.03/qmail-smtpd.c qmail-1.03-maxrcpt/qmail-smtpd.c
--- qmail-1.03/qmail-smtpd.c Mon Jun 15 11:53:16 1998
+++ qmail-1.03-maxrcpt/qmail-smtpd.c Fri Nov 5 20:11:54 1999
@@ -27,6 +27,8 @@
#define MAXHOPS 100
unsigned int databytes = 0;
int timeout = 1200;
+int rcptcounter = 0;
+int maxrcpt = -1;
int safewrite(fd,buf,len) int fd; char *buf; int len;
{
@@ -58,6 +60,7 @@
void err_noop() { out("250 ok\r\n"); }
void err_vrfy() { out("252 send some mail, i'll try my best\r\n"); }
void err_qqt() { out("451 qqt failure (#4.3.0)\r\n"); }
+void err_excessrcpt() { out("666 Too many recipients specified (#5.5.4)\r\n"); }
stralloc greeting = {0};
@@ -109,6 +112,7 @@
if (liphostok == -1) die_control();
if (control_readint(&timeout,"control/timeoutsmtpd") == -1) die_control();
if (timeout <= 0) timeout = 1;
+ if (control_readint(&maxrcpt,"control/maxrcpt") == -1) die_control();
if (rcpthosts_init() == -1) die_control();
@@ -240,6 +244,7 @@
void smtp_mail(arg) char *arg;
{
if (!addrparse(arg)) { err_syntax(); return; }
+ rcptcounter = 0;
flagbarf = bmfcheck();
seenmail = 1;
if (!stralloc_copys(&rcptto,"")) die_nomem();
@@ -248,7 +253,9 @@
out("250 ok\r\n");
}
void smtp_rcpt(arg) char *arg; {
+ rcptcounter++;
if (!seenmail) { err_wantmail(); return; }
+ if (checkrcptcount() == 1) {err_excessrcpt(); }
if (!addrparse(arg)) { err_syntax(); return; }
if (flagbarf) { err_bmf(); return; }
if (relayclient) {
@@ -392,6 +399,12 @@
if (*qqx == 'D') out("554 "); else out("451 ");
out(qqx + 1);
out("\r\n");
+}
+
+int checkrcptcount() {
+ if (maxrcpt == -1) {return 0;}
+ else if (rcptcounter > maxrcpt) {return 1;}
+ else {return 0;}
}
struct commands smtpcommands[] = {