--- qmail-smtpd.c.orig Mon Jun 15 19:53:16 1998 +++ qmail-smtpd.c Fri Jul 23 14:10:17 2004 @@ -50,6 +50,7 @@ void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); } void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } +void err_brt() { out("553 sorry, your envelope recipient is in my badrcptto list (#5.7.1)\r\n"); { extern stralloc addr; char *s; s = "badrcptto: "; write(2, s, str_len(s)); write(2, addr.s, addr.len - 1); write(2, "\n", 1); } } void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } @@ -96,6 +97,9 @@ int bmfok = 0; stralloc bmf = {0}; struct constmap mapbmf; +int brtok = 0; +stralloc brt = {0}; +struct constmap mapbrt; void setup() { @@ -116,6 +120,10 @@ if (bmfok == -1) die_control(); if (bmfok) if (!constmap_init(&mapbmf,bmf.s,bmf.len,0)) die_nomem(); + brtok = control_readfile(&brt,"control/badrcptto",0); + if (brtok == -1) die_control(); + if (brtok) + if (!constmap_init(&mapbrt,brt.s,brt.len,0)) die_nomem(); if (control_readint(&databytes,"control/databytes") == -1) die_control(); x = env_get("DATABYTES"); @@ -208,6 +216,13 @@ return 0; } +int brtcheck() +{ + if (!brtok) return 0; + if (constmap(&mapbrt,addr.s,addr.len - 1)) return 1; + return 0; +} + int addrallowed() { int r; @@ -251,6 +266,8 @@ if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } if (flagbarf) { err_bmf(); return; } + flagbarf = brtcheck(); + if (flagbarf) { err_brt(); return; } if (relayclient) { --addr.len; if (!stralloc_cats(&addr,relayclient)) die_nomem();