summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-02-04 02:54:37 +0100
committermanuel <manuel@mausz.at>2013-02-04 02:54:37 +0100
commitee944357ee374402f20eb1297a0b596f7ef4ea8d (patch)
treefe9c7758ee22a05caf8f62f94eeb1fe0c23619db
parenta0de1c2316ccd0f2146440f422cd79065ec98109 (diff)
downloadqmail-ee944357ee374402f20eb1297a0b596f7ef4ea8d.tar.gz
qmail-ee944357ee374402f20eb1297a0b596f7ef4ea8d.tar.bz2
qmail-ee944357ee374402f20eb1297a0b596f7ef4ea8d.zip
[PATCH] Reject some bad relaying attempt
qmail-smtpd-relay-reject.gentoo
-rw-r--r--qmail-smtpd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/qmail-smtpd.c b/qmail-smtpd.c
index c77c6cc..86c5bd9 100644
--- a/qmail-smtpd.c
+++ b/qmail-smtpd.c
@@ -95,6 +95,7 @@ void err_nogateway()
95#endif 95#endif
96void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); } 96void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); }
97void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } 97void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); }
98void err_relay() { out("553 we don't relay (#5.7.1)\r\n"); }
98void err_wantmail() { out("503 MAIL first (#5.5.1)\r\n"); } 99void err_wantmail() { out("503 MAIL first (#5.5.1)\r\n"); }
99void err_wantrcpt() { out("503 RCPT first (#5.5.1)\r\n"); } 100void err_wantrcpt() { out("503 RCPT first (#5.5.1)\r\n"); }
100void err_noop() { out("250 ok\r\n"); } 101void err_noop() { out("250 ok\r\n"); }
@@ -345,6 +346,20 @@ int addrallowed()
345 return r; 346 return r;
346} 347}
347 348
349int addrrelay()
350{
351 int j;
352 j = addr.len;
353 while(--j >= 0)
354 if (addr.s[j] == '@') break;
355 if (j < 0) j = addr.len;
356 while(--j >= 0) {
357 if (addr.s[j] == '@') return 1;
358 if (addr.s[j] == '%') return 1;
359 if (addr.s[j] == '!') return 1;
360 }
361 return 0;
362}
348 363
349int seenmail = 0; 364int seenmail = 0;
350int flagbarfbmf; /* defined if seenmail */ 365int flagbarfbmf; /* defined if seenmail */
@@ -469,6 +484,7 @@ void smtp_mail(arg) char *arg;
469void smtp_rcpt(arg) char *arg; { 484void smtp_rcpt(arg) char *arg; {
470 if (!seenmail) { err_wantmail(); return; } 485 if (!seenmail) { err_wantmail(); return; }
471 if (!addrparse(arg)) { err_syntax(); return; } 486 if (!addrparse(arg)) { err_syntax(); return; }
487 if (addrrelay()) { err_relay(); return; }
472 if (flagbarfbhelo) { 488 if (flagbarfbhelo) {
473 if (logregex) { 489 if (logregex) {
474 strerr_warn6("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0); 490 strerr_warn6("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0);