- Bernhard Duebi <[EMAIL PROTECTED]>:

| I use qmail on my Internet Mail Gateways and it works fine. Now I
| want to integrate a virus scanner into qmail.

| I though of having 2 qmail instances. The first sends all incoming
| mail to the virus scanner. The virus scanner then invokes the second
| qmail instance, which routes the mail to the receipient. But, this
| means I have to support 2 different configurations of qmail.

That is not really a great burden, since one of the two will most
likely have a very simple setup.  Another approach is to add a
NORELAYCLIENT environment variable to qmail-smtpd.  (Someone suggested
that recently on this list.)  It would have the same effect as
RELAYCLIENT (prepending a string to the incoming mail address), but
without turning off the rcpthosts check.

Then, just have your tcpcontrol file contain

:allow,NORELAYCLIENT='virus.check'

and the virtualdomains file contain

virus.check:alias-viruscheck

and set up ~alias/.qmail-viruscheck-default with something like

|do-check-for-virus | forward "$DEFAULT"

If you want locally generated, outgoing mail to pass through the virus
checker too, use the fact that virtually all user generated mail
passes through qmail-inject.  So replace qmail-inject with a program
which passes its stdin through the virus checker, then pipes the
output into the real qmail-inject (with the same arguments of course).

| And what about bounces ?

Locally generated bounces do not pass through qmail-inject, so they
won't be affected.  Remotely generated bounces will of course be
subject to virus checking as they come in.

Fixing qmail-smtpd.c to allow the NORELAYCLIENT variable is no sweat.
I include an untested patch below.

- Harald

--- qmail-smtpd.c.orig  Mon Jun 15 12:53:16 1998
+++ qmail-smtpd.c       Fri Mar  5 20:13:32 1999
@@ -81,6 +81,7 @@
 char *remoteinfo;
 char *local;
 char *relayclient;
+int norelay = 1;
 
 stralloc helohost = {0};
 char *fakehelo; /* pointer into helohost, or 0 */
@@ -130,7 +131,10 @@
   remotehost = env_get("TCPREMOTEHOST");
   if (!remotehost) remotehost = "unknown";
   remoteinfo = env_get("TCPREMOTEINFO");
-  relayclient = env_get("RELAYCLIENT");
+  relayclient = env_get("NORELAYCLIENT");
+  if (!relayclient) {
+    relayclient = env_get("RELAYCLIENT");
+    if (relayclient) norelay = 0; }
   dohelo(remotehost);
 }
 
@@ -256,7 +260,7 @@
     if (!stralloc_cats(&addr,relayclient)) die_nomem();
     if (!stralloc_0(&addr)) die_nomem();
   }
-  else
+  if (norelay)
     if (!addrallowed()) { err_nogateway(); return; }
   if (!stralloc_cats(&rcptto,"T")) die_nomem();
   if (!stralloc_cats(&rcptto,addr.s)) die_nomem();

Reply via email to