Skip to contentSkip to conversation

MIME footer patch, was: mlmmj-1.2.9-RC2 and scooping up patches

DISCUSSION Jakob Hirsch 2 participants 4 messages Dec 10, 2005 – Dec 18, 2005

lore
Share & tools
lore
#0 lore raw
Quoted 1 line · Mads Martin Joergensen

http://mlmmj.mmj.dk/files/mlmmj-1.2.9-RC2.tar.bz2

nice!

And I finally reworked the infamous MIME footer patch. The behaviour is now controlled by a new control (footer_mime).

There are some major changes in the vodoo file:
- rebuild the while loop that works through the headers
- removed the strlen(hdrline)==1 check. gethdrline() never returns more than one LF and it's always the rightmost character.
- removed the special handling of headers starting with "mime" (usually only the "MIME-Version" header). What was the purpose of it? AFAIK it's a header like every else.
- the result of every writen() is checked now

The changes are really big, but the code is much clearer now and fairly straightforward. As always, comments welcome.

Regards,
Jakob

ChangeLog +1 -0
diff -ru mlmmj-1.2.9-RC2/ChangeLog mlmmj-1.2.9-RC2-jh1/ChangeLog
@@ -11,6 +11,7 @@
    It makes sense to be able to confirm a request submitted by the sysadmin
    on the commandline
  o Add 'subonlyget' tunable which makes +get-N only work for subscribers
+ o Added MIME handling for the footer (controlled by 'footer_mime')
 1.2.8
  o Don't closedir() before done (GOOD spotting Christian Laursen)
  o Make sure the resend of queue files will not loop indefinately
include/do_all_the_voodo_here.h +1 -1
diff -ru mlmmj-1.2.9-RC2/include/do_all_the_voodo_here.h mlmmj-1.2.9-RC2-jh1/include/do_all_the_voodo_here.h
@@ -30,6 +30,6 @@
 void getinfo(const char *line, struct mailhdr *readhdrs);
 int do_all_the_voodo_here(int infd, int outfd, int hdrfd, int footfd,
 	      const char **delhdrs, struct mailhdr *readhdrs,
-	      struct strlist *allhdrs, const char *subjectprefix);
+	      struct strlist *allhdrs, const char *subjectprefix, int footmime);
 
 #endif /* DO_ALL_THE_VOODO_HERE_H */
src/do_all_the_voodo_here.c +150 -76

258 lines not on this page · raw message

Only in mlmmj-1.2.9-RC2-jh1/src: .do_all_the_voodo_here.c.swp

src/mlmmj-process.c +11 -4
diff -ru mlmmj-1.2.9-RC2/src/mlmmj-process.c mlmmj-1.2.9-RC2-jh1/src/mlmmj-process.c
@@ -315,10 +315,10 @@
 {
 	int i, j, opt, noprocess = 0, moderated = 0;
 	int hdrfd, footfd, rawmailfd, donemailfd;
-	int subonlypost = 0, addrtocc = 1, intocc = 0;
+	int subonlypost = 0, addrtocc = 1, intocc = 0, footmime = 0;
 	int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0;
 	char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL;
-	char *footerfilename = NULL, *donemailname = NULL;
+	char *footerfilename = NULL, *donemailname = NULL, *footmimestr = NULL;
 	char *randomstr = NULL, *mqueuename;
 	char *mlmmjsend, *mlmmjsub, *mlmmjunsub, *mlmmjbounce;
 	char *bindir, *subjectprefix, *discardname, *listaddr, *listdelim;
@@ -453,10 +453,17 @@
 	delheaders->strs[delheaders->count] = NULL;
 	
 	subjectprefix = ctrlvalue(listdir, "prefix");	
+
+	if ((footfd >= 0) && 
+		(footmimestr = ctrlvalue(listdir, "footer_mime")) )
+	{
+		footmime = atoi(footmimestr);
+		myfree(footmimestr);
+	}
 	
 	if(do_all_the_voodo_here(rawmailfd, donemailfd, hdrfd, footfd,
 				(const char**)delheaders->strs, readhdrs,
-				&allheaders, subjectprefix) < 0) {
+				&allheaders, subjectprefix, footmime) < 0) {
 		log_error(LOG_ARGS, "Error in do_all_the_voodo_here");
 		exit(EXIT_FAILURE);
 	}
