A friend wants to DKIM-sign outgoing mail, probably using Kyle Wheeler's
DKIM wrapper around qmail-remote
(http://www.memoryhole.net/qmail/#dkim). But he doesn't want to confuse
his package manager by moving aside the real qmail-remote binary and
putting something else in its place.
Inspired by the QMAILQUEUE patch, we patched qmail-rspawn to look for
QMAILREMOTE in its environment. The 0th arg to execvp() is either the
value of the env var (if set), or "qmail-remote" as usual. We tested
with various arguments to qmail-start.
When QMAILREMOTE is not set:
May 21 08:13:29 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: success:
166.84.7.144_accepted_message./Remote_host_said:_250_ok_1495368789_qp_3818/
When QMAILREMOTE is set to an empty string, or a non-empty path (full or
unqualified) of a program that does not exist:
May 21 08:16:34 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: failure: Unable_to_run_qmail-remote./
When QMAILREMOTE is set to /var/tmp/schmonz (a shell script that runs
'exec qmail-remote "$@"'):
May 21 08:22:19 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: success:
166.84.7.144_accepted_message./Remote_host_said:_250_ok_1495369319_qp_19267/
Does this patch look reasonable?
--- Makefile.orig 2007-11-30 20:22:54.000000000 +0000
+++ Makefile
@@ -1462,19 +1462,19 @@ tcpto.h readwrite.h timeoutconn.h timeou
qmail-rspawn: \
load qmail-rspawn.o spawn.o tcpto_clean.o now.o coe.o sig.a open.a \
-seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a str.a \
+seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a env.a
str.a \
auto_qmail.o auto_uids.o auto_spawn.o
./load qmail-rspawn spawn.o tcpto_clean.o now.o coe.o \
sig.a open.a seek.a lock.a wait.a fd.a stralloc.a alloc.a \
- substdio.a error.a str.a auto_qmail.o auto_uids.o \
- auto_spawn.o
+ substdio.a error.a env.a str.a auto_qmail.o auto_uids.o \
+ auto_spawn.o
qmail-rspawn.0: \
qmail-rspawn.8
nroff -man qmail-rspawn.8 > qmail-rspawn.0
qmail-rspawn.o: \
-compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h \
+compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h
env.h \
tcpto.h
./compile qmail-rspawn.c
--- qmail-rspawn.c.orig 1998-06-15 10:53:16.000000000 +0000
+++ qmail-rspawn.c
@@ -5,6 +5,17 @@
#include "fork.h"
#include "error.h"
#include "tcpto.h"
+#include "env.h"
+
+static char *qrargs[1] = { 0 };
+
+static void setup_qrargs()
+{
+ if (!qrargs[0])
+ qrargs[0] = env_get("QMAILREMOTE");
+ if(!qrargs[0])
+ qrargs[0] = "qmail-remote";
+}
void initialize(argc,argv)
int argc;
@@ -84,7 +95,9 @@ char *s; char *r; int at;
int f;
char *(args[5]);
- args[0] = "qmail-remote";
+ setup_qrargs();
+
+ args[0] = qrargs[0];
args[1] = r + at + 1;
args[2] = s;
args[3] = r;
DKIM wrapper around qmail-remote
(http://www.memoryhole.net/qmail/#dkim). But he doesn't want to confuse
his package manager by moving aside the real qmail-remote binary and
putting something else in its place.
Inspired by the QMAILQUEUE patch, we patched qmail-rspawn to look for
QMAILREMOTE in its environment. The 0th arg to execvp() is either the
value of the env var (if set), or "qmail-remote" as usual. We tested
with various arguments to qmail-start.
When QMAILREMOTE is not set:
May 21 08:13:29 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: success:
166.84.7.144_accepted_message./Remote_host_said:_250_ok_1495368789_qp_3818/
When QMAILREMOTE is set to an empty string, or a non-empty path (full or
unqualified) of a program that does not exist:
May 21 08:16:34 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: failure: Unable_to_run_qmail-remote./
When QMAILREMOTE is set to /var/tmp/schmonz (a shell script that runs
'exec qmail-remote "$@"'):
May 21 08:22:19 magnetic-babysitter-netbsd7 nbqmailsend: delivery
1: success:
166.84.7.144_accepted_message./Remote_host_said:_250_ok_1495369319_qp_19267/
Does this patch look reasonable?
--- Makefile.orig 2007-11-30 20:22:54.000000000 +0000
+++ Makefile
@@ -1462,19 +1462,19 @@ tcpto.h readwrite.h timeoutconn.h timeou
qmail-rspawn: \
load qmail-rspawn.o spawn.o tcpto_clean.o now.o coe.o sig.a open.a \
-seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a str.a \
+seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a env.a
str.a \
auto_qmail.o auto_uids.o auto_spawn.o
./load qmail-rspawn spawn.o tcpto_clean.o now.o coe.o \
sig.a open.a seek.a lock.a wait.a fd.a stralloc.a alloc.a \
- substdio.a error.a str.a auto_qmail.o auto_uids.o \
- auto_spawn.o
+ substdio.a error.a env.a str.a auto_qmail.o auto_uids.o \
+ auto_spawn.o
qmail-rspawn.0: \
qmail-rspawn.8
nroff -man qmail-rspawn.8 > qmail-rspawn.0
qmail-rspawn.o: \
-compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h \
+compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h
env.h \
tcpto.h
./compile qmail-rspawn.c
--- qmail-rspawn.c.orig 1998-06-15 10:53:16.000000000 +0000
+++ qmail-rspawn.c
@@ -5,6 +5,17 @@
#include "fork.h"
#include "error.h"
#include "tcpto.h"
+#include "env.h"
+
+static char *qrargs[1] = { 0 };
+
+static void setup_qrargs()
+{
+ if (!qrargs[0])
+ qrargs[0] = env_get("QMAILREMOTE");
+ if(!qrargs[0])
+ qrargs[0] = "qmail-remote";
+}
void initialize(argc,argv)
int argc;
@@ -84,7 +95,9 @@ char *s; char *r; int at;
int f;
char *(args[5]);
- args[0] = "qmail-remote";
+ setup_qrargs();
+
+ args[0] = qrargs[0];
args[1] = r + at + 1;
args[2] = s;
args[3] = r;