1 message in net.sourceforge.lists.courier-users[courier-users] [PATCH] more configur...
FromSent OnAttachments
Marcin SemeniukSep 26, 2006 3:40 am.patch
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[courier-users] [PATCH] more configurable dsn messagesActions...
From:Marcin Semeniuk (m.se@net.icm.edu.pl)
Date:Sep 26, 2006 3:40:38 am
List:net.sourceforge.lists.courier-users
Attachments:

Hello Sam,

I noticed that there is no simple way (without patching courier) to change dsn message in such way it can contain two (or more) languages, and each language have full set of information (servername, time, ip address). Besides reading format strings (like %s) from files, isn't very secure, courier can be easy broken by just adding one %s to /etc/courier/dsnheader file (so dsn messages can't be sent, and lots of empty notifications will be sent to users).

I made a patch (I was trying to do it in similar way as are done templates in sqwebmail), now dsnheader file can contain tags like [#ME#], which are later replaced by value of config_me(). So now server administrator can have dsnheader which can support two or more languages, and in part of message for each language, it can contain server address (and other information that are now inserted by courier in place of %s).

Additionally in my approach server administrator can change order of information (ex. he can insert time before server name).

best regards, Marcin Semeniuk

Index: courier-0.53.2/courier/module.dsn/dsn.c =================================================================== RCS file:
/home/cvs/uwmail/sources/courier/courier-0.53.2/courier/module.dsn/dsn.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 dsn.c --- courier-0.53.2/courier/module.dsn/dsn.c 6 Jun 2006 08:38:08 -0000 1.1.1.1 +++ courier-0.53.2/courier/module.dsn/dsn.c 26 Sep 2006 09:31:26 -0000 @@ -704,6 +704,60 @@ return (0); }

+static void print_header(FILE *f, char *template, const char *me, const char
*from_time, const char *from_mta) +{ + unsigned char c, c2; + int i = 0; + + while ((c=template[i++]) > 0) { + char kw[64]; + if (c != '[') + { + fprintf(f,"%c", c); + continue; + } + + if ((c=template[i++]) != '#') + { + fprintf(f, "%c", '['); + continue; + } + c=template[i++]; + + c2=0; + while (c != 0 && (isalnum(c) || c == '_')) + { + if (c2 < sizeof(kw)-1) + kw[c2++]=c; + c=template[i++]; + } + kw[c2]=0; + + if (c != '#') + { + fprintf(f, "[#%s", kw); + continue; + } + + if ((c=template[i++]) != ']') + { + fprintf(f, "[#%s#", kw); + continue; + } + + if (strcmp(kw, "ME") == 0) + { + fprintf(f, "%s", me); + } + else if (strcmp(kw, "FROMTIME") == 0) + { + fprintf(f, "%s", from_time); + } + else if (strcmp(kw, "FROMMTA") == 0) + fprintf(f, "%s", from_mta); + } +} + static int dodsn(struct ctlfile *ctf, FILE *fp, const char *sender, int dodelayed) { @@ -799,7 +853,7 @@

from_time=rfc822_mkdate(stat_buf.st_mtime);

- fprintf(fp, dsnheader, config_me(), from_time, + print_header(fp, dsnheader, config_me(), from_time, from_mta_p && *from_mta_p ? from_mta_p:"unknown");

if (dodelayed) Index: courier-0.53.2/courier/module.dsn/dsnheader.txt.in =================================================================== RCS file:
/home/cvs/uwmail/sources/courier/courier-0.53.2/courier/module.dsn/dsnheader.txt.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 dsnheader.txt.in --- courier-0.53.2/courier/module.dsn/dsnheader.txt.in 6 Jun 2006 08:38:08 -0000
1.1.1.1 +++ courier-0.53.2/courier/module.dsn/dsnheader.txt.in 26 Sep 2006 10:07:29
-0000 @@ -1,8 +1,8 @@ Content-Type: text/plain; charset=us-ascii

-This is a delivery status notification from %s, +This is a delivery status notification from [#ME#], running the Courier mail server, version @version@.

-The original message was received on %s -from %s +The original message was received on [#FROMTIME#] +from [#FROMMTA#]