All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mlmmj more verbose access denied mails
@ 2007-10-30 15:53 Sascha Sommer
  2007-11-04 18:01 ` Morten K. Poulsen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sascha Sommer @ 2007-10-30 15:53 UTC (permalink / raw)
  To: mlmmj

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

Hi,

the attached patch adds another parameter to the prepheader function. This 
parameter can be used to pass the filename of the mail that is going to be 
rejected.

If the parameter is set the first 100 lines of the rejected mail will be 
appended to the reply.

I implemented this for the rejections due to maxmailsize, access denied and 
list adress not passed in the to cases.
What do you think?

Regards

Sascha

P.S. The mails will then look like:

"Hi, this is the mlmmj program managing the mailinglist

test@cuba.sommer.dynalias.net

I'm sorry to inform you that your message could not be delivered to the
list. Your mail was rejected because it matched a rule set up by the
list administrator.

Thanks.

X-Original-To: test@cuba.sommer.dynalias.net
Delivered-To: test@cuba.sommer.dynalias.net
Received: by cuba.sommer.dynalias.net (Postfix, from userid 1000)
        id 56FB719B3AC; Mon, 29 Oct 2007 18:13:03 +0100 (CET)
From: Sascha Sommer <sascha@cuba.sommer.dynalias.net>
To: test@cuba.sommer.dynalias.net
Subject: test4
User-Agent: KMail/1.9.6 (enterprise 20070904.708012)
MIME-Version: 1.0
Content-Disposition: inline
Date: Mon, 29 Oct 2007 18:13:02 +0100
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <200710291813.02497.sascha@cuba.sommer.dynalias.net>

blah blah blah
"

[-- Attachment #2: mlmmj-verbose-access-bounce.patch --]
[-- Type: text/x-diff, Size: 8349 bytes --]

diff -Naur org/mlmmj-1.2.15/include/prepstdreply.h mlmmj-1.2.15/include/prepstdreply.h
--- org/mlmmj-1.2.15/include/prepstdreply.h	2007-06-13 22:54:41.000000000 +0200
+++ mlmmj-1.2.15/include/prepstdreply.h	2007-10-29 16:46:03.000000000 +0100
@@ -31,6 +31,6 @@
 int open_listtext(const char *listdir, const char *filename);
 char *prepstdreply(const char *listdir, const char *filename, const char *from,
 		   const char *to, const char *replyto, size_t tokencount,
-		   char **data, char *customheaders);
+		   char **data, char *customheaders, const char *mailname);
 
 #endif /* PREPSTDREPLY_H */
diff -Naur org/mlmmj-1.2.15/src/mlmmj-bounce.c mlmmj-1.2.15/src/mlmmj-bounce.c
--- org/mlmmj-1.2.15/src/mlmmj-bounce.c	2006-08-06 10:36:47.000000000 +0200
+++ mlmmj-1.2.15/src/mlmmj-bounce.c	2007-10-29 17:00:01.000000000 +0100
@@ -139,7 +139,7 @@
 
 	maildata[1] = indexstr;
 	queuefilename = prepstdreply(listdir, "bounce-probe", "$listowner$",
-					myaddr, NULL, 1, maildata, NULL);
+					myaddr, NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(indexstr);
 
diff -Naur org/mlmmj-1.2.15/src/mlmmj-process.c mlmmj-1.2.15/src/mlmmj-process.c
--- org/mlmmj-1.2.15/src/mlmmj-process.c	2007-05-09 18:59:23.000000000 +0200
+++ mlmmj-1.2.15/src/mlmmj-process.c	2007-10-29 17:46:36.000000000 +0100
@@ -123,7 +123,7 @@
 	myfree(listfqdn);
 
 	queuefilename = prepstdreply(listdir, "moderation", "$listowner$",
-				     to, replyto, 2, maildata, NULL);
+				     to, replyto, 2, maildata, NULL, NULL);
 
 	if((queuefd = open(queuefilename, O_WRONLY|O_APPEND)) < 0) {
 		log_error(LOG_ARGS, "Could not open '%s'", queuefilename);
@@ -657,7 +657,7 @@
 			queuefilename = prepstdreply(listdir,
 					"maxmailsize", "$listowner$",
 					fromemails.emaillist[0],
-					NULL, 2, maildata, NULL);
+					NULL, 2, maildata, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listdelim);
 			myfree(listname);
@@ -768,7 +768,7 @@
 				     listfqdn);
 		queuefilename = prepstdreply(listdir, "notintocc",
 					"$listowner$", fromemails.emaillist[0],
-					     NULL, 0, NULL, NULL);
+					     NULL, 0, NULL, NULL, donemailname);
 		MY_ASSERT(queuefilename)
 		myfree(listdelim);
 		myfree(listname);
@@ -829,7 +829,7 @@
 					"bounces-help@", listfqdn);
 			queuefilename = prepstdreply(listdir, "subonlypost",
 					"$listowner$", fromemails.emaillist[0],
-						     NULL, 1, maildata, NULL);
+						     NULL, 1, maildata, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listaddr);
 			myfree(listdelim);
@@ -880,7 +880,7 @@
 			queuefilename = prepstdreply(listdir, "access",
 							"$listowner$",
 							fromemails.emaillist[0],
-						     NULL, 0, NULL, NULL);
+						     NULL, 0, NULL, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listaddr);
 			myfree(listdelim);
diff -Naur org/mlmmj-1.2.15/src/mlmmj-sub.c mlmmj-1.2.15/src/mlmmj-sub.c
--- org/mlmmj-1.2.15/src/mlmmj-sub.c	2007-06-10 20:40:20.000000000 +0200
+++ mlmmj-1.2.15/src/mlmmj-sub.c	2007-10-29 16:59:07.000000000 +0100
@@ -147,7 +147,7 @@
 	maildata[5] = moderators;
 
 	queuefilename = prepstdreply(listdir, "submod-moderator",
-				"$listowner$", to, replyto, 3, maildata, NULL);
+				"$listowner$", to, replyto, 3, maildata, NULL, NULL);
 	
 	myfree(maildata[1]);
 	
@@ -181,7 +181,7 @@
 
 	from = concatstr(4, listname, listdelim, "bounces-help@", listfqdn);
 	queuefilename = prepstdreply(listdir, "submod-requester", "$listowner$",
-					subaddr, NULL, 0, NULL, NULL);
+					subaddr, NULL, 0, NULL, NULL, NULL);
 	
 	myfree(listname);
 	myfree(listfqdn);
@@ -274,7 +274,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 
@@ -321,7 +321,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$listowner$",
-				"$listowner$", NULL, 1, maildata, NULL);
+				"$listowner$", NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename)
 	myfree(listtext);
 	myfree(maildata[1]);
@@ -408,7 +408,7 @@
 	maildata[3] = mystrdup(confirmaddr);
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$", subaddr,
-				     confirmaddr, 2, maildata, NULL);
+				     confirmaddr, 2, maildata, NULL, NULL);
 
 	myfree(maildata[1]);
 	myfree(maildata[3]);
@@ -460,7 +460,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "sub-subscribed", "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 
 	myfree(listaddr);
diff -Naur org/mlmmj-1.2.15/src/mlmmj-unsub.c mlmmj-1.2.15/src/mlmmj-unsub.c
--- org/mlmmj-1.2.15/src/mlmmj-unsub.c	2006-08-23 21:37:18.000000000 +0200
+++ mlmmj-1.2.15/src/mlmmj-unsub.c	2007-10-29 16:59:44.000000000 +0100
@@ -76,7 +76,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 
@@ -124,7 +124,7 @@
 	}
 	
 	queuefilename = prepstdreply(listdir, listtext, "$listowner$",
-				     "$listowner$", NULL, 1, maildata, NULL);
+				     "$listowner$", NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 	myfree(maildata[1]);
@@ -213,7 +213,7 @@
 	maildata[3] = mystrdup(confirmaddr);
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$", subaddr,
-				     confirmaddr, 2, maildata, NULL);
+				     confirmaddr, 2, maildata, NULL, NULL);
 
 	myfree(maildata[1]);
 	myfree(maildata[3]);
@@ -305,7 +305,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "unsub-notsubscribed",
-				     "$helpaddr$", subaddr, NULL, 0, NULL, NULL);
+				     "$helpaddr$", subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 
 	myfree(listaddr);
diff -Naur org/mlmmj-1.2.15/src/prepstdreply.c mlmmj-1.2.15/src/prepstdreply.c
--- org/mlmmj-1.2.15/src/prepstdreply.c	2007-06-14 00:27:21.000000000 +0200
+++ mlmmj-1.2.15/src/prepstdreply.c	2007-10-29 18:09:46.000000000 +0100
@@ -187,9 +187,9 @@
 
 char *prepstdreply(const char *listdir, const char *filename, const char *from,
 		   const char *to, const char *replyto, size_t tokencount,
-		   char **data, char *customheaders)
+		   char **data, char *customheaders, const char *mailname)
 {
-	int infd, outfd;
+	int infd, outfd, mailfd;
 	char *listaddr, *listdelim, *myfrom, *tmp, *subject, *retstr = NULL;
 	char *listfqdn, *line, *utfline, *utfsub, *utfsub2;
 	char *myreplyto, *myto, *str = NULL, *mydate, *mymsgid;
@@ -198,6 +198,12 @@
 		return NULL;
 	}
 
+        if (mailname) {
+	   if((mailfd = open(mailname, O_RDONLY)) < 0) {
+		return NULL;
+	   }
+	}
+
 	listaddr = getlistaddr(listdir);
 	listdelim = getlistdelim(listdir);
 	listfqdn = genlistfqdn(listaddr);
@@ -310,6 +316,24 @@
 		}
 		myfree(str);
 	}
+
+	/* append the mail inline */
+	if(mailname) {
+		size_t count = 0;
+		while(count < 100 && (str = mygetline(mailfd))) {
+			if(writen(outfd, str, strlen(str)) < 0) {
+				myfree(str);
+				myfree(listaddr);
+				myfree(listdelim);
+				myfree(listfqdn);
+				log_error(LOG_ARGS, "Could not append mail");
+				return NULL;
+			}
+			myfree(str);
+			count++;
+		}
+		close(mailfd);
+	}
 	
 	fsync(outfd);
 	close(outfd);
diff -Naur org/mlmmj-1.2.15/src/send_help.c mlmmj-1.2.15/src/send_help.c
--- org/mlmmj-1.2.15/src/send_help.c	2006-12-06 22:29:27.000000000 +0100
+++ mlmmj-1.2.15/src/send_help.c	2007-10-29 16:56:12.000000000 +0100
@@ -57,7 +57,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, textfile, "$listowner$",
-					emailaddr, NULL, 0, NULL, NULL);
+					emailaddr, NULL, 0, NULL, NULL, NULL);
 	if(queuefilename == NULL) {
 		log_error(LOG_ARGS, "Could not prepare %s mail", name);
 		exit(EXIT_FAILURE);
diff -Naur org/mlmmj-1.2.15/src/send_list.c mlmmj-1.2.15/src/send_list.c
--- org/mlmmj-1.2.15/src/send_list.c	2006-08-06 10:36:48.000000000 +0200
+++ mlmmj-1.2.15/src/send_list.c	2007-10-29 16:57:34.000000000 +0100
@@ -61,7 +61,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "listsubs", "$listowner$",
-					emailaddr, NULL, 0, NULL, NULL);
+					emailaddr, NULL, 0, NULL, NULL, NULL);
 	if(queuefilename == NULL) {
 		log_error(LOG_ARGS, "Could not prepare sub list mail");
 		exit(EXIT_FAILURE);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mlmmj more verbose access denied mails
  2007-10-30 15:53 [PATCH] mlmmj more verbose access denied mails Sascha Sommer
@ 2007-11-04 18:01 ` Morten K. Poulsen
  2007-11-05 15:06 ` Sascha Sommer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Morten K. Poulsen @ 2007-11-04 18:01 UTC (permalink / raw)
  To: mlmmj

Hi Sascha,

Sorry about the delay.

Sascha Sommer wrote:
> the attached patch adds another parameter to the prepheader function. This 
> parameter can be used to pass the filename of the mail that is going to be 
> rejected.

Thanks for the patch. I like the idea.

Perhaps you could extend it a bit, with support for a keyword (or magic 
line, to ease implementation) in the listtext files? Something like this:

---
Subject: Post to $listaddr$ denied due to size limit
[...]
Thanks.

This mail was generated in response to the following mail:
$original-mail$
---

As it is now, the original mail is just appended without any information 
about what it is.

I know that it is a bit more work, but I think it would add a lot of 
value :-)


Morten

-- 
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mlmmj more verbose access denied mails
  2007-10-30 15:53 [PATCH] mlmmj more verbose access denied mails Sascha Sommer
  2007-11-04 18:01 ` Morten K. Poulsen
