[Mimedefang] PATCH: -X option to inhibit X-Scanned-By header

James Ralston qralston+ml.mimedefang at andrew.cmu.edu
Wed Apr 2 20:29:00 EST 2003


I've been testing out MIMEDefang for the past few weeks.  Right now,
I'm only using MIMEDefang to run incoming messages through
SpamAssassin, but so far, MIMEDefang is working great.  My thanks to
Roaring Penguin for this beautiful little piece of software.

Attached is a patch against mimedefang-2.31.  It adds a -X option, to
inhibit adding the X-Scanned-By header.  Previously, inhibiting the
X-Scanned-By header could be accomplished by supplying a zero-length
string to the -x option, but the shell quoting hoops that required in
startup scripts were torturous.

I tried to update all of the docs, init scripts, etc. with this patch,
but I might have missed something.  If so, let me know.

Note that it is *not* my intent to encourage people to prevent
MIMEDefang from inserting plugs for itself and Roaring Penguin.  It's
just that in some cases, it's desirable to have MIMEDefang keep a "low
profile".  Since the topic has come up before on this list, I simply
thought I'd share the patch.

Regards,

-- 
James Ralston, Information Technology
Software Engineering Institute
Carnegie Mellon University, Pittsburgh, PA, USA
-------------- next part --------------
--- mimedefang-2.31/redhat/mimedefang-init.x-scanned-by	2003-03-05 10:30:28.000000000 -0500
+++ mimedefang-2.31/redhat/mimedefang-init	2003-04-02 19:12:54.000000000 -0500
@@ -179,6 +179,8 @@
 	$([ "$MULTIPLEXOR" = "yes" -a "$MX_RELAY_CHECK" = "yes" ] && echo "-r") \
 	$([ "$MULTIPLEXOR" = "yes" -a "$MX_SENDER_CHECK" = "yes" ] && echo "-s") \
 	$([ "$MULTIPLEXOR" = "yes" -a "$MX_RECIPIENT_CHECK" = "yes" ] && echo "-t") \
+	$([ "$HEADER_TEXT" ] && echo "-x '${HEADER_TEXT}'") \
+	$([ "$INHIBIT_HEADER" = "yes" ] && echo "-X") \
 	$([ "$KEEP_FAILED_DIRECTORIES" = "yes" ] && echo "-k") \
 	-p $SOCKET
     RETVAL=$?
--- mimedefang-2.31/redhat/mimedefang-sysconfig.x-scanned-by	2003-03-05 10:30:28.000000000 -0500
+++ mimedefang-2.31/redhat/mimedefang-sysconfig	2003-04-02 19:12:54.000000000 -0500
@@ -83,6 +83,17 @@
 # uncomment the next line
 # LOG_FILTER_TIME=yes
 
+# If you want to override the default string that mimedefang uses for
+# the X-Scanned-By: header (which is added to every message that
+# mimedefang processes), uncomment and set the HEADER_TEXT line.
+# WARNING: don't use the apostrophe character ("'"; ASCII value 39) in
+# your HEADER_TEXT string, or else the init.d script will mis-parse it.
+# HEADER_TEXT="MIMEDefang (www . roaringpenguin . com / mimedefang)"
+
+# If you want to inhibit mimedefang from adding the X-Scanned-By:
+# header to the messages it processes, uncomment the next line.
+# INHIBIT_HEADER=yes
+
 # Run the multiplexor and filters as this user, not root.  RECOMMENDED
 MX_USER=defang
 
--- mimedefang-2.31/mimedefang.8.in.x-scanned-by	2003-02-10 13:21:17.000000000 -0500
+++ mimedefang-2.31/mimedefang.8.in	2003-04-02 19:12:54.000000000 -0500
@@ -120,9 +120,17 @@
 
 .TP
 .B \-x \fIstring\fR
-Add \fIstring\fR as the content of the X-Scanned-By: header.  If you
-set \fIstring\fR to the empty string (i.e. \-x ""), then no X-Scanned-By:
-header will be added.
+Causes \fBmimedefang\fR to use \fIstring\fR for the value of the
+X-Scanned-By: header which is added to every message during
+processing.  If the \-x option is not used, \fBmimedefang\fR
+constructs a default string which consists of information about the
+version of \fBmimedefang\fR which is being used.
+
+.TP
+.B \-X
+Causes \fBmimedefang\fR to refrain from adding the X-Scanned-By:
+header.  (Note that the \-x option will have no effect if the \-X
+option is used.)
 
 .TP
 .B \-M
--- mimedefang-2.31/mimedefang.c.x-scanned-by	2003-03-17 09:12:08.000000000 -0500
+++ mimedefang-2.31/mimedefang.c	2003-04-02 19:13:07.000000000 -0500
@@ -176,6 +176,9 @@
 /* Protect mkdir() with mutex? */
 static int protectMkdirWithMutex = 0;
 
+/* Inhibit adding the X-Scanned-By header? */
+static int inhibitHeader = 0;
+
 #ifdef ENABLE_DEBUGGING
 /**********************************************************************
 *%FUNCTION: handle_sig
@@ -839,7 +842,7 @@
     }
 
     /* Check for existing identical X-Scanned-By: header */
-    if (scan_body && *scan_body) {
+    if (!inhibitHeader && scan_body && *scan_body) {
 	if (!strcasecmp(headerf, "X-Scanned-By") &&
 	    !strcasecmp(headerv, scan_body)) {
 	    data->headerPresent = 1;
@@ -1265,7 +1268,7 @@
 
     fclose(fp);
 
-    if (!data->headerPresent) {
+    if (!inhibitHeader && !data->headerPresent) {
 	if (scan_body && *scan_body) {
 	    smfi_addheader(ctx, "X-Scanned-By", scan_body);
 	}
@@ -1492,7 +1495,8 @@
     fprintf(stderr, "  -t                -- Do recipient checks before processing body (requires -m)\n");
     fprintf(stderr, "  -P file           -- Write process-ID of daemon to specified file\n");
     fprintf(stderr, "  -T                -- Log filter times to syslog\n");
-    fprintf(stderr, "  -x string         -- Add string as X-Scanned-By header\n");
+    fprintf(stderr, "  -x string         -- Use string for value of X-Scanned-By header\n");
+    fprintf(stderr, "  -X                -- Inhibit adding the X-Scanned-By header\n");
     fprintf(stderr, "  -M                -- Protect mkdir with mutex\n");
     exit(EXIT_FAILURE);
 }
@@ -1534,8 +1538,11 @@
     }
 
     /* Process command line options */
-    while ((c = getopt(argc, argv, "hn:p:dm:f:srtkP:F:U:Tx:M")) != -1) {
+    while ((c = getopt(argc, argv, "hn:p:dm:f:srtkP:F:U:Tx:MX")) != -1) {
 	switch (c) {
+	case 'X':
+	    inhibitHeader = 1;
+	    break;
 	case 'M':
 	    protectMkdirWithMutex = 1;
 	    break;


More information about the MIMEDefang mailing list