This is a patch which gives similar functionality to qmail as the databytes setup, but totaldatabytes instead. It looks at the number of recipients a message is going to and applys the value of /var/qmail/control/totaldatabytes as the limit when size is multiplied by number of recipients. This is so users can't send one large email to many people without a limitation, this will limit that. We had problems with users sending the current 'christmas movies/pictures' to lots of people using Cc: so the multiple emails leaving our server from that one email would create a large amount of traffic. This patch now will keep that to whatever it is setup to limit to in totaldatabytes, and prevent unlimited flooding potential from our users. It makes a person have to send the message possibly more than once when wanting to send it to many people, so they have to think actually about it and work at it. This saves us from the blind sending of large files to many people when taking advantage of multiple rcpt to's feature by users of qmail. If anything looks like it could be improved I welcome sugestions, thanks. I included it below, but if mangled it is also available from: http://www.groovy.org/source/Qmail/ diff -ru qmail-1.03/qmail-smtpd.c qmail-1.03-totaldb/qmail-smtpd.c --- qmail-1.03/qmail-smtpd.c Mon Jun 15 05:53:16 1998 +++ qmail-1.03-totaldb/qmail-smtpd.c Wed Dec 13 11:09:20 2000 @@ -26,6 +26,7 @@ #define MAXHOPS 100 unsigned int databytes = 0; +unsigned int totaldatabytes = 0; int timeout = 1200; int safewrite(fd,buf,len) int fd; char *buf; int len; @@ -121,7 +122,12 @@ x = env_get("DATABYTES"); if (x) { scan_ulong(x,&u); databytes = u; } if (!(databytes + 1)) --databytes; - + + if (control_readint(&totaldatabytes,"control/totaldatabytes") == -1) die_control(); + x = env_get("TOTALDATABYTES"); + if (x) { scan_ulong(x,&u); totaldatabytes = u; } + if (!(totaldatabytes + 1)) --totaldatabytes; + remoteip = env_get("TCPREMOTEIP"); if (!remoteip) remoteip = "unknown"; local = env_get("TCPLOCALHOST"); @@ -221,6 +227,7 @@ int flagbarf; /* defined if seenmail */ stralloc mailfrom = {0}; stralloc rcptto = {0}; +int rcptcount = 0; void smtp_helo(arg) char *arg; { @@ -245,6 +252,7 @@ if (!stralloc_copys(&rcptto,"")) die_nomem(); if (!stralloc_copys(&mailfrom,addr.s)) die_nomem(); if (!stralloc_0(&mailfrom)) die_nomem(); + rcptcount = 0; out("250 ok\r\n"); } void smtp_rcpt(arg) char *arg; { @@ -261,6 +269,7 @@ if (!stralloc_cats(&rcptto,"T")) die_nomem(); if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); if (!stralloc_0(&rcptto)) die_nomem(); + if (totaldatabytes) ++rcptcount; out("250 ok\r\n"); } @@ -280,6 +289,7 @@ struct qmail qqt; unsigned int bytestooverflow = 0; +unsigned int totalbytestooverflow = 0; void put(ch) char *ch; @@ -287,6 +297,9 @@ if (bytestooverflow) if (!--bytestooverflow) qmail_fail(&qqt); + if (totalbytestooverflow) + if (!--totalbytestooverflow) + qmail_fail(&qqt); qmail_put(&qqt,ch,1); } @@ -374,6 +387,7 @@ if (!rcptto.len) { err_wantrcpt(); return; } seenmail = 0; if (databytes) bytestooverflow = databytes + 1; + if (totaldatabytes) totalbytestooverflow = (totaldatabytes + 1) / rcptcount; if (qmail_open(&qqt) == -1) { err_qqt(); return; } qp = qmail_qp(&qqt); out("354 go ahead\r\n"); @@ -389,6 +403,7 @@ if (!*qqx) { acceptmessage(qp); return; } if (hops) { out("554 too many hops, this message is looping (#5.4.6)\r\n"); return; } if (databytes) if (!bytestooverflow) { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); return; } + if (totaldatabytes) if (!totalbytestooverflow) { out("552 sorry, that message size exceeds my totaldatabytes limit (#5.3.4)\r\n"); return; } if (*qqx == 'D') out("554 "); else out("451 "); out(qqx + 1); out("\r\n"); Thanks, Chris K Chris Kennedy / [EMAIL PROTECTED] I-Land Internet Services / Network Operations Center \|/ ____ \|/ "@'/ .. \`@" /_| \__/ |_\ \__U_/ -Linux SPARC Kernel Oops