@ 2007-11-05 15:06 ` Sascha Sommer
  2007-11-05 21:37 ` Morten K. Poulsen
  2007-11-08 15:49 ` Sascha Sommer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Sommer @ 2007-11-05 15:06 UTC (permalink / raw)
  To: mlmmj

[-- Attachment #1: Type: text/plain, Size: 1270 bytes --]

Hi,

On Sonntag, 4. November 2007, Morten K. Poulsen wrote:
> Hi Sascha,
>
> Sorry about the delay.
>

No problem. Thanks for the review.

> Sascha Sommer wrote:
> > the attached patch adds another parameter to the prepheader function.
> > This parameter can be used to pass the filename of the mail that is going
> > to be rejected.
>
> Thanks for the patch. I like the idea.
>
> Perhaps you could extend it a bit, with support for a keyword (or magic
> line, to ease implementation) in the listtext files? Something like this:
>
> ---
> Subject: Post to $listaddr$ denied due to size limit
> [...]
> Thanks.
>
> This mail was generated in response to the following mail:
> $original-mail$
> ---
>
> As it is now, the original mail is just appended without any information
> about what it is.
>
> I know that it is a bit more work, but I think it would add a lot of
> value :-)
>

Ok. See the attached patch.
The keyword $originalmail$ can now be set in the
access
maxmailsize
moderation
notintocc
subonlypost

listtext files. If set the first 100 lines of the denied mail will be 
attached.
I also removed the code that currently does the same for the moderation case 
and made it use the new keyword.

Only the de and en listtexts have been updated.

Regards

Sascha

[-- Attachment #2: mlmmj-verbose-access-bounce_try2.patch --]
[-- Type: text/x-diff, Size: 17144 bytes --]

diff -Naur mlmmj-1.2.15.org/include/prepstdreply.h mlmmj-1.2.15/include/prepstdreply.h
--- mlmmj-1.2.15.org/include/prepstdreply.h	2007-11-05 15:29:41.000000000 +0100
+++ mlmmj-1.2.15/include/prepstdreply.h	2007-11-05 15:51:44.000000000 +0100
@@ -25,12 +25,12 @@
 #define PREPSTDREPLY_H
 
 char *substitute(const char *line, const char *listaddr, const char *listdelim,
-		 size_t datacount, char **data);
+		 size_t datacount, char **data, const char* mailname);
 char *substitute_one(const char *line, const char *listaddr,
-		 const char *listdelim, size_t datacount, char **data);
+		 const char *listdelim, size_t datacount, char **data, const char* mailname);
 int open_listtext(const char *listdir, const char *filename);
 char *prepstdreply(const char *listdir, const char *filename, const char *from,
 		   const char *to, const char *replyto, size_t tokencount,
-		   char **data, char *customheaders);
+		   char **data, char *customheaders, const char *mailname);
 
 #endif /* PREPSTDREPLY_H */
diff -Naur mlmmj-1.2.15.org/listtexts/de/access mlmmj-1.2.15/listtexts/de/access
--- mlmmj-1.2.15.org/listtexts/de/access	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/de/access	2007-11-05 15:51:44.000000000 +0100
@@ -10,3 +10,6 @@
 Filter, den der Administrator dieser Liste aufgesetzt hat, traf 
 auf Ihre Mail zu.
 
+--- Unterhalb dieser Linie sehen Sie die ersten 100 Zeilen der abgelehnten Nachricht. --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/de/maxmailsize mlmmj-1.2.15/listtexts/de/maxmailsize
--- mlmmj-1.2.15.org/listtexts/de/maxmailsize	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/de/maxmailsize	2007-11-05 15:51:44.000000000 +0100
@@ -9,3 +9,7 @@
 Tut mir leid aber Ihre Mail konnte nicht versandt werden. Die von
 Ihnen verschickte Mail \u00FCberschreitet das bestehende Gr\u00F6\u00DFenlimit
 von $maxmailsize$ Bytes.
+
+--- Unterhalb dieser Linie sehen Sie die ersten 100 Zeilen der abgelehnten Nachricht. --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/de/moderation mlmmj-1.2.15/listtexts/de/moderation
--- mlmmj-1.2.15.org/listtexts/de/moderation	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/de/moderation	2007-11-05 15:51:44.000000000 +0100
@@ -23,3 +23,5 @@
 $moderators$
 
 --- Unterhalb dieser Linie sehen Sie die ersten 100 Zeilen der Nachricht, welche moderiert werden muss. --->
+$orignalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/de/notintocc mlmmj-1.2.15/listtexts/de/notintocc
--- mlmmj-1.2.15.org/listtexts/de/notintocc	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/de/notintocc	2007-11-05 15:51:44.000000000 +0100
@@ -14,3 +14,6 @@
 
 Danke.
 
+--- Unterhalb dieser Linie sehen Sie die ersten 100 Zeilen der abgelehnten Nachricht. --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/de/subonlypost mlmmj-1.2.15/listtexts/de/subonlypost
--- mlmmj-1.2.15.org/listtexts/de/subonlypost	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/de/subonlypost	2007-11-05 15:51:44.000000000 +0100
@@ -26,3 +26,6 @@
 sind, Nachrichten an die Liste schicken zu k\u00F6nnen, tragen Sie die neue
 Adresse bitte auf die Nomail-Version dieser Liste ein.
 
+--- Unterhalb dieser Linie sehen Sie die ersten 100 Zeilen der abgelehnten Nachricht. --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/en/access mlmmj-1.2.15/listtexts/en/access
--- mlmmj-1.2.15.org/listtexts/en/access	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/en/access	2007-11-05 15:51:44.000000000 +0100
@@ -10,3 +10,6 @@
 
 Thanks.
 
+--- below this line the first 100 lines of the denied message --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/en/maxmailsize mlmmj-1.2.15/listtexts/en/maxmailsize
--- mlmmj-1.2.15.org/listtexts/en/maxmailsize	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/en/maxmailsize	2007-11-05 15:51:44.000000000 +0100
@@ -9,3 +9,6 @@
 
 Thanks.
 
+--- below this line the first 100 lines of the denied message --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/en/moderation mlmmj-1.2.15/listtexts/en/moderation
--- mlmmj-1.2.15.org/listtexts/en/moderation	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/en/moderation	2007-11-05 15:51:44.000000000 +0100
@@ -19,3 +19,5 @@
 $moderators$
 
 --- below this line the first 100 lines of the message up for moderation --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/en/notintocc mlmmj-1.2.15/listtexts/en/notintocc
--- mlmmj-1.2.15.org/listtexts/en/notintocc	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/en/notintocc	2007-11-05 15:51:44.000000000 +0100
@@ -12,3 +12,6 @@
 
 Thanks.
 
+--- below this line the first 100 lines of the denied message --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/listtexts/en/subonlypost mlmmj-1.2.15/listtexts/en/subonlypost
--- mlmmj-1.2.15.org/listtexts/en/subonlypost	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/listtexts/en/subonlypost	2007-11-05 15:51:44.000000000 +0100
@@ -18,3 +18,6 @@
 If you want to be able to post from more than one email address, you
 can subscribe the other addresses to the nomail version of the list.
 
+--- below this line the first 100 lines of the denied message --->
+$originalmail$
+
diff -Naur mlmmj-1.2.15.org/src/mlmmj-bounce.c mlmmj-1.2.15/src/mlmmj-bounce.c
--- mlmmj-1.2.15.org/src/mlmmj-bounce.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/mlmmj-bounce.c	2007-11-05 15:51:44.000000000 +0100
@@ -139,7 +139,7 @@
 
 	maildata[1] = indexstr;
 	queuefilename = prepstdreply(listdir, "bounce-probe", "$listowner$",
-					myaddr, NULL, 1, maildata, NULL);
+					myaddr, NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(indexstr);
 
diff -Naur mlmmj-1.2.15.org/src/mlmmj-process.c mlmmj-1.2.15/src/mlmmj-process.c
--- mlmmj-1.2.15.org/src/mlmmj-process.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/mlmmj-process.c	2007-11-05 15:51:44.000000000 +0100
@@ -76,8 +76,7 @@
 	char *buf, *replyto, *listaddr = getlistaddr(listdir), *listdelim;
 	char *queuefilename = NULL, *moderatorsfilename;
 	char *mailbasename = mybasename(mailfilename), *tmp, *to;
-	int queuefd, moderatorsfd, mailfd;
-	size_t count = 0;
+	int moderatorsfd;
 	char *maildata[4] = { "moderateaddr", NULL, "moderators", NULL };
 #if 0
 	printf("mailfilename = [%s], mailbasename = [%s]\n", mailfilename,
@@ -86,11 +85,6 @@
 	listfqdn = genlistfqdn(listaddr);
 	listname = genlistname(listaddr);
 
-	if((mailfd = open(mailfilename, O_RDONLY)) < 0) {
-		log_error(LOG_ARGS, "Could not open '%s'", mailfilename);
-		exit(EXIT_FAILURE);
-	}
-
 	moderatorsfilename = concatstr(2, listdir, "/control/moderators");
 	if((moderatorsfd = open(moderatorsfilename, O_RDONLY)) < 0) {
 		log_error(LOG_ARGS, "Could not open '%s'", moderatorsfilename);
@@ -123,25 +117,7 @@
 	myfree(listfqdn);
 
 	queuefilename = prepstdreply(listdir, "moderation", "$listowner$",
-				     to, replyto, 2, maildata, NULL);
-
-	if((queuefd = open(queuefilename, O_WRONLY|O_APPEND)) < 0) {
-		log_error(LOG_ARGS, "Could not open '%s'", queuefilename);
-		myfree(queuefilename);
-		exit(EXIT_FAILURE);
-	}
-	
-	while(count < 100 && (buf = mygetline(mailfd))) {
-		tmp = concatstr(2, " ", buf);
-		myfree(buf);
-		if(writen(queuefd, tmp, strlen(tmp)) < 0)
-			log_error(LOG_ARGS, "Could not write line for "
-					    "moderatemail");
-		myfree(tmp);
-		count++;
-	}
-	close(queuefd);
-	close(mailfd);
+				     to, replyto, 2, maildata, NULL, mailfilename);
 
 	execlp(mlmmjsend, mlmmjsend,
 				"-l", "2",
@@ -657,7 +633,7 @@
 			queuefilename = prepstdreply(listdir,
 					"maxmailsize", "$listowner$",
 					fromemails.emaillist[0],
-					NULL, 2, maildata, NULL);
+					NULL, 2, maildata, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listdelim);
 			myfree(listname);
@@ -768,7 +744,7 @@
 				     listfqdn);
 		queuefilename = prepstdreply(listdir, "notintocc",
 					"$listowner$", fromemails.emaillist[0],
-					     NULL, 0, NULL, NULL);
+					     NULL, 0, NULL, NULL, donemailname);
 		MY_ASSERT(queuefilename)
 		myfree(listdelim);
 		myfree(listname);
@@ -829,7 +805,7 @@
 					"bounces-help@", listfqdn);
 			queuefilename = prepstdreply(listdir, "subonlypost",
 					"$listowner$", fromemails.emaillist[0],
-						     NULL, 1, maildata, NULL);
+						     NULL, 1, maildata, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listaddr);
 			myfree(listdelim);
@@ -880,7 +856,7 @@
 			queuefilename = prepstdreply(listdir, "access",
 							"$listowner$",
 							fromemails.emaillist[0],
-						     NULL, 0, NULL, NULL);
+						     NULL, 0, NULL, NULL, donemailname);
 			MY_ASSERT(queuefilename)
 			myfree(listaddr);
 			myfree(listdelim);
diff -Naur mlmmj-1.2.15.org/src/mlmmj-sub.c mlmmj-1.2.15/src/mlmmj-sub.c
--- mlmmj-1.2.15.org/src/mlmmj-sub.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/mlmmj-sub.c	2007-11-05 15:51:44.000000000 +0100
@@ -147,7 +147,7 @@
 	maildata[5] = moderators;
 
 	queuefilename = prepstdreply(listdir, "submod-moderator",
-				"$listowner$", to, replyto, 3, maildata, NULL);
+				"$listowner$", to, replyto, 3, maildata, NULL, NULL);
 	
 	myfree(maildata[1]);
 	
@@ -181,7 +181,7 @@
 
 	from = concatstr(4, listname, listdelim, "bounces-help@", listfqdn);
 	queuefilename = prepstdreply(listdir, "submod-requester", "$listowner$",
-					subaddr, NULL, 0, NULL, NULL);
+					subaddr, NULL, 0, NULL, NULL, NULL);
 	
 	myfree(listname);
 	myfree(listfqdn);
@@ -274,7 +274,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 
@@ -321,7 +321,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$listowner$",
-				"$listowner$", NULL, 1, maildata, NULL);
+				"$listowner$", NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename)
 	myfree(listtext);
 	myfree(maildata[1]);
@@ -408,7 +408,7 @@
 	maildata[3] = mystrdup(confirmaddr);
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$", subaddr,
-				     confirmaddr, 2, maildata, NULL);
+				     confirmaddr, 2, maildata, NULL, NULL);
 
 	myfree(maildata[1]);
 	myfree(maildata[3]);
@@ -460,7 +460,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "sub-subscribed", "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 
 	myfree(listaddr);
diff -Naur mlmmj-1.2.15.org/src/mlmmj-unsub.c mlmmj-1.2.15/src/mlmmj-unsub.c
--- mlmmj-1.2.15.org/src/mlmmj-unsub.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/mlmmj-unsub.c	2007-11-05 15:51:44.000000000 +0100
@@ -76,7 +76,7 @@
 	}
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$",
-				     subaddr, NULL, 0, NULL, NULL);
+				     subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 
@@ -124,7 +124,7 @@
 	}
 	
 	queuefilename = prepstdreply(listdir, listtext, "$listowner$",
-				     "$listowner$", NULL, 1, maildata, NULL);
+				     "$listowner$", NULL, 1, maildata, NULL, NULL);
 	MY_ASSERT(queuefilename);
 	myfree(listtext);
 	myfree(maildata[1]);
@@ -213,7 +213,7 @@
 	maildata[3] = mystrdup(confirmaddr);
 
 	queuefilename = prepstdreply(listdir, listtext, "$helpaddr$", subaddr,
-				     confirmaddr, 2, maildata, NULL);
+				     confirmaddr, 2, maildata, NULL, NULL);
 
 	myfree(maildata[1]);
 	myfree(maildata[3]);
@@ -305,7 +305,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "unsub-notsubscribed",
-				     "$helpaddr$", subaddr, NULL, 0, NULL, NULL);
+				     "$helpaddr$", subaddr, NULL, 0, NULL, NULL, NULL);
 	MY_ASSERT(queuefilename);
 
 	myfree(listaddr);
diff -Naur mlmmj-1.2.15.org/src/prepstdreply.c mlmmj-1.2.15/src/prepstdreply.c
--- mlmmj-1.2.15.org/src/prepstdreply.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/prepstdreply.c	2007-11-05 15:51:44.000000000 +0100
@@ -44,13 +44,13 @@
 #include "unistr.h"
 
 char *substitute(const char *line, const char *listaddr, const char *listdelim,
-		 size_t datacount, char **data)
+		 size_t datacount, char **data, const char *mailname)
 {
 	char *s1, *s2;
 
-	s1 = substitute_one(line, listaddr, listdelim, datacount, data);
+	s1 = substitute_one(line, listaddr, listdelim, datacount, data, mailname);
 	while(s1) {
-		s2 = substitute_one(s1, listaddr, listdelim, datacount, data);
+		s2 = substitute_one(s1, listaddr, listdelim, datacount, data, mailname);
 		if(s2) {
 			myfree(s1);
 			s1 = s2;
@@ -62,7 +62,7 @@
 }
 
 char *substitute_one(const char *line, const char *listaddr,
-		     const char *listdelim, size_t datacount, char **data)
+		     const char *listdelim, size_t datacount, char **data, const char* mailname)
 {
 	char *fqdn, *listname, *d1, *d2, *token, *value = NULL;
 	char *retstr, *origline;
@@ -132,7 +132,28 @@
 		value = concatstr(4, listname, listdelim, "subscribe-nomail@",
 				  fqdn);
 		goto concatandreturn;
-	}
+	} else if(strcmp(token, "originalmail") == 0) {
+	        /* append the first 100 lines of the mail inline */
+		int mailfd;
+		if(mailname && 
+                     ((mailfd = open(mailname, O_RDONLY)) > 0)){
+                	size_t count = 0;
+			char* str = NULL;
+                	while(count < 100 && (str = mygetline(mailfd))) {
+				char* tmp = value;
+				value = concatstr(3, value, " ", str);
+				if(tmp)
+					myfree(tmp);
+                        	count++;
+                        }
+			if(str)
+                        	myfree(str);
+                	close(mailfd);
+                }else{
+			log_error(LOG_ARGS, "Could not substitute $originalmail$ (mailname == %s)",mailname);
+		}
+		goto concatandreturn;
+        }
 	if(data) {
 		for(i = 0; i < datacount; i++) {
 			if(strcmp(token, data[i*2]) == 0) {
@@ -187,7 +208,7 @@
 
 char *prepstdreply(const char *listdir, const char *filename, const char *from,
 		   const char *to, const char *replyto, size_t tokencount,
-		   char **data, char *customheaders)
+		   char **data, char *customheaders, const char *mailname)
 {
 	int infd, outfd;
 	char *listaddr, *listdelim, *myfrom, *tmp, *subject, *retstr = NULL;
@@ -211,7 +232,7 @@
 		chomp(line);
 		utfsub = unistr_escaped_to_utf8(line + 9);
 		utfsub2 = substitute(utfsub, listaddr, listdelim, tokencount,
-				     data);
+				     data, NULL);
 		subject = unistr_utf8_to_header(utfsub2);
 		myfree(utfsub);
 		myfree(utfsub2);
@@ -231,14 +252,14 @@
 		utfline = NULL;
 	}
 	
-	myfrom = substitute(from, listaddr, listdelim, tokencount, data);
-	myto = substitute(to, listaddr, listdelim, tokencount, data);
+	myfrom = substitute(from, listaddr, listdelim, tokencount, data, NULL);
+	myto = substitute(to, listaddr, listdelim, tokencount, data, NULL);
 	mydate = gendatestr();
 	mymsgid = genmsgid(listfqdn);
 
 	if(replyto) {
 		myreplyto = substitute(replyto, listaddr, listdelim,
-				       tokencount, data);
+				       tokencount, data, NULL);
 		tmp = concatstr(3, "Reply-To: ", myreplyto, "\n");
 		myfree(myreplyto);
 		myreplyto = tmp;
@@ -297,7 +318,7 @@
 		myfree(tmp);
 
 		tmp = utfline;
-		str = substitute(utfline, listaddr, listdelim, tokencount, data);
+		str = substitute(utfline, listaddr, listdelim, tokencount, data, mailname);
 		myfree(tmp);
 
 		if(writen(outfd, str, strlen(str)) < 0) {
diff -Naur mlmmj-1.2.15.org/src/send_digest.c mlmmj-1.2.15/src/send_digest.c
--- mlmmj-1.2.15.org/src/send_digest.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/send_digest.c	2007-11-05 15:51:44.000000000 +0100
@@ -263,7 +263,7 @@
 		utfsub = unistr_escaped_to_utf8(line + 9);
 	}
 
-	utfsub2 = substitute(utfsub, listaddr, listdelim, 5, subst_data);
+	utfsub2 = substitute(utfsub, listaddr, listdelim, 5, subst_data, NULL);
 	subject = unistr_utf8_to_header(utfsub2);
 	myfree(utfsub);
 	myfree(utfsub2);
@@ -362,7 +362,7 @@
 				myfree(line);
 
 				tmp = substitute(utfline, listaddr, listdelim,
-						5, subst_data);
+						5, subst_data, NULL);
 				myfree(utfline);
 
 				if(writen(fd, tmp, strlen(tmp)) < 0) {
diff -Naur mlmmj-1.2.15.org/src/send_help.c mlmmj-1.2.15/src/send_help.c
--- mlmmj-1.2.15.org/src/send_help.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/send_help.c	2007-11-05 15:51:44.000000000 +0100
@@ -57,7 +57,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, textfile, "$listowner$",
-					emailaddr, NULL, 0, NULL, NULL);
+					emailaddr, NULL, 0, NULL, NULL, NULL);
 	if(queuefilename == NULL) {
 		log_error(LOG_ARGS, "Could not prepare %s mail", name);
 		exit(EXIT_FAILURE);
diff -Naur mlmmj-1.2.15.org/src/send_list.c mlmmj-1.2.15/src/send_list.c
--- mlmmj-1.2.15.org/src/send_list.c	2007-11-05 15:29:40.000000000 +0100
+++ mlmmj-1.2.15/src/send_list.c	2007-11-05 15:51:44.000000000 +0100
@@ -61,7 +61,7 @@
 	myfree(listdelim);
 
 	queuefilename = prepstdreply(listdir, "listsubs", "$listowner$",
-					emailaddr, NULL, 0, NULL, NULL);
+					emailaddr, NULL, 0, NULL, NULL, NULL);
 	if(queuefilename == NULL) {
 		log_error(LOG_ARGS, "Could not prepare sub list mail");
 		exit(EXIT_FAILURE);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mlmmj more verbose access denied mails
  2007-10-30 15:53 [PATCH] mlmmj more verbose access denied mails Sascha Sommer
  2007-11-04 18:01 ` Morten K. Poulsen
  2007-11-05 15:06 ` Sascha Sommer
@ 2007-11-05 21:37 ` Morten K. Poulsen
  2007-11-08 15:49 ` Sascha Sommer
  3 siblings, 0 replies; 5+ messages in thread
From: Morten K. Poulsen @ 2007-11-05 21:37 UTC (permalink / raw)
  To: mlmmj

Hi Sascha,

Sascha Sommer wrote:
> On Sonntag, 4. November 2007, Morten K. Poulsen wrote:
>> Perhaps you could extend it a bit, with support for a keyword (or magic
>> line, to ease implementation) in the listtext files? Something like this:
[...]
> Ok. See the attached patch.

Thanks! I have committed it to CVS.

So, all translation maintainers, please update the following listtexts:
- access
- maxmailsize
- moderation
- notintocc
- subonlypost

to include two lines like this:

--- below this line are the first 100 lines of the denied message --->
$originalmail$

Thanks :-)


Best regards,
Morten

-- 
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mlmmj more verbose access denied mails
  2007-10-30 15:53 [PATCH] mlmmj more verbose access denied mails Sascha Sommer
                   ` (2 preceding siblings ...)
  2007-11-05 21:37 ` Morten K. Poulsen
@ 2007-11-08 15:49 ` Sascha Sommer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Sommer @ 2007-11-08 15:49 UTC (permalink / raw)
  To: mlmmj

Hi,

On Montag, 5. November 2007, Morten K. Poulsen wrote:
> Hi Sascha,
>
> Sascha Sommer wrote:
> > On Sonntag, 4. November 2007, Morten K. Poulsen wrote:
> >> Perhaps you could extend it a bit, with support for a keyword (or magic
> >> line, to ease implementation) in the listtext files? Something like
> >> this:
>
> [...]
>
> > Ok. See the attached patch.
>
> Thanks! I have committed it to CVS.
>

Thanks.

Regards

Sascha

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-08 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-30 15:53 [PATCH] mlmmj more verbose access denied mails Sascha Sommer
2007-11-04 18:01 ` Morten K. Poulsen
2007-11-05 15:06 ` Sascha Sommer
2007-11-05 21:37 ` Morten K. Poulsen
2007-11-08 15:49 ` Sascha Sommer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.