From: mmj Date: Wed, 27 Apr 2005 18:02:10 +0000 (+1000) Subject: Avoid possible race wrt. moderation X-Git-Tag: RELEASE_1_2_12_RC1~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abf67332fad90c036da098f8a787beff3c2641d3;p=thirdparty%2Fmlmmj.git Avoid possible race wrt. moderation --- diff --git a/ChangeLog b/ChangeLog index e7d7b237..fd25bf18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/Makefile.am b/Makefile.am index 4af500e0..30235671 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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: diff --git a/src/listcontrol.c b/src/listcontrol.c index c7a42c48..3ef5bf12 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -102,7 +102,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, { 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 @@ int listcontrol(struct email_container *fromemails, const char *listdir, /* 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);