@@ -550,7 +557,7 @@
 			}
 			if(do_all_the_voodo_here(rawmailfd, donemailfd, -1,
 					-1, (const char**)delheaders->strs,
-					NULL, &allheaders, NULL) < 0) {
+					NULL, &allheaders, NULL, 0) < 0) {
 				log_error(LOG_ARGS, "do_all_the_voodo_here");
 				exit(EXIT_FAILURE);
 			}
TUNABLES +18 -0
diff -ru mlmmj-1.2.9-RC2/TUNABLES mlmmj-1.2.9-RC2-jh1/TUNABLES
@@ -151,3 +151,21 @@
 
    This specifies what to use as recipient delimiter for the list.
    Default is "+".
+
+ ��� footer				(normal)
+   
+   The contents in this file are added to every message to the list members.
+
+ ��� footer_mime			(integer)
+
+   The value in this file controls the MIME handling. It is ignored if there
+   is no footer.
+
+	0	Add the plain footer (default, same as a emtpy or nonexisting file).
+	1	If the message is a MIME message, the footer is added in a new MIME part.
+		Else simply append the plain text.
+	2	Rebuild every message into a MIME message and add the footer as a MIME
+		part.
+	3	same as 2, but you have to use your own MIME headers (useful for special
+		character sets etc.)
+
#1 lore raw
Quoted 3 lines · Jakob Hirsch
Quoted 1 line

http://mlmmj.mmj.dk/files/mlmmj-1.2.9-RC2.tar.bz2

nice!

Last chance for 1.2.9 final patches.

Quoted 12 lines

And I finally reworked the infamous MIME footer patch. The behaviour is now controlled by a new control (footer_mime).

There are some major changes in the vodoo file:
- rebuild the while loop that works through the headers
- removed the strlen(hdrline)=1 check. gethdrline() never returns more than one LF and it's always the rightmost character.
- removed the special handling of headers starting with "mime" (usually only the "MIME-Version" header). What was the purpose of it? AFAIK it's a header like every else.
- the result of every writen() is checked now

Quoted 2 lines

The changes are really big, but the code is much clearer now and fairly straightforward. As always, comments welcome.

It's nice and fine, but too big to go in 1.2.9 at this point. 1.2.10-RC1 will have it.

Signature · 4 lines
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                 -- A. P. J.
#2 lore raw
In reply to Jakob Hirsch
Quoted 4 lines · Mads Martin Joergensen
Quoted 2 lines

The changes are really big, but the code is much clearer now and fairly straightforward. As always, comments welcome.

It's nice and fine, but too big to go in 1.2.9 at this point. 1.2.10-RC1 will have it.

That's fine with me, anybody needing it can use the patch for now. And there is a small change needed...

Something different: I get the following in my mail log when a mail is sent to a list. The list is low traffic, so it didn't appear before.

Dec 14 16:56:35 ymmv /usr/local/bin/mlmmj-process[24558]:
subscriberfuncs.c:61: Could not mmap fd: Invalid argument
Dec 14 16:56:35 ymmv /usr/local/bin/mlmmj-send[24558]:

getaddrsfromfd.c:27: Could not mmap fd: Invalid argument

The error looks bad, but messages are sent out fine.

#3 lore raw
In reply to Jakob Hirsch
Quoted 1 line · Jakob Hirsch

And there is a small change needed...

For footer_mime >= 1 it didn't check if a MIME-Version header was present. Fixed now.

ChangeLog +2 -0
diff -ur mlmmj-1.2.9/ChangeLog mlmmj-1.2.9-jh1/ChangeLog
@@ -1,3 +1,5 @@
+1.2.10
+ o Added MIME handling for the footer, see 'footer_mime' (Jakob Hirsch)
 1.2.9
  o Make find_email_adr() more robust (BSD, Neale Pickett)
  o Make the email address check case-insensitive. (Neale Pickett)
