diff -Nru qmail-1.03-smtpd-auth-0.30/qmail-smtpd.c qmail-1.03/qmail-smtpd.c --- qmail-1.03-smtpd-auth-0.30/qmail-smtpd.c Fri Nov 16 10:49:48 2001 +++ qmail-1.03/qmail-smtpd.c Fri Nov 16 10:53:51 2001 @@ -67,6 +67,7 @@ int err_pipe() { out("454 oops, unable to open pipe and I can't auth (#4.3.0)\r\n"); return -1; } int err_write() { out("454 oops, unable to write pipe and I can't auth (#4.3.0)\r\n"); return -1; } void err_authd() { out("503 you're already authenticated (#5.5.0)\r\n"); } +void err_notauthd() { out("503 you're not authenticated (#5.5.0)\r\n"); } void err_authmail() { out("503 no auth during mail transaction (#5.5.0)\r\n"); } int err_noauth() { out("504 auth type unimplemented (#5.5.1)\r\n"); return -1; } int err_authabrt() { out("501 auth exchange cancelled (#5.0.0)\r\n"); return -1; } @@ -233,6 +234,7 @@ int flagbarf; /* defined if seenmail */ stralloc mailfrom = {0}; stralloc rcptto = {0}; +int authd = 0; void smtp_helo(arg) char *arg; { @@ -259,6 +261,7 @@ } void smtp_mail(arg) char *arg; { + if (!authd) { err_notauthd(); return; } if (!addrparse(arg)) { err_syntax(); return; } flagbarf = bmfcheck(); seenmail = 1; @@ -268,6 +271,7 @@ out("250 ok\r\n"); } void smtp_rcpt(arg) char *arg; { + if (!authd) { err_notauthd(); return; } if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } if (flagbarf) { err_bmf(); return; } @@ -390,6 +394,7 @@ unsigned long qp; char *qqx; + if (!authd) { err_notauthd(); return; } if (!seenmail) { err_wantmail(); return; } if (!rcptto.len) { err_wantrcpt(); return; } seenmail = 0; @@ -425,7 +430,6 @@ char **childargs; substdio ssup; char upbuf[128]; -int authd = 0; int authgetl(void) { int i; @@ -648,6 +652,8 @@ { hostname = argv[1]; childargs = argv + 2; + + if (!hostname || !*childargs) { authd = 1; } sig_pipeignore(); if (chdir(auto_qmail) == -1) die_control();