[Greylist-users] qmail implementation - correct this time, I hope

Tony Arcieri tarcieri at atmos.colostate.edu
Wed Jun 25 15:56:22 PDT 2003


Third time's the charm, right?

In the previous two patches the env_scanner() statement was not in the
smtp_rcpt() block.  I've corrected that in this patch.  Please let me
know... all my qmail systems here are production and I don't have a spare
system to actually do any testing on, unfortunately.

Tony Arcieri
-------------- next part --------------
--- qmail-1.03/qmail-smtpd.c	Mon Jun 15 04:53:16 1998
+++ qmail-1.03-scanenv/qmail-smtpd.c	Wed Jun 25 14:52:47 2003
@@ -19,6 +19,8 @@
 #include "env.h"
 #include "now.h"
 #include "exit.h"
+#include "fork.h"
+#include "wait.h"
 #include "rcpthosts.h"
 #include "timeoutread.h"
 #include "timeoutwrite.h"
@@ -45,10 +47,12 @@
 void die_read() { _exit(1); }
 void die_alarm() { out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); }
 void die_nomem() { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); }
+void die_tempfail() { out("421 temporary envelope failure (#4.3.0)\r\n"); flush(); _exit(1); } 
 void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }
 void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
 void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); }
 
+void err_permfail() { out("553 permanent envelope failure (#5.7.1)\r\n"); }
 void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }
 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"); }
@@ -222,6 +226,32 @@
 stralloc mailfrom = {0};
 stralloc rcptto = {0};
 
+int env_scanner()
+{
+  int child;
+  int wstat;
+  char *env_scannerarg[] = { "bin/qmail-env-scanner", mailfrom.s, addr.s, 0 };
+  
+  switch(child = vfork()) {
+    case -1:
+      return 0;
+    case 0:
+      execv(*env_scannerarg,env_scannerarg);
+      return 0;
+  }
+
+  wait_pid(&wstat,child);
+  if (wait_crashed(wstat)) return 0;
+  switch(wait_exitcode(wstat)) {
+    case 100:
+      die_tempfail();
+    case 101:
+      return 0;
+    default:
+      return 1;
+  }
+}
+
 void smtp_helo(arg) char *arg;
 {
   smtp_greet("250 "); out("\r\n");
@@ -261,6 +291,7 @@
   if (!stralloc_cats(&rcptto,"T")) die_nomem();
   if (!stralloc_cats(&rcptto,addr.s)) die_nomem();
   if (!stralloc_0(&rcptto)) die_nomem();
+  if(!env_scanner()) { err_permfail(); return; }
   out("250 ok\r\n");
 }
 


More information about the Greylist-users mailing list