This is not _the_ QMAILQUEUE patch by Bruce Guenter that's included in
netqmail. When you want qmail-smtpd(8), for instance, to be able to
modify or reject incoming messages by inserting a wrapper around
qmail-queue(8), _the_ QMAILQUEUE patch makes that easier.

The mess822-QMAILQUEUE patch is the exact same idea (and code), but
for mess822.

If `QMAILQUEUE` is set in the environment, `ofmipd(8)` (and
`new-inject(1)`) run that program in place of `qmail-queue`, allowing
you to modify submitted messages in arbitrary ways, above and beyond
`mess822`'s own rewriting features.

Your wrapper needs to adhere to the `qmail-queue(8)` interface, and
should probably conclude its work by running the real `qmail-queue`
binary, which -- since you're applying this patch -- can stay right
where it is.

With _the_ QMAILQUEUE patch, rather than write your own wrapper, I'd
suggest using Bruce Guenter's `qmail-qfilter` and writing your own
filters. With this mess822-QMAILQUEUE patch, I suggest the same.

To set `QMAILQUEUE` in `ofmipd`'s environment:

1. Find your `ofmipd(8)` invocation.
2. If it doesn't already call `env(1)` to clear the environment, add that.
3. Look for where `env` is called, and pass `QMAILQUEUE=/path/to/your-wrapper-program-here` to it.
4. Restart your `ofmipd` service.

If you're using qmail-run from pkgsrc, that's as easy as:

1. `echo "qmailofmipd_postenv='QMAILQUEUE=/path/to/your-wrapper-program-here'" >> /etc/rc.conf`
2. `/etc/rc.d/qmailofmipd restart`


--- qmail.c.orig	1998-09-05 02:33:37.000000000 +0000
+++ qmail.c
@@ -6,8 +6,17 @@
 #include "fd.h"
 #include "qmail.h"
 #include "auto_qmail.h"
+#include "env.h"
 
-static char *binqqargs[2] = { "bin/qmail-queue", 0 } ;
+static char *binqqargs[2] = { 0, 0 } ;
+
+static void setup_qqargs()
+{
+  if(!binqqargs[0])
+    binqqargs[0] = env_get("QMAILQUEUE");
+  if(!binqqargs[0])
+    binqqargs[0] = "bin/qmail-queue";
+}
 
 int qmail_open(qq)
 struct qmail *qq;
@@ -15,6 +24,8 @@ struct qmail *qq;
   int pim[2];
   int pie[2];
 
+  setup_qqargs();
+
   if (pipe(pim) == -1) return -1;
   if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; }
  
