Below is a very simple patch to tcpserver that lets it run the program
specified in the environment variable PROG rather than the one named on the
command line. I vaguely recall the idea of doing this coming up on the list
several months ago, but I can't find the thread now.
The idea is that you could run, for example, ofmipd for your internal clients
and qmail-smtpd for the rest of the world by specifying
PROG="/usr/local/bin/ofmipd" in the appropriate place in your tcprules file.
You might also run a shell script that pipes fixcr through qmail-smtpd for
hosts that are sending mail with bare linefeeds (which is what prompted me to
do it).
The patched tcpserver is somewhat deficient in that it runs PROG with the same
arguments as the program named on the command line, but for the purposes above
this doesn't matter.
Can anyone see anything terribly wrong with doing this?
Chris
--- tcpserver.c.orig Thu Nov 12 00:32:01 1998
+++ tcpserver.c Fri Mar 26 09:42:50 1999
@@ -263,6 +263,7 @@
int opt;
char *hostname;
char *portname;
+ char *x;
struct servent *se;
int j;
@@ -497,6 +498,7 @@
sig_childunblock();
sig_termdefault();
sig_pipedefault();
+ if (x = env_get("PROG")) *argv = x;
execvp(*argv,argv);
if (verbosity) strerr_warn4(DROP,"unable to run ",*argv,": ",&strerr_sys);
_exit(111);