-----BEGIN PGP SIGNED MESSAGE-----
Hi,
Recently modified qmail-inject.c to perform address rewriting. This
allows to get all To:, From: etc. into our standard format. Thought others
may be interested. Anyone who knows qmail-inject inside out (Dan?) care to
comment on it? Cheers. (There's still some diagnostics in this version,
but you get the idea.) (Sorry about the comments, Dan :-)
- ------
diff -c qmail-1.00.orig/qmail-inject.c qmail-1.00/qmail-inject.c
*** qmail-1.00.orig/qmail-inject.c Thu Feb 20 07:07:24 1997
- --- qmail-1.00/qmail-inject.c Tue Mar 18 14:13:47 1997
***************
*** 21,26 ****
- --- 21,27 ----
#include "exit.h"
#include "quote.h"
#include "headerbody.h"
+ #include "cdb.h"
#define LINELEN 80
***************
*** 254,259 ****
- --- 255,309 ----
addr->t[i] = defaultdomain.t[shift - 1 - i];
}
+ stralloc tempsa = {0};
+ stralloc tempsabuf = {0};
+ token822_alloc tempaddr = {0};
+ int usersfd;
+
+ void salf_rw(addr)
+ token822_alloc *addr;
+ {
+ char buf[LINELEN + 2];
+ uint32 dlen, p;
+
+ /* reverse addr array */
+ token822_reverse(addr);
+
+ /* convert addr array back to string */
+ if (token822_unparse(&tempsa, addr, LINELEN) != 1) die_nomem();
+
+ /* lower-case the string */
+ for (p = 0; p < tempsa.len - 1; p++)
+ tempsa.s[p] = tolower(tempsa.s[p]);
+
+ strncpy(buf, tempsa.s, tempsa.len);
+ buf[tempsa.len] = '\0';
+ printf("%s", buf);
+
+ /* see if we can find it in the database */
+ if (tempsa.len >= 2 && cdb_seek(usersfd, tempsa.s, tempsa.len - 1, &dlen)) {
+
+ /* if so check we can read the value okay */
+ if (dlen <= sizeof buf && read(usersfd, buf, dlen) == dlen) {
+
+ buf[dlen] = '\0';
+ printf("Matched with : %s\n", buf);
+ /* resize the allocated space for string and copy new string over it */
+ if (stralloc_ready(&tempsa, dlen + 1)) {
+ strncpy(tempsa.s, buf, dlen);
+ tempsa.s[dlen] = '\n';
+ tempsa.len = dlen + 1;
+
+ /* parse string back into addr array */
+ token822_parse(addr, &tempsa, &tempsabuf);
+ }
+ }
+ }
+
+ /* reverse addr array */
+ token822_reverse(addr);
+ }
+
void rwplus(addr)
token822_alloc *addr;
{
***************
*** 293,298 ****
- --- 343,349 ----
rwnoat(addr);
rwplus(addr);
rwnodot(addr);
+ salf_rw(addr);
}
int setreturn(addr)
***************
*** 652,657 ****
- --- 703,710 ----
int recipstrategy;
signal_init();
+
+ usersfd = open_read("/var/qmail/rewrite/compiled");
starttime = now();
diff -c qmail-1.00.orig/Makefile qmail-1.00/Makefile
*** qmail-1.00.orig/Makefile Thu Feb 20 07:07:24 1997
- --- qmail-1.00/Makefile Tue Mar 11 10:42:12 1997
***************
*** 965,978 ****
qmail-inject.o hfield.o newfield.o datetime.o date822fmt.o now.o \
signal.o quote.o token822.o control.o libopen.a headerbody.o qqtalk.o \
libwait.a libenv.a libgetopt.a libgetline.a libsubstdio.a \
! libstralloc.a liballoc.a liberror.a libstr.a libfs.a libfd.a load
./load qmail-inject hfield.o newfield.o datetime.o \
date822fmt.o now.o signal.o quote.o token822.o control.o \
headerbody.o qqtalk.o libenv.a libgetopt.a libgetline.a \
libfd.a \
libwait.a \
libopen.a \
! libsubstdio.a libstralloc.a liballoc.a liberror.a libstr.a libfs.a
qmail-inject.0: \
qmail-inject.8
- --- 965,978 ----
qmail-inject.o hfield.o newfield.o datetime.o date822fmt.o now.o \
signal.o quote.o token822.o control.o libopen.a headerbody.o qqtalk.o \
libwait.a libenv.a libgetopt.a libgetline.a libsubstdio.a \
! libstralloc.a liballoc.a liberror.a libstr.a libfs.a libfd.a load libcdb.a
./load qmail-inject hfield.o newfield.o datetime.o \
date822fmt.o now.o signal.o quote.o token822.o control.o \
headerbody.o qqtalk.o libenv.a libgetopt.a libgetline.a \
libfd.a \
libwait.a \
libopen.a \
! libsubstdio.a libstralloc.a liballoc.a liberror.a libstr.a libfs.a libcdb.a
qmail-inject.0: \
qmail-inject.8
***************
*** 983,989 ****
error.h sgetopt.h stralloc.h now.h gen_alloc.h exit.h subfd.h \
newfield.h quote.h headerbody.h token822.h qqtalk.h alloc.h \
conf-home.h getline.h fmt.h str.h subgetopt.h gen_allocdefs.h \
! datetime.h
./compile qmail-inject.c
qmail-limits.0: \
- --- 983,989 ----
error.h sgetopt.h stralloc.h now.h gen_alloc.h exit.h subfd.h \
newfield.h quote.h headerbody.h token822.h qqtalk.h alloc.h \
conf-home.h getline.h fmt.h str.h subgetopt.h gen_allocdefs.h \
! datetime.h cdb.h uint32.h
./compile qmail-inject.c
qmail-limits.0: \
- ------
Mark Powell - Unix Information Officer - Clifford Whitworth Building
A.I.S., University of Salford, Salford, Manchester, UK.
Tel: +44 161 745 5936 Fax: +44 161 736 3596
Email: mark@salford.ac.uk finger mark@ucsalf.ac.uk (for PGP key)
<A HREF="http://www.ucsalf.ac.uk/~mark/">Home Page</A>
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
iQCVAwUBMy6ls1M87iaKBL59AQGjggP+JpsseeY8uLt6WL/U0LStLvSp3GxOiO3Y
GUwApsjEu4+6f0zTRhvVt4ala/zc5N/7JqLhrJiK4E4+3+dS0NZJwyHH1UJa3I9t
e9393u3ygahzXYzhQqpueFe0DV8/m70eAXMH3Bry5KYTou7zuT2k2nSkPQOHCxLO
UckOGYz5qzc=
=Pyk6
-----END PGP SIGNATURE-----
Hi,
Recently modified qmail-inject.c to perform address rewriting. This
allows to get all To:, From: etc. into our standard format. Thought others
may be interested. Anyone who knows qmail-inject inside out (Dan?) care to
comment on it? Cheers. (There's still some diagnostics in this version,
but you get the idea.) (Sorry about the comments, Dan :-)
- ------
diff -c qmail-1.00.orig/qmail-inject.c qmail-1.00/qmail-inject.c
*** qmail-1.00.orig/qmail-inject.c Thu Feb 20 07:07:24 1997
- --- qmail-1.00/qmail-inject.c Tue Mar 18 14:13:47 1997
***************
*** 21,26 ****
- --- 21,27 ----
#include "exit.h"
#include "quote.h"
#include "headerbody.h"
+ #include "cdb.h"
#define LINELEN 80
***************
*** 254,259 ****
- --- 255,309 ----
addr->t[i] = defaultdomain.t[shift - 1 - i];
}
+ stralloc tempsa = {0};
+ stralloc tempsabuf = {0};
+ token822_alloc tempaddr = {0};
+ int usersfd;
+
+ void salf_rw(addr)
+ token822_alloc *addr;
+ {
+ char buf[LINELEN + 2];
+ uint32 dlen, p;
+
+ /* reverse addr array */
+ token822_reverse(addr);
+
+ /* convert addr array back to string */
+ if (token822_unparse(&tempsa, addr, LINELEN) != 1) die_nomem();
+
+ /* lower-case the string */
+ for (p = 0; p < tempsa.len - 1; p++)
+ tempsa.s[p] = tolower(tempsa.s[p]);
+
+ strncpy(buf, tempsa.s, tempsa.len);
+ buf[tempsa.len] = '\0';
+ printf("%s", buf);
+
+ /* see if we can find it in the database */
+ if (tempsa.len >= 2 && cdb_seek(usersfd, tempsa.s, tempsa.len - 1, &dlen)) {
+
+ /* if so check we can read the value okay */
+ if (dlen <= sizeof buf && read(usersfd, buf, dlen) == dlen) {
+
+ buf[dlen] = '\0';
+ printf("Matched with : %s\n", buf);
+ /* resize the allocated space for string and copy new string over it */
+ if (stralloc_ready(&tempsa, dlen + 1)) {
+ strncpy(tempsa.s, buf, dlen);
+ tempsa.s[dlen] = '\n';
+ tempsa.len = dlen + 1;
+
+ /* parse string back into addr array */
+ token822_parse(addr, &tempsa, &tempsabuf);
+ }
+ }
+ }
+
+ /* reverse addr array */
+ token822_reverse(addr);
+ }
+
void rwplus(addr)
token822_alloc *addr;
{
***************
*** 293,298 ****
- --- 343,349 ----
rwnoat(addr);
rwplus(addr);
rwnodot(addr);
+ salf_rw(addr);
}
int setreturn(addr)
***************
*** 652,657 ****
- --- 703,710 ----
int recipstrategy;
signal_init();
+
+ usersfd = open_read("/var/qmail/rewrite/compiled");
starttime = now();
diff -c qmail-1.00.orig/Makefile qmail-1.00/Makefile
*** qmail-1.00.orig/Makefile Thu Feb 20 07:07:24 1997
- --- qmail-1.00/Makefile Tue Mar 11 10:42:12 1997
***************
*** 965,978 ****
qmail-inject.o hfield.o newfield.o datetime.o date822fmt.o now.o \
signal.o quote.o token822.o control.o libopen.a headerbody.o qqtalk.o \
libwait.a libenv.a libgetopt.a libgetline.a libsubstdio.a \
! libstralloc.a liballoc.a liberror.a libstr.a libfs.a libfd.a load
./load qmail-inject hfield.o newfield.o datetime.o \
date822fmt.o now.o signal.o quote.o token822.o control.o \
headerbody.o qqtalk.o libenv.a libgetopt.a libgetline.a \
libfd.a \
libwait.a \
libopen.a \
! libsubstdio.a libstralloc.a liballoc.a liberror.a libstr.a libfs.a
qmail-inject.0: \
qmail-inject.8
- --- 965,978 ----
qmail-inject.o hfield.o newfield.o datetime.o date822fmt.o now.o \
signal.o quote.o token822.o control.o libopen.a headerbody.o qqtalk.o \
libwait.a libenv.a libgetopt.a libgetline.a libsubstdio.a \
! libstralloc.a liballoc.a liberror.a libstr.a libfs.a libfd.a load libcdb.a
./load qmail-inject hfield.o newfield.o datetime.o \
date822fmt.o now.o signal.o quote.o token822.o control.o \
headerbody.o qqtalk.o libenv.a libgetopt.a libgetline.a \
libfd.a \
libwait.a \
libopen.a \
! libsubstdio.a libstralloc.a liballoc.a liberror.a libstr.a libfs.a libcdb.a
qmail-inject.0: \
qmail-inject.8
***************
*** 983,989 ****
error.h sgetopt.h stralloc.h now.h gen_alloc.h exit.h subfd.h \
newfield.h quote.h headerbody.h token822.h qqtalk.h alloc.h \
conf-home.h getline.h fmt.h str.h subgetopt.h gen_allocdefs.h \
! datetime.h
./compile qmail-inject.c
qmail-limits.0: \
- --- 983,989 ----
error.h sgetopt.h stralloc.h now.h gen_alloc.h exit.h subfd.h \
newfield.h quote.h headerbody.h token822.h qqtalk.h alloc.h \
conf-home.h getline.h fmt.h str.h subgetopt.h gen_allocdefs.h \
! datetime.h cdb.h uint32.h
./compile qmail-inject.c
qmail-limits.0: \
- ------
Mark Powell - Unix Information Officer - Clifford Whitworth Building
A.I.S., University of Salford, Salford, Manchester, UK.
Tel: +44 161 745 5936 Fax: +44 161 736 3596
Email: mark@salford.ac.uk finger mark@ucsalf.ac.uk (for PGP key)
<A HREF="http://www.ucsalf.ac.uk/~mark/">Home Page</A>
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
iQCVAwUBMy6ls1M87iaKBL59AQGjggP+JpsseeY8uLt6WL/U0LStLvSp3GxOiO3Y
GUwApsjEu4+6f0zTRhvVt4ala/zc5N/7JqLhrJiK4E4+3+dS0NZJwyHH1UJa3I9t
e9393u3ygahzXYzhQqpueFe0DV8/m70eAXMH3Bry5KYTou7zuT2k2nSkPQOHCxLO
UckOGYz5qzc=
=Pyk6
-----END PGP SIGNATURE-----