From b0c5a1bf27516611d34b6b7d56a0376e3c64171b Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 5 Feb 2013 23:48:16 +0100 Subject: [PATCH] realrcptto --- qmail-smtpd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'qmail-smtpd.c') diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 33ca503..9fb495b 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -116,6 +116,18 @@ void die_ipme() out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); eflush(); _exit(1); } +void die_cdb() +{ + enew(); eout("Unable to read cdb user database!\n"); + out("421 unable to read cdb user database (#4.3.0)\r\n"); flush(); + eflush(); _exit(1); +} +void die_sys() +{ + enew(); eout("Unable to read system user database!\n"); + out("421 unable to read system user database (#4.3.0)\r\n"); flush(); + eflush(); _exit(1); +} void straynewline() { enew(); eout("Stray newline from "); eout(remoteip); eout(".\n"); @@ -162,6 +174,13 @@ int err_input() { out("501 malformed auth input (#5.5.4)\r\n"); return -1; } int err_wantstarttls() { out("530 Must issue a STARTTLS command first (#5.7.0)\r\n"); return -1; }; void err_authfail() { out("535 authentication failed (#5.7.1)\r\n"); } +extern void realrcptto_init(); +extern void realrcptto_start(); +extern int realrcptto(); +extern int realrcptto_deny(); + +int flagauth = 0; + stralloc greeting = {0}; void smtp_greet(code) char *code; @@ -260,6 +279,7 @@ void setup() if (fdmbrt == -1) if (errno != error_noent) die_control(); + realrcptto_init(); if (control_readint(&databytes,"control/databytes") == -1) die_control(); x = env_get("DATABYTES"); @@ -604,6 +624,7 @@ void smtp_mail(arg) char *arg; if (!stralloc_copys(&rcptto,"")) die_nomem(); if (!stralloc_copys(&mailfrom,addr.s)) die_nomem(); if (!stralloc_0(&mailfrom)) die_nomem(); + realrcptto_start(); recipcount = 0; out("250 ok\r\n"); } @@ -653,6 +674,10 @@ void smtp_rcpt(arg) char *arg; { flagbrt = 1; log_deny("BAD RCPT TO", mailfrom.s,addr.s); } + if (!flagauth && !relayclient && !realrcptto(addr.s,1)) { + out("554 sorry, no mailbox here by that name. (#5.1.1)\r\n"); + return; + } if (!(spp_val = spp_rcpt(allowed))) return; if (!relayclient && spp_val == 1) { if (!allowed) { @@ -785,6 +810,7 @@ void smtp_data() { if (mailfrom.len == 1 && recipcount > 1) { err_badbounce(); return; } if (flagbrt) { err_brt(); return; } if (!spp_data()) return; + if (!relayclient && realrcptto_deny()) { out("550 sorry, no mailbox here by that name. (#5.1.1)\r\n"); return; } seenmail = 0; if (databytes) bytestooverflow = databytes + 1; if (qmail_open(&qqt) == -1) { err_qqt(); return; } @@ -821,7 +847,6 @@ static stralloc chal = {0}; /* plain challenge */ static stralloc slop = {0}; /* b64 challenge */ #endif -int flagauth = 0; char **childargs; char ssauthbuf[512]; substdio ssauth = SUBSTDIO_FDBUF(safewrite,3,ssauthbuf,sizeof(ssauthbuf)); -- cgit v1.2.3