this qmail-1.03.originip-field.patch v2006062201 modifies qmail-queue to put X-Originating-IP: 10.0.0.1 in the header of messages if TCPREMOTEIP is set. See http://marc.theaimsgroup.com/?l=qmail&m=115092235402886&w=2 Applies clean to qmail-1.03 and netqmail-1.05 Use: follow instructions at http://www.lifewithqmail.org, except in section 2.5.2, after doing "./collate.sh", do: wget http://jeremy.kister.net/code/qmail-1.03.originip-field.patch patch -d netqmail-1.05 < qmail-1.03.originip-field.patch -- Jeremy Kister http://jeremy.kister.net./ ##################################################################### --- ../qmail-1.03/Makefile 2006-06-22 03:26:07.946715000 -0400 +++ Makefile 2006-06-22 03:25:49.636640000 -0400 @@ -1421,11 +1421,11 @@ qmail-queue: \ load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \ datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \ -str.a fs.a auto_qmail.o auto_split.o auto_uids.o +fs.a auto_qmail.o auto_split.o auto_uids.o env.a str.a ./load qmail-queue triggerpull.o fmtqfn.o now.o \ date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \ - alloc.a substdio.a error.a str.a fs.a auto_qmail.o \ - auto_split.o auto_uids.o + alloc.a substdio.a error.a fs.a auto_qmail.o \ + auto_split.o auto_uids.o env.a str.a qmail-queue.0: \ qmail-queue.8 @@ -1434,7 +1434,7 @@ qmail-queue.o: \ compile qmail-queue.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ -auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h +auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h env.h ./compile qmail-queue.c qmail-remote: \ --- ../qmail-1.03/qmail-queue.c 1998-06-15 06:53:16.000000000 -0400 +++ qmail-queue.c 2006-06-22 03:25:50.066606000 -0400 @@ -16,6 +16,7 @@ #include "auto_uids.h" #include "date822fmt.h" #include "fmtqfn.h" +#include "env.h" #define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */ #define ADDR 1003 @@ -39,6 +40,7 @@ int intdfd; int flagmademess = 0; int flagmadeintd = 0; +char *remoteip; void cleanup() { @@ -61,8 +63,11 @@ void sigbug() { die(81); } unsigned int receivedlen; -char *received; +unsigned int originlen; /* "Received: (qmail-queue invoked by alias); 26 Sep 1995 04:46:54 -0000\n" */ +char *received; +char *origin; +/* "X-Originating-IP: 10.0.0.1\n" */ static unsigned int receivedfmt(s) char *s; @@ -97,6 +102,27 @@ receivedfmt(received); } +static unsigned int originfmt(s) +char *s; +{ + unsigned int i; + unsigned int len; + len = 0; + i = fmt_str(s,"X-Originating-IP: "); len += i; if (s) s += i; + i = fmt_str(s,remoteip); len += i; if (s) s += i; + i = fmt_str(s,"\n"); len += i; if (s) s += i; + + return len; +} + +void origin_setup() +{ + originlen = originfmt((char *) 0); + origin = alloc(originlen + 1); + if (!origin) die(51); + originfmt(origin); +} + unsigned int pidfmt(s,seq) char *s; unsigned long seq; @@ -192,6 +218,12 @@ if (substdio_bput(&ssout,received,receivedlen) == -1) die_write(); + remoteip = env_get("TCPREMOTEIP"); + if(remoteip) { + origin_setup(); + if (substdio_bput(&ssout,origin,originlen) == -1) die_write(); + } + switch(substdio_copy(&ssout,&ssin)) { case -2: die_read();