Mercurial > hg > mlmmj
changeset 480:e47f5d7b8ddd
Avoid possible race wrt. moderation
author | mmj |
---|---|
date | Thu, 28 Apr 2005 04:02:10 +1000 |
parents | 6ce0bff8ee30 |
children | 3d3c60ef5667 |
files | ChangeLog Makefile.am src/listcontrol.c |
diffstat | 3 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Apr 26 20:24:15 2005 +1000 +++ b/ChangeLog Thu Apr 28 04:02:10 2005 +1000 @@ -1,3 +1,5 @@ + o When sending moderated mails, rename them so that they wont be moderated + again while sending 1.2.5 o Make listname+list send the list of regular subscribers to the owner who requested it.
--- a/Makefile.am Tue Apr 26 20:24:15 2005 +1000 +++ b/Makefile.am Thu Apr 28 04:02:10 2005 +1000 @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 EXTRA_DIST = include VERSION LICENSE UPGRADE src/log_error.c FAQ \ TUNABLES README.access contrib man listtexts/de \ - listtexts/da + listtexts/da README.exim4 README.sendmail CLEANFILES = *~ mlmmj-*.tar.* dist-hook:
--- a/src/listcontrol.c Tue Apr 26 20:24:15 2005 +1000 +++ b/src/listcontrol.c Thu Apr 28 04:02:10 2005 +1000 @@ -102,7 +102,7 @@ { char *atsign, *recipdelimsign, *bouncenr, *tmpstr; char *controlstr, *param, *conffilename, *moderatefilename; - char *c, *archivefilename; + char *c, *archivefilename, *sendfilename; const char *subswitch; size_t len; struct stat stbuf; @@ -483,16 +483,25 @@ /* TODO Add accept/reject parameter to moderate */ unlink(mailname); moderatefilename = concatstr(3, listdir, "/moderation/", param); + sendfilename = concatstr(2, moderatefilename, ".sending"); myfree(param); + if(stat(moderatefilename, &stbuf) < 0) { myfree(moderatefilename); exit(EXIT_SUCCESS); /* just exit, no mail to moderate */ } + /* Rename it to avoid mail being sent twice */ + if(rename(moderatefilename, sendfilename) < 0) { + log_error(LOG_ARGS, "Could not rename to .sending"); + exit(EXIT_FAILURE); + } + log_oper(listdir, OPLOGFNAME, "%s moderated %s", fromemails->emaillist[0], moderatefilename); + myfree(moderatefilename); execlp(mlmmjsend, mlmmjsend, "-L", listdir, - "-m", moderatefilename, (char *)NULL); + "-m", sendfilename, (char *)NULL); log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); exit(EXIT_FAILURE);