include/do_all_the_voodo_here.h +1 -1
diff -ur mlmmj-1.2.9/include/do_all_the_voodo_here.h mlmmj-1.2.9-jh1/include/do_all_the_voodo_here.h
@@ -30,6 +30,6 @@
 void getinfo(const char *line, struct mailhdr *readhdrs);
 int do_all_the_voodo_here(int infd, int outfd, int hdrfd, int footfd,
 	      const char **delhdrs, struct mailhdr *readhdrs,
-	      struct strlist *allhdrs, const char *subjectprefix);
+	      struct strlist *allhdrs, const char *subjectprefix, int footmime);
 
 #endif /* DO_ALL_THE_VOODO_HERE_H */
src/do_all_the_voodo_here.c +156 -76

264 lines not on this page · raw message

src/mlmmj-process.c +11 -4
diff -ur mlmmj-1.2.9/src/mlmmj-process.c mlmmj-1.2.9-jh1/src/mlmmj-process.c
@@ -315,10 +315,10 @@
 {
 	int i, j, opt, noprocess = 0, moderated = 0;
 	int hdrfd, footfd, rawmailfd, donemailfd;
-	int subonlypost = 0, addrtocc = 1, intocc = 0;
+	int subonlypost = 0, addrtocc = 1, intocc = 0, footmime = 0;
 	int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0;
 	char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL;
-	char *footerfilename = NULL, *donemailname = NULL;
+	char *footerfilename = NULL, *donemailname = NULL, *footmimestr = NULL;
 	char *randomstr = NULL, *mqueuename;
 	char *mlmmjsend, *mlmmjsub, *mlmmjunsub, *mlmmjbounce;
 	char *bindir, *subjectprefix, *discardname, *listaddr, *listdelim;
@@ -453,10 +453,17 @@
 	delheaders->strs[delheaders->count] = NULL;
 	
 	subjectprefix = ctrlvalue(listdir, "prefix");	
+
+	if ((footfd >= 0) && 
+		(footmimestr = ctrlvalue(listdir, "footer_mime")) )
+	{
+		footmime = atoi(footmimestr);
+		myfree(footmimestr);
+	}
 	
 	if(do_all_the_voodo_here(rawmailfd, donemailfd, hdrfd, footfd,
 				(const char**)delheaders->strs, readhdrs,
-				&allheaders, subjectprefix) < 0) {
+				&allheaders, subjectprefix, footmime) < 0) {
 		log_error(LOG_ARGS, "Error in do_all_the_voodo_here");
 		exit(EXIT_FAILURE);
 	}
@@ -550,7 +557,7 @@
 			}
 			if(do_all_the_voodo_here(rawmailfd, donemailfd, -1,
 					-1, (const char**)delheaders->strs,
-					NULL, &allheaders, NULL) < 0) {
+					NULL, &allheaders, NULL, 0) < 0) {
 				log_error(LOG_ARGS, "do_all_the_voodo_here");
 				exit(EXIT_FAILURE);
 			}
TUNABLES +18 -0
diff -ur mlmmj-1.2.9/TUNABLES mlmmj-1.2.9-jh1/TUNABLES
@@ -151,3 +151,21 @@
 
    This specifies what to use as recipient delimiter for the list.
    Default is "+".
+
+ ��� footer				(normal)
+   
+   The contents in this file are added to every message to the list members.
+
+ ��� footer_mime			(integer)
+
+   The value in this file controls the MIME handling. It is ignored if there
+   is no footer.
+
+	0	Add the plain footer (default, same as a emtpy or nonexisting file).
+	1	If the message is a MIME message, the footer is added in a new MIME part.
+		Else simply append the plain text.
+	2	Rebuild every message into a MIME message and add the footer as a MIME
+		part.
+	3	same as 2, but you have to use your own MIME headers (useful for special
+		character sets etc.)
+