Mercurial > hg > mlmmj
changeset 601:f98f595b77b6
Fixed requeue for lists with noarchive enabled
author | xi |
---|---|
date | Wed, 15 Nov 2006 00:15:54 +1100 |
parents | f1155f6b2812 |
children | 0b274cc500de |
files | ChangeLog src/mlmmj-maintd.c src/mlmmj-send.c |
diffstat | 3 files changed, 62 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Nov 14 08:52:18 2006 +1100 +++ b/ChangeLog Wed Nov 15 00:15:54 2006 +1100 @@ -1,3 +1,4 @@ + o Fixed requeue for lists with noarchive enabled 1.2.12 o Fixed memory corruption in cleanquotedp() o Fixed bug in gethdrline() introduced in 1.2.12-RC3
--- a/src/mlmmj-maintd.c Tue Nov 14 08:52:18 2006 +1100 +++ b/src/mlmmj-maintd.c Wed Nov 15 00:15:54 2006 +1100 @@ -371,7 +371,7 @@ struct stat st; pid_t childpid, pid; time_t t; - int status; + int status, fromrequeuedir = 0; if(chdir(dirname) < 0) { log_error(LOG_ARGS, "Could not chdir(%s)", dirname); @@ -412,10 +412,22 @@ * continue */ myfree(archivefilename); + + /* If the list is set not to archive we want to look + * in /requeue/ for a mailfile + */ + archivefilename = concatstr(4, listdir, "/requeue/", + dp->d_name, "/mailfile"); + if(stat(archivefilename, &st) < 0) { + myfree(archivefilename); continue; } + fromrequeuedir = 1; + } subfilename = concatstr(3, dirname, dp->d_name, "/subscribers"); if(stat(subfilename, &st) < 0) { + if (fromrequeuedir) + unlink(archivefilename); myfree(archivefilename); myfree(subfilename); continue;
--- a/src/mlmmj-send.c Tue Nov 14 08:52:18 2006 +1100 +++ b/src/mlmmj-send.c Wed Nov 15 00:15:54 2006 +1100 @@ -73,6 +73,34 @@ gotsigterm = 1; } +char *get_index_from_filename(const char *filename) +{ + char *myfilename, *indexstr, *ret; + size_t len; + + myfilename = mystrdup(filename); + if (!myfilename) { + return NULL; + } + + len = strlen(myfilename); + if (len > 9 && (strcmp(myfilename + len - 9, "/mailfile") == 0)) { + myfilename[len - 9] = '\0'; + } + + indexstr = strrchr(myfilename, '/'); + if (indexstr) { + indexstr++; /* skip the slash */ + } else { + indexstr = myfilename; + } + + ret = mystrdup(indexstr); + myfree(myfilename); + + return ret; +} + char *bounce_from_adr(const char *recipient, const char *listadr, const char *listdelim, const char *mailfilename) { @@ -85,12 +113,7 @@ return NULL; } - indexstr = strrchr(mymailfilename, '/'); - if (indexstr) { - indexstr++; /* skip the slash */ - } else { - indexstr = mymailfilename; - } + indexstr = get_index_from_filename(mymailfilename); myrecipient = mystrdup(recipient); if (!myrecipient) { @@ -142,6 +165,7 @@ myfree(myrecipient); myfree(mylistadr); myfree(mylistdelim); + myfree(indexstr); myfree(mymailfilename); return bounceaddr; @@ -579,7 +603,7 @@ const char *mlmmjbounce, const char *hdrs, size_t hdrslen, const char *body, size_t bodylen) { - int res = 0, i; + int res = 0, i, status; char *bounceaddr, *addr, *index; for(i = 0; i < addrs->count; i++) { @@ -594,8 +618,10 @@ /* we got SIGTERM, so save the addresses and bail */ log_error(LOG_ARGS, "TERM signal recieved, " "shutting down."); - index = mybasename(archivefilename); - return requeuemail(listdir, index, addrs, i); + index = get_index_from_filename(archivefilename); + status = requeuemail(listdir, index, addrs, i); + myfree(index); + return status; } if(from) { res = send_mail(sockfd, from, addr, replyto, @@ -611,8 +637,10 @@ } if(res && listaddr && archivefilename) { /* we failed, so save the addresses and bail */ - index = mybasename(archivefilename); - return requeuemail(listdir, index, addrs, i); + index = get_index_from_filename(archivefilename); + status = requeuemail(listdir, index, addrs, i); + myfree(index); + return status; } } return 0; @@ -659,7 +687,7 @@ char *mlmmjbounce = NULL, *bindir, *mailmap, *probefile, *a; char *body = NULL, *hdrs = NULL, *memmailsizestr = NULL, *verp = NULL; char relay[16], *listname, *listfqdn, *verpfrom, *maxverprecipsstr; - char strindex[32], *reply, *strport; + char strindex[32], *reply, *strport, *requeuefilename; ssize_t memmailsize = 0; DIR *subddir; struct dirent *dp; @@ -1227,7 +1255,13 @@ archivefilename); } } else { + len = strlen(listdir) + 9 + 20 + 9; + requeuefilename = mymalloc(len); + snprintf(requeuefilename, len, "%s/requeue/%d/mailfile", listdir, + mindex); + if (rename(mailfilename, requeuefilename) < 0) unlink(mailfilename); + myfree(requeuefilename); } myfree(archivefilename); } else if(deletewhensent)