Skip to contentSkip to conversation

alternate value for RECIPDELIM

PATCH Neale Pickett 2 participants 3 messages Sep 21, 2005 – Sep 22, 2005

lore
Share & tools
lore
#0 lore raw

I've got a mail server that's been using '-' instead of '+' for a long, long time now, and I can't switch it over to '+' without breaking a billion email addresses. I patched the source code (patch at bottom) to let me use '+', and let anyone else #define a new RECIPDELIM (and have it work), but I don't like the patch.

It seems like the *right* thing to do would be to use something like my patch, where people could configure it at compile-time, but to maybe read /etc/mlmmj/recipdelim (if it exists) to get the RECIPDELIM. This would let me go back to using the debian package with its default '+'.

Something like:

char recipdelim = 's';

{
int fd;

  fd = fopen("/etc/mlmmj/recipdelim", "r");
  if (fd) {
    int r;
    r = fgetc(fd);
    if (r != EOF) {
      recipdelim = r;
    }

    fclose(fd);

}
}

If this seems like a good idea to mlmmj's author, I'd be happy to work on a new patch to implement things this way. In the meantime, the following at least lets you modify it at compile time. (It also uses RECIPDELIM for Postfix's VERP stuff, which seems to be the right thing, but I could be wildly wrong).

include/mlmmj.h +2 -1
diff -ur mlmmj-1.2.8/include/mlmmj.h mlmmj-1.2.8-local/include/mlmmj.h
@@ -28,7 +28,8 @@
 
 #define RELAYHOST "127.0.0.1"
 #define READ_BUFSIZE 2048
-#define RECIPDELIM '+'  /* XXX Warning: not changable at the moment */
+#define RECIPDELIMS "+"  /* Recipient delimiter--may only be one character long */
+#define RECIPDELIM (RECIPDELIMS[0])
 #define MODREQLIFE 604800 /* How long time will moderation requests be kept?
 			   * 604800s is 7 days */
 #define DISCARDEDLIFE 604800 /* How long time will discarded mails be kept?
src/mlmmj-bounce.c +1 -1
diff -ur mlmmj-1.2.8/src/mlmmj-bounce.c mlmmj-1.2.8-local/src/mlmmj-bounce.c
@@ -112,7 +112,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	from = concatstr(5, listname, "+bounces-probe-", myaddr, "@", listfqdn);
+	from = concatstr(5, listname, RECIPDELIMS "bounces-probe-", myaddr, "@", listfqdn);
 
 	myfree(listaddr);
 	myfree(listfqdn);
src/mlmmj-process.c +6 -6
diff -ur mlmmj-1.2.8/src/mlmmj-process.c mlmmj-1.2.8-local/src/mlmmj-process.c
@@ -106,13 +106,13 @@
 
 	close(moderatorsfd);
 
-	replyto = concatstr(5, listname, "+moderate-", mailbasename, "@",
+	replyto = concatstr(5, listname, RECIPDELIMS "moderate-", mailbasename, "@",
 			    listfqdn);
 
 	maildata[1] = replyto;
 	maildata[3] = moderators;
 
-	from = concatstr(3, listname, "+owner@", listfqdn);
+	from = concatstr(3, listname, RECIPDELIMS "owner@", listfqdn);
 	to = concatstr(3, listname, "-moderators@", listfqdn);
 
 	myfree(listname);
@@ -519,7 +519,7 @@
 
 	if(recipdelim) {
 		owner = concatstr(2, listdir, "/control/owner");
-		if(owner && strncmp(recipdelim, "+owner@", 7) == 0) {
+		if(owner && strncmp(recipdelim, RECIPDELIMS "owner@", 7) == 0) {
 			/* strip envelope from before resending */
 			delheaders->count = 0;
 			delheaders->strs = NULL;
@@ -645,7 +645,7 @@
 		}
 		listname = genlistname(listaddr);
 		listfqdn = genlistfqdn(listaddr);
-		fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+		fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 		queuefilename = prepstdreply(listdir, "notintocc",
 					"$listowner$", fromemails.emaillist[0],
 					NULL, 0, NULL);
@@ -686,7 +686,7 @@
 			listname = genlistname(listaddr);
 			listfqdn = genlistfqdn(listaddr);
 			maildata[1] = fromemails.emaillist[0];
-			fromaddr = concatstr(3, listname, "+bounces-help@",
+			fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@",
 					listfqdn);
 			queuefilename = prepstdreply(listdir, "subonlypost",
 					"$listowner$", fromemails.emaillist[0],
@@ -726,7 +726,7 @@
 			}
 			listname = genlistname(listaddr);
 			listfqdn = genlistfqdn(listaddr);
-			fromaddr = concatstr(3, listname, "+bounces-help@",
+			fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@",
 					listfqdn);
 			queuefilename = prepstdreply(listdir, "access",
 							"$listowner$",

Only in mlmmj-1.2.8-local/src: mlmmj-process.c.orig

src/mlmmj-send.c +2 -2
diff -ur mlmmj-1.2.8/src/mlmmj-send.c mlmmj-1.2.8-local/src/mlmmj-send.c
@@ -1043,7 +1043,7 @@
 
 		listname = genlistname(listaddr);	
 		listfqdn = genlistfqdn(listaddr);	
-		verpfrom = concatstr(5, listname, "+bounces-", strindex, "@",
+		verpfrom = concatstr(5, listname, RECIPDELIMS "bounces-", strindex, "@",
 				listfqdn);
 		myfree(listname);
 		myfree(listfqdn);
@@ -1053,7 +1053,7 @@
 
 		if(verp && (strcmp(verp, "postfix") == 0)) {
 			myfree(verp);
-			verp = mystrdup("XVERP=-=");
+			verp = mystrdup("XVERP=" RECIPDELIMS "=");
 		}
 
 		if(addtohdr && verp) {

Only in mlmmj-1.2.8-local/src: mlmmj-send.c.orig

src/mlmmj-sub.c +8 -8
diff -ur mlmmj-1.2.8/src/mlmmj-sub.c mlmmj-1.2.8-local/src/mlmmj-sub.c
@@ -55,7 +55,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	myfree(listname);
 	myfree(listfqdn);
@@ -100,8 +100,8 @@
 
 	maildata[1] = mystrdup(subaddr);
 	
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
-	tostr = concatstr(3, listname, "+owner@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
+	tostr = concatstr(3, listname, RECIPDELIMS "owner@", listfqdn);
 	
 	myfree(listname);
 	myfree(listfqdn);
@@ -177,22 +177,22 @@
 
 	close(subconffd);
 
-	fromaddr = concatstr(5, listname, "+bounces-confsub-", randomstr,
+	fromaddr = concatstr(5, listname, RECIPDELIMS "bounces-confsub-", randomstr,
 				"@", listfqdn);
 	
 	switch(typesub) {
 		default:
 		case SUB_NORMAL:
 			listtext = mystrdup("sub-confirm");
-			tmpstr = mystrdup("+confsub-");
+			tmpstr = mystrdup(RECIPDELIMS "confsub-");
 			break;
 		case SUB_DIGEST:
 			listtext = mystrdup("sub-confirm-digest");
-			tmpstr = mystrdup("+confsub-digest-");
+			tmpstr = mystrdup(RECIPDELIMS "confsub-digest-");
 			break;
 		case SUB_NOMAIL:
 			listtext = mystrdup("sub-confirm-nomail");
-			tmpstr = mystrdup("+confsub-nomail-");
+			tmpstr = mystrdup(RECIPDELIMS "confsub-nomail-");
 			break;
 	}
 
@@ -250,7 +250,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	queuefilename = prepstdreply(listdir, "sub-subscribed", "$helpaddr$",
 				     subaddr, NULL, 0, NULL);

Only in mlmmj-1.2.8-local/src: mlmmj-sub.c~

src/mlmmj-unsub.c +8 -8
diff -ur mlmmj-1.2.8/src/mlmmj-unsub.c mlmmj-1.2.8-local/src/mlmmj-unsub.c
@@ -55,7 +55,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	myfree(listname);
 	myfree(listfqdn);
@@ -101,8 +101,8 @@
 
         maildata[1] = mystrdup(subaddr);
 
-        fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
-	tostr = concatstr(3, listname, "+owner@", listfqdn);
+        fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
+	tostr = concatstr(3, listname, RECIPDELIMS "owner@", listfqdn);
 
 	myfree(listname);
 	myfree(listfqdn);
@@ -180,22 +180,22 @@
 
 	close(subconffd);
 
-	fromaddr = concatstr(5, listname, "+bounces-confunsub-", randomstr,
+	fromaddr = concatstr(5, listname, RECIPDELIMS "bounces-confunsub-", randomstr,
 				"@", listfqdn);
 
 	switch(typesub) {
 		default:
 		case SUB_NORMAL:
 			listtext = mystrdup("unsub-confirm");
-			tmpstr = mystrdup("+confunsub-");
+			tmpstr = mystrdup(RECIPDELIMS "confunsub-");
 			break;
 		case SUB_DIGEST:
 			listtext = mystrdup("unsub-confirm-digest");
-			tmpstr = mystrdup("+confunsub-digest-");
+			tmpstr = mystrdup(RECIPDELIMS "confunsub-digest-");
 			break;
 		case SUB_NOMAIL:
 			listtext = mystrdup("unsub-confirm-nomail");
-			tmpstr = mystrdup("+confunsub-nomail-");
+			tmpstr = mystrdup(RECIPDELIMS "confunsub-nomail-");
 			break;
 	}
 
@@ -294,7 +294,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	queuefilename = prepstdreply(listdir, "unsub-notsubscribed",
 				     "$helpaddr$", subaddr, NULL, 0, NULL);

Only in mlmmj-1.2.8-local/src: mlmmj-unsub.c~

src/prepstdreply.c +10 -9
diff -ur mlmmj-1.2.8/src/prepstdreply.c mlmmj-1.2.8-local/src/prepstdreply.c
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <errno.h>
 
+#include "mlmmj.h"
 #include "prepstdreply.h"
 #include "strgen.h"
 #include "chomp.h"
@@ -95,31 +96,31 @@
 		value = mystrdup(listaddr);
 		goto concatandreturn;
 	} else if(strcmp(token, "listowner") == 0) {
-		value = concatstr(3, listname, "+owner@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "owner@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "helpaddr") == 0) {
-		value = concatstr(3, listname, "+help@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "help@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "listgetN") == 0) {
-		value = concatstr(3, listname, "+get-N@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "get-N@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "listunsubaddr") == 0) {
-		value = concatstr(3, listname, "+unsubscribe@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "unsubscribe@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "digestunsubaddr") == 0) {
-		value = concatstr(3, listname, "+unsubscribe-digest@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "unsubscribe-digest@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "nomailunsubaddr") == 0) {
-		value = concatstr(3, listname, "+unsubscribe-nomail@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "unsubscribe-nomail@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "listsubaddr") == 0) {
-		value = concatstr(3, listname, "+subscribe@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "subscribe@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "digestsubaddr") == 0) {
-		value = concatstr(3, listname, "+subscribe-digest@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "subscribe-digest@", fqdn);
 		goto concatandreturn;
 	} else if(strcmp(token, "nomailsubaddr") == 0) {
-		value = concatstr(3, listname, "+subscribe-nomail@", fqdn);
+		value = concatstr(3, listname, RECIPDELIMS "subscribe-nomail@", fqdn);
 		goto concatandreturn;
 	}
 	if(data) {
src/send_digest.c +1 -1
diff -ur mlmmj-1.2.8/src/send_digest.c mlmmj-1.2.8-local/src/send_digest.c
@@ -90,7 +90,7 @@
 		snprintf(buf, sizeof(buf), " (%d-%d)", firstindex, lastindex);
 	}
 
-	fromstr = concatstr(5, "From: ", listname, "+help@", listfqdn, "\n");
+	fromstr = concatstr(5, "From: ", listname, RECIPDELIMS "help@", listfqdn, "\n");
 	tmp = concatstr(6, "MIME-Version: 1.0"
 			    "\nContent-Type: multipart/" DIGESTMIMETYPE "; "
 			    "boundary=", boundary,
src/send_help.c +1 -1
diff -ur mlmmj-1.2.8/src/send_help.c mlmmj-1.2.8-local/src/send_help.c
@@ -50,7 +50,7 @@
 	listname = genlistname(listaddr);
 	listfqdn = genlistfqdn(listaddr);
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	queuefilename = prepstdreply(listdir, "listhelp", "$listowner$",
 					emailaddr, NULL, 0, NULL);
src/send_list.c +1 -1
diff -ur mlmmj-1.2.8/src/send_list.c mlmmj-1.2.8-local/src/send_list.c
@@ -55,7 +55,7 @@
 	listfqdn = genlistfqdn(listaddr);
 	subdir = concatstr(2, listdir, "/subscribers.d/");
 
-	fromaddr = concatstr(3, listname, "+bounces-help@", listfqdn);
+	fromaddr = concatstr(3, listname, RECIPDELIMS "bounces-help@", listfqdn);
 
 	queuefilename = prepstdreply(listdir, "listsubs", "$listowner$",
 					emailaddr, NULL, 0, NULL);
#1 lore raw
Quoted 3 lines · Neale Pickett

Something like:

char recipdelim = 's';

Don't ask me why I put an 's' there, because I don't know. That should have been:

char recipdelim = '+';

#2 lore raw
In reply to Neale Pickett
Quoted 3 lines · Neale Pickett

I've got a mail server that's been using '-' instead of '+' for a long, long time now, and I can't switch it over to '+' without breaking a billion email addresses. I patched the source code (patch at bottom) to let me use '+', and let anyone else #define a new RECIPDELIM (and have it work), but I don't like the patch.

It seems like the *right* thing to do would be to use something like my patch, where people could configure it at compile-time, but to maybe read /etc/mlmmj/recipdelim (if it exists) to get the RECIPDELIM. This would let me go back to using the debian package with its default '+'.

This looks awfully familiar. I swear I developed mine separately. But it's clearly a feature in fairly high demand...

The two differences are that I set it up to read an optional list delimiter on a per-list basis, and that my patch supports multi-character delimiters (not that this is probably a generally-sane idea to do with most servers, but... why make things difficult? It's not really any more effort to support it, or any slower in practice).

As soon as I can pare out the last nits, I'll post it (it's getting copies of real list emails from my production server right now to excercise it some, and there are a couple of things still being odd).

Signature · 1 line
Joel Aelwyn <[email protected]>