From: Baptiste Daroussin Date: Wed, 28 Dec 2022 13:51:51 +0000 (+0100) Subject: Convert textcontent and ctrlcontent to ctrlvalue X-Git-Tag: RELEASE_1_4_0_a2~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bb1326d58e49ca3e96c4baf96d2264daadd1a07;p=thirdparty%2Fmlmmj.git Convert textcontent and ctrlcontent to ctrlvalue --- diff --git a/include/ctrlvalue.h b/include/ctrlvalue.h index afa469b1..48c31b90 100644 --- a/include/ctrlvalue.h +++ b/include/ctrlvalue.h @@ -29,8 +29,8 @@ #include char *ctrlvalue(int ctrlfd, const char *ctrlstr); -char *ctrlcontent(const char *listdir, const char *ctrlstr); -char *textcontent(const char *listdir, const char *ctrlstr); +char *ctrlcontent(int ctrlfd, const char *ctrlstr); +char *textcontent(int listfd, const char *ctrlstr); intmax_t ctrlim(int ctrlfd, const char *ctrlstr, intmax_t min, intmax_t max, intmax_t fallback); uintmax_t ctrluim(int ctrlfd, const char *ctrlstr, uintmax_t min, diff --git a/include/listcontrol.h b/include/listcontrol.h index 70d6fb4b..78316d95 100644 --- a/include/listcontrol.h +++ b/include/listcontrol.h @@ -29,6 +29,6 @@ int listcontrol(struct email_container *fromemails, const char *listdir, const char *controlstr, const char *mlmmjsub, const char *mlmmjunsub, const char *mlmmjsend, - const char *mailname, int fd); + const char *mailname, int listfd, int ctrlfd); #endif /* LISTCONTROL_H */ diff --git a/include/prepstdreply.h b/include/prepstdreply.h index 66790060..d807727a 100644 --- a/include/prepstdreply.h +++ b/include/prepstdreply.h @@ -51,7 +51,7 @@ const char *get_file_line(void *state); void finish_file_lines(file_lines_state *s); char *substitute(const char *line, const char *listaddr, const char *listdelim, - const char *listdir, text *txt); + int listfd, int ctrlfd, text *txt); text *open_text_file(const char *listdir, const char *filename); text *open_text(const char *listdir, const char *purpose, const char *action, @@ -61,9 +61,9 @@ void register_originalmail(text *txt, const char *mailname); void register_formatted(text *txt, const char *token, rewind_function rew, get_function get, void * state); char *get_processed_text_line(text *txt, int headers, - const char *listaddr, const char *listdelim, const char *listdir, int ctrlfd); + const char *listaddr, const char *listdelim, const char *listdir, int listfd, int ctrlfd); char *prepstdreply(text *txt, const char *listdir, - const char *from, const char *to, const char *replyto, int ctrlfd); + const char *from, const char *to, const char *replyto, int listfd, int ctrlfd); void close_text(text *txt); #endif /* PREPSTDREPLY_H */ diff --git a/include/send_digest.h b/include/send_digest.h index 4ebcd107..d9fb6456 100644 --- a/include/send_digest.h +++ b/include/send_digest.h @@ -25,6 +25,6 @@ #define SEND_DIGEST_H int send_digest(const char *listdir, int lastindex, int index, - int issue, const char *addr, const char *mlmmjsend, int ctrlfd); + int issue, const char *addr, const char *mlmmjsend, int listfd, int ctrlfd); #endif /* SEND_DIGEST_H */ diff --git a/include/send_list.h b/include/send_list.h index 9b1af989..986aa689 100644 --- a/include/send_list.h +++ b/include/send_list.h @@ -25,6 +25,6 @@ #define SEND_LIST_H void send_list(const char *listdir, const char *emailaddr, - const char *mlmmjsend, int ctrlfd); + const char *mlmmjsend, int ctrlfd, int listfd); #endif diff --git a/src/ctrlvalue.c b/src/ctrlvalue.c index 4be678e1..0aea7b0a 100644 --- a/src/ctrlvalue.c +++ b/src/ctrlvalue.c @@ -39,7 +39,7 @@ #include "xmalloc.h" static char * -_ctrlval(int ctrlfd, const char *ctrlstr, int oneline) +ctrlval(int ctrlfd, const char *ctrlstr, int oneline) { int fd; FILE *fp; @@ -72,48 +72,25 @@ _ctrlval(int ctrlfd, const char *ctrlstr, int oneline) return (buf); } -static char *ctrlvalat(int dfd, const char *subdir, - const char *ctrlstr, int oneline) +char * +ctrlvalue(int ctrlfd, const char *ctrlstr) { - char *buf; - int ctrlfd; - - if (dfd == -1) - return NULL; - - ctrlfd = openat(dfd, subdir, O_DIRECTORY|O_CLOEXEC); - - if(ctrlfd < 0) - return NULL; - - buf = _ctrlval(ctrlfd, ctrlstr, oneline); - close(ctrlfd); - return (buf); + return (ctrlval(ctrlfd, ctrlstr, true)); } -static char *ctrlval(const char *listdir, const char *subdir, - const char *ctrlstr, int oneline) +char * +ctrlcontent(int ctrlfd, const char *ctrlstr) { - int dfd = open(listdir, O_DIRECTORY|O_CLOEXEC); - char *ret = ctrlvalat(dfd, subdir, ctrlstr, oneline); - if (dfd != -1) - close(dfd); - return (ret); -} - -char *ctrlvalue(int ctrlfd, const char *ctrlstr) -{ - return (_ctrlval(ctrlfd, ctrlstr, true)); + return (ctrlval(ctrlfd, ctrlstr, false)); } -char *ctrlcontent(const char *listdir, const char *ctrlstr) +char * +textcontent(int listfd, const char *ctrlstr) { - return ctrlval(listdir, "control", ctrlstr, 0); -} - -char *textcontent(const char *listdir, const char *ctrlstr) -{ - return ctrlval(listdir, "text", ctrlstr, 0); + int fd = openat(listfd, "text", O_DIRECTORY|O_CLOEXEC); + char *ret = ctrlval(fd, ctrlstr, false); + close(fd); + return (ret); } intmax_t @@ -121,7 +98,7 @@ ctrlim(int ctrlfd, const char *ctrlstr, intmax_t min, intmax_t max, intmax_t fallback) { const char *errstr; - char *val = _ctrlval(ctrlfd, ctrlstr, true); + char *val = ctrlval(ctrlfd, ctrlstr, true); intmax_t ret; if (val == NULL) @@ -142,7 +119,7 @@ ctrluim(int ctrlfd, const char *ctrlstr, uintmax_t min, uintmax_t max, uintmax_t fallback) { const char *errstr; - char *val = _ctrlval(ctrlfd, ctrlstr, true); + char *val = ctrlval(ctrlfd, ctrlstr, true); uintmax_t ret; if (val == NULL) @@ -162,7 +139,7 @@ time_t ctrltimet(int dfd, const char *ctrlstr, time_t fallback) { const char *errstr; - char *val = _ctrlval(dfd, ctrlstr, true); + char *val = ctrlval(dfd, ctrlstr, true); time_t ret; if (val == NULL) diff --git a/src/listcontrol.c b/src/listcontrol.c index 2d5db856..928b71d7 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -115,7 +115,7 @@ static struct ctrl_command ctrl_commands[] = { int listcontrol(struct email_container *fromemails, const char *listdir, const char *controlstr, const char *mlmmjsub, const char *mlmmjunsub, const char *mlmmjsend, - const char *mailname, int ctrlfd) + const char *mailname, int listfd, int ctrlfd) { char *bouncenr, *tmpstr; char *param = NULL, *conffilename, *moderatefilename, *gatekeepfilename; @@ -134,7 +134,6 @@ int listcontrol(struct email_container *fromemails, const char *listdir, const char *subtype = NULL; const char *subtypename = NULL; bounce_t bret; - int listfd; /* A closed list doesn't allow subscribtion and unsubscription */ closedlist = statctrl(ctrlfd, "closedlist"); @@ -233,7 +232,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, fromemails->emaillist[0]); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, ctrlfd); + fromemails->emaillist[0], NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, @@ -275,7 +274,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, fromemails->emaillist[0]); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, ctrlfd); + fromemails->emaillist[0], NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, @@ -317,7 +316,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, fromemails->emaillist[0]); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, ctrlfd); + fromemails->emaillist[0], NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, @@ -695,7 +694,7 @@ permit: txt = open_text(listdir, "help", NULL, NULL, NULL, "listhelp"); MY_ASSERT(txt); queuefilename = prepstdreply(txt, listdir, - "$listowner$", fromemails->emaillist[0], NULL, ctrlfd); + "$listowner$", fromemails->emaillist[0], NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, @@ -717,7 +716,7 @@ permit: txt = open_text(listdir, "faq", NULL, NULL, NULL, "listfaq"); MY_ASSERT(txt); queuefilename = prepstdreply(txt, listdir, - "$listowner$", fromemails->emaillist[0], NULL, ctrlfd); + "$listowner$", fromemails->emaillist[0], NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, @@ -792,7 +791,8 @@ permit: " Ignoring mail"); return -1; } else { - send_list(listdir, owners->strs[owner_idx], mlmmjsend, ctrlfd); + send_list(listdir, owners->strs[owner_idx], mlmmjsend, + listfd, ctrlfd); } break; diff --git a/src/mlmmj-bounce.c b/src/mlmmj-bounce.c index cdae8c17..ce5aaa86 100644 --- a/src/mlmmj-bounce.c +++ b/src/mlmmj-bounce.c @@ -53,7 +53,8 @@ #include "utils.h" -void do_probe(const char *listdir, const char *mlmmjsend, const char *addr, int ctrlfd) +void do_probe(const char *listdir, const char *mlmmjsend, const char *addr, + int listfd, int ctrlfd) { text *txt; file_lines_state *fls; @@ -92,7 +93,7 @@ void do_probe(const char *listdir, const char *mlmmjsend, const char *addr, int fls = init_truncated_file_lines(addr, 0, ':'); register_formatted(txt, "bouncenumbers", rewind_file_lines, get_file_line, fls); - queuefilename = prepstdreply(txt, listdir, "$listowner$", myaddr, NULL, ctrlfd); + queuefilename = prepstdreply(txt, listdir, "$listowner$", myaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -231,7 +232,7 @@ int main(int argc, char **argv) if (probe) { /* send out a probe */ - do_probe(listdir, mlmmjsend, address, ctrlfd); + do_probe(listdir, mlmmjsend, address, listfd, ctrlfd); /* do_probe() will never return */ exit(EXIT_FAILURE); } diff --git a/src/mlmmj-maintd.c b/src/mlmmj-maintd.c index 6a5639f1..283e8469 100644 --- a/src/mlmmj-maintd.c +++ b/src/mlmmj-maintd.c @@ -652,7 +652,7 @@ run_digests(int dfd, int ctrlfd, const char *mlmmjsend, const char *listdir, int if (index > lastindex) { lastissue++; - send_digest(listdir, lastindex+1, index, lastissue, NULL, mlmmjsend, ctrlfd); + send_digest(listdir, lastindex+1, index, lastissue, NULL, mlmmjsend, dfd, ctrlfd); } if (lseek(fd, 0, SEEK_SET) < 0) { diff --git a/src/mlmmj-process.c b/src/mlmmj-process.c index dbdfde07..424bae6e 100644 --- a/src/mlmmj-process.c +++ b/src/mlmmj-process.c @@ -129,7 +129,7 @@ static int is_moderator(const char *listdir, const char *address, static void newmoderated(const char *listdir, const char *mailfilename, const char *mlmmjsend, const char *efromsender, const char *subject, const char *posteraddr, - enum modreason modreason, int ctrlfd) + enum modreason modreason, int listfd, int ctrlfd) { char *from, *listfqdn, *listname, *moderators = NULL; char *replyto, *listaddr = getlistaddr(ctrlfd), *listdelim; @@ -183,7 +183,7 @@ static void newmoderated(const char *listdir, const char *mailfilename, rewind_memory_lines, get_memory_line, mls); register_originalmail(txt, mailfilename); queuefilename = prepstdreply(txt, listdir, "$listowner$", to, replyto, - ctrlfd); + listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -204,7 +204,7 @@ static void newmoderated(const char *listdir, const char *mailfilename, rewind_memory_lines, get_memory_line, mls); register_originalmail(txt, mailfilename); queuefilename = prepstdreply(txt, listdir, - "$listowner$", efromsender, NULL, ctrlfd); + "$listowner$", efromsender, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -788,7 +788,7 @@ int main(int argc, char **argv) testfrom = &fromemails; listcontrol(testfrom, listdir, recipextra, mlmmjsub, mlmmjunsub, mlmmjsend, - donemailname, ctrlfd); + donemailname, listfd, ctrlfd); return EXIT_SUCCESS; } @@ -832,7 +832,7 @@ int main(int argc, char **argv) register_unformatted(txt, "maxmailsize", maxmailsizestr); register_originalmail(txt, donemailname); queuefilename = prepstdreply(txt, listdir, - "$listowner$", posteraddr, NULL, ctrlfd); + "$listowner$", posteraddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); free(listdelim); @@ -897,7 +897,7 @@ int main(int argc, char **argv) register_unformatted(txt, "posteraddr", posteraddr); register_originalmail(txt, donemailname); queuefilename = prepstdreply(txt, listdir, - "$listowner$", posteraddr, NULL, ctrlfd); + "$listowner$", posteraddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename) close_text(txt); free(listdelim); @@ -942,7 +942,7 @@ int main(int argc, char **argv) register_unformatted(txt, "posteraddr", posteraddr); register_originalmail(txt, donemailname); queuefilename = prepstdreply(txt, listdir, - "$listowner$", posteraddr, NULL, ctrlfd); + "$listowner$", posteraddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename) close_text(txt); free(listaddr); @@ -1054,7 +1054,7 @@ int main(int argc, char **argv) register_unformatted(txt, "posteraddr", testaddr); register_originalmail(txt, donemailname); queuefilename = prepstdreply(txt, listdir, - "$listowner$", testaddr, NULL, ctrlfd); + "$listowner$", testaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename) close_text(txt); free(listaddr); @@ -1113,7 +1113,7 @@ int main(int argc, char **argv) } newmoderated(listdir, mqueuename, mlmmjsend, efrom, subject, posteraddr, - modreason, ctrlfd); + modreason, listfd, ctrlfd); return EXIT_SUCCESS; } diff --git a/src/mlmmj-sub.c b/src/mlmmj-sub.c index 67974429..8a708829 100644 --- a/src/mlmmj-sub.c +++ b/src/mlmmj-sub.c @@ -53,7 +53,8 @@ static void moderate_sub(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, - const char *mlmmjsend, enum subtype typesub, enum subreason reasonsub, int ctrlfd) + const char *mlmmjsend, enum subtype typesub, enum subreason reasonsub, + int listfd, int ctrlfd) { int i, fd, status; text *txt; @@ -160,7 +161,7 @@ static void moderate_sub(const char *listdir, const char *listaddr, register_formatted(txt, "gatekeepers", rewind_memory_lines, get_memory_line, mls); queuefilename = prepstdreply(txt, listdir, "$listowner$", to, replyto, - ctrlfd); + listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -210,7 +211,7 @@ static void moderate_sub(const char *listdir, const char *listaddr, register_formatted(txt, "gatekeepers", rewind_memory_lines, get_memory_line, mls); queuefilename = prepstdreply(txt, listdir, - "$listowner$", subaddr, NULL, ctrlfd); + "$listowner$", subaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -288,7 +289,8 @@ freedone: void confirm_sub(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, - const char *mlmmjsend, enum subtype typesub, enum subreason reasonsub, int ctrlfd) + const char *mlmmjsend, enum subtype typesub, + enum subreason reasonsub, int listfd, int ctrlfd) { text *txt; char *queuefilename, *fromaddr, *listname, *listfqdn, *listtext; @@ -325,7 +327,7 @@ void confirm_sub(const char *listdir, const char *listaddr, MY_ASSERT(txt); register_unformatted(txt, "subaddr", subaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, NULL, ctrlfd); + "$helpaddr$", subaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -335,7 +337,8 @@ void confirm_sub(const char *listdir, const char *listaddr, void notify_sub(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, - const char *mlmmjsend, enum subtype typesub, enum subreason reasonsub, int ctrlfd) + const char *mlmmjsend, enum subtype typesub, + enum subreason reasonsub, int listfd, int ctrlfd) { char *listfqdn, *listname, *fromaddr, *tostr; text *txt; @@ -375,7 +378,7 @@ void notify_sub(const char *listdir, const char *listaddr, register_unformatted(txt, "subaddr", subaddr); register_unformatted(txt, "newsub", subaddr); /* DEPRECATED */ queuefilename = prepstdreply(txt, listdir, - "$listowner$", "$listowner$", NULL, ctrlfd); + "$listowner$", "$listowner$", NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -385,7 +388,8 @@ void notify_sub(const char *listdir, const char *listaddr, void generate_subconfirm(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, - const char *mlmmjsend, enum subtype typesub, enum subreason reasonsub, int ctrlfd) + const char *mlmmjsend, enum subtype typesub, + enum subreason reasonsub, int listfd, int ctrlfd) { int subconffd; char *confirmaddr, *listname, *listfqdn, *confirmfilename = NULL; @@ -465,7 +469,7 @@ void generate_subconfirm(const char *listdir, const char *listaddr, register_unformatted(txt, "confaddr", confirmaddr); /* DEPRECATED */ register_unformatted(txt, "confirmaddr", confirmaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, confirmaddr, ctrlfd); + "$helpaddr$", subaddr, confirmaddr, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -501,7 +505,7 @@ static void print_help(const char *prg) void generate_subscribed(const char *listdir, const char *subaddr, const char *mlmmjsend, enum subtype typesub, const char *listaddr, - const char *listdelim, int ctrlfd) + const char *listdelim, int listfd, int ctrlfd) { text *txt; char *queuefilename, *fromaddr, *listname, *listfqdn; @@ -517,7 +521,7 @@ void generate_subscribed(const char *listdir, const char *subaddr, MY_ASSERT(txt); register_unformatted(txt, "subaddr", subaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, NULL, ctrlfd); + "$helpaddr$", subaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -704,7 +708,7 @@ int main(int argc, char **argv) if(subbed == typesub) { if(!nogensubscribed) generate_subscribed(listdir, address, mlmmjsend, - typesub, listaddr, listdelim, ctrlfd); + typesub, listaddr, listdelim, listfd, ctrlfd); return EXIT_SUCCESS; } else if(subbed != SUB_NONE) { reasonsub = SUB_SWITCH; @@ -727,12 +731,13 @@ int main(int argc, char **argv) if(subbed == SUB_NONE && subconfirm) generate_subconfirm(listdir, listaddr, listdelim, - address, mlmmjsend, typesub, reasonsub, ctrlfd); + address, mlmmjsend, typesub, reasonsub, listfd, ctrlfd); if(modstr == NULL && subbed == SUB_NONE && !force && statctrl(ctrlfd, "submod")) { moderate_sub(listdir, listaddr, listdelim, - address, mlmmjsend, typesub, reasonsub, ctrlfd); + address, mlmmjsend, typesub, reasonsub, listfd, + ctrlfd); } if (typesub == SUB_BOTH) { @@ -752,7 +757,7 @@ int main(int argc, char **argv) if(childpid < 0) { log_error(LOG_ARGS, "Could not fork; owner not notified"); confirm_sub(listdir, listaddr, listdelim, address, - mlmmjsend, typesub, reasonsub, ctrlfd); + mlmmjsend, typesub, reasonsub, listfd, ctrlfd); } if(childpid > 0) { @@ -764,7 +769,7 @@ int main(int argc, char **argv) /* child confirms subscription */ if(childpid == 0) confirm_sub(listdir, listaddr, listdelim, address, - mlmmjsend, typesub, reasonsub, ctrlfd); + mlmmjsend, typesub, reasonsub, listfd, ctrlfd); } notifysub = !quiet && reasonsub != SUB_SWITCH && @@ -773,7 +778,7 @@ int main(int argc, char **argv) /* Notify list owner about subscription */ if (notifysub) notify_sub(listdir, listaddr, listdelim, address, mlmmjsend, - typesub, reasonsub, ctrlfd); + typesub, reasonsub, listfd, ctrlfd); free(address); free(listaddr); diff --git a/src/mlmmj-unsub.c b/src/mlmmj-unsub.c index 472f5d43..1fe08a1f 100644 --- a/src/mlmmj-unsub.c +++ b/src/mlmmj-unsub.c @@ -52,7 +52,8 @@ void confirm_unsub(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, const char *mlmmjsend, - enum subtype typesub, enum subreason reasonsub, int ctrlfd) + enum subtype typesub, enum subreason reasonsub, int listfd, + int ctrlfd) { text *txt; char *queuefilename, *fromaddr, *listname, *listfqdn, *listtext; @@ -85,7 +86,7 @@ void confirm_unsub(const char *listdir, const char *listaddr, MY_ASSERT(txt); register_unformatted(txt, "subaddr", subaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, NULL, ctrlfd); + "$helpaddr$", subaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -96,7 +97,7 @@ void confirm_unsub(const char *listdir, const char *listaddr, void notify_unsub(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, const char *mlmmjsend, - enum subtype typesub, enum subreason reasonsub, int ctrlfd) + enum subtype typesub, enum subreason reasonsub, int listfd, int ctrlfd) { char *listfqdn, *listname, *fromaddr, *tostr; text *txt; @@ -132,7 +133,7 @@ void notify_unsub(const char *listdir, const char *listaddr, register_unformatted(txt, "subaddr", subaddr); register_unformatted(txt, "oldsub", subaddr); /* DEPRECATED */ queuefilename = prepstdreply(txt, listdir, - "$listowner$", "$listowner$", NULL, ctrlfd); + "$listowner$", "$listowner$", NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -144,7 +145,7 @@ void notify_unsub(const char *listdir, const char *listaddr, void generate_unsubconfirm(const char *listdir, const char *listaddr, const char *listdelim, const char *subaddr, const char *mlmmjsend, - enum subtype typesub, enum subreason reasonsub, int ctrlfd) + enum subtype typesub, enum subreason reasonsub, int listfd, int ctrlfd) { char *confirmaddr, *listname, *listfqdn, *tmpstr; text *txt; @@ -219,7 +220,7 @@ void generate_unsubconfirm(const char *listdir, const char *listaddr, register_unformatted(txt, "confaddr", confirmaddr); /* DEPRECATED */ register_unformatted(txt, "confirmaddr", confirmaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, confirmaddr, ctrlfd); + "$helpaddr$", subaddr, confirmaddr, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -254,7 +255,7 @@ static void print_help(const char *prg) static void generate_notsubscribed(const char *listdir, const char *subaddr, const char *mlmmjsend, enum subtype typesub, const char *listaddr, - const char *listdelim, int ctrlfd) + const char *listdelim, int listfd, int ctrlfd) { text *txt; char *queuefilename, *fromaddr, *listname, *listfqdn; @@ -270,7 +271,7 @@ static void generate_notsubscribed(const char *listdir, const char *subaddr, MY_ASSERT(txt); register_unformatted(txt, "subaddr", subaddr); queuefilename = prepstdreply(txt, listdir, - "$helpaddr$", subaddr, NULL, ctrlfd); + "$helpaddr$", subaddr, NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); @@ -421,7 +422,7 @@ int main(int argc, char **argv) /* Address is not subscribed */ if(!nogennotsubscribed) { generate_notsubscribed(listdir, address, mlmmjsend, - typesub, listaddr, listdelim, ctrlfd); + typesub, listaddr, listdelim, listfd, ctrlfd); } exit(EXIT_SUCCESS); @@ -429,7 +430,7 @@ int main(int argc, char **argv) if(unsubconfirm) generate_unsubconfirm(listdir, listaddr, listdelim, address, - mlmmjsend, typesub, reasonsub, ctrlfd); + mlmmjsend, typesub, reasonsub, listfd, ctrlfd); unsubscribe(listfd, address, typesub); @@ -440,7 +441,7 @@ int main(int argc, char **argv) log_error(LOG_ARGS, "Could not fork"); confirm_unsub(listdir, listaddr, listdelim, address, mlmmjsend, - typesub, reasonsub, ctrlfd); + typesub, reasonsub, listfd, ctrlfd); } if(childpid > 0) { @@ -453,7 +454,7 @@ int main(int argc, char **argv) if(childpid == 0) confirm_unsub(listdir, listaddr, listdelim, address, mlmmjsend, - typesub, reasonsub, ctrlfd); + typesub, reasonsub, listfd, ctrlfd); } notifysub = !quiet && statctrl(ctrlfd, "notifysub"); @@ -461,7 +462,7 @@ int main(int argc, char **argv) /* Notify list owner about subscription */ if (notifysub) notify_unsub(listdir, listaddr, listdelim, address, mlmmjsend, - typesub, reasonsub, ctrlfd); + typesub, reasonsub, listfd, ctrlfd); free(listaddr); free(listdelim); diff --git a/src/prepstdreply.c b/src/prepstdreply.c index d082c664..700d56d6 100644 --- a/src/prepstdreply.c +++ b/src/prepstdreply.c @@ -329,7 +329,7 @@ static char *numeric_token(char *token) static void substitute_one(char **line_p, char **pos_p, int *width_p, const char *listaddr, const char *listdelim, - const char *listdir, text *txt) + int listfd, int ctrlfd, text *txt) { /* It is important for this function to leave the length of the * processed portion unchanged, or increase it by just one ASCII @@ -402,10 +402,10 @@ static void substitute_one(char **line_p, char **pos_p, int *width_p, fqdn); } else if(strncmp(token, "control ", 8) == 0) { token = filename_token(token + 8); - if (token != NULL) value = ctrlcontent(listdir, token); + if (token != NULL) value = ctrlcontent(ctrlfd, token); } else if(strncmp(token, "text ", 5) == 0) { token = filename_token(token + 5); - if (token != NULL) value = textcontent(listdir, token); + if (token != NULL) value = textcontent(listfd, token); } else if(strcmp(token, "originalmail") == 0) { /* DEPRECATED: use %originalmail% instead */ value = xstrdup(" %originalmail 100%"); @@ -442,7 +442,7 @@ static void substitute_one(char **line_p, char **pos_p, int *width_p, char *substitute(const char *line, const char *listaddr, const char *listdelim, - const char *listdir, text *txt) + int listfd, int ctrlfd, text *txt) { char *new; char *pos; @@ -454,7 +454,7 @@ char *substitute(const char *line, const char *listaddr, const char *listdelim, while (*pos != '\0') { if (*pos == '$') { substitute_one(&new, &pos, &width, - listaddr, listdelim, listdir, txt); + listaddr, listdelim, listfd, ctrlfd, txt); /* The function sets up for the next character * to process, so continue straight away. */ continue; @@ -1090,7 +1090,7 @@ static int handle_directive(text *txt, char **line_p, char **pos_p, char *get_processed_text_line(text *txt, int headers, const char *listaddr, const char *listdelim, - const char *listdir, int ctrlfd) + const char *listdir, int listfd, int ctrlfd) { char *line; const char *item; @@ -1351,7 +1351,7 @@ char *get_processed_text_line(text *txt, int headers, } else if (*pos == '$' && txt->skip == NULL) { if (peeking) break; substitute_one(&line, &pos, &width, listaddr, - listdelim, listdir, txt); + listdelim, listfd, ctrlfd, txt); if (len != pos - line) { /* Cancel any break inhibition if the * length changed (which will be @@ -1583,7 +1583,7 @@ void close_text(text *txt) char *prepstdreply(text *txt, const char *listdir, - const char *from, const char *to, const char *replyto, int ctrlfd) + const char *from, const char *to, const char *replyto, int listfd, int ctrlfd) { size_t len, i; int outfd; @@ -1626,10 +1626,10 @@ char *prepstdreply(text *txt, const char *listdir, free(str); } - tmp = substitute(from, listaddr, listdelim, listdir, txt); + tmp = substitute(from, listaddr, listdelim, listfd, ctrlfd, txt); headers[0] = concatstr(2, "From: ", tmp); free(tmp); - tmp = substitute(to, listaddr, listdelim, listdir, txt); + tmp = substitute(to, listaddr, listdelim, listfd, ctrlfd, txt); headers[1] = concatstr(2, "To: ", tmp); free(tmp); headers[2] = genmsgid(listfqdn); @@ -1642,14 +1642,14 @@ char *prepstdreply(text *txt, const char *listdir, headers[7] = xstrdup("Content-Transfer-Encoding: 8bit"); if(replyto) { - tmp = substitute(replyto, listaddr, listdelim, listdir, txt); + tmp = substitute(replyto, listaddr, listdelim, listfd, ctrlfd, txt); headers[8] = concatstr(2, "Reply-To: ", tmp); free(tmp); } for(;;) { line = get_processed_text_line(txt, 1, listaddr, listdelim, - listdir, ctrlfd); + listdir, listfd, ctrlfd); if (!line) { log_error(LOG_ARGS, "No body in listtext"); break; @@ -1736,7 +1736,7 @@ char *prepstdreply(text *txt, const char *listdir, if (line == NULL) { line = get_processed_text_line(txt, 0, listaddr, listdelim, - listdir, ctrlfd); + listdir, listfd, ctrlfd); } while(line) { if(dprintf(outfd, "%s\n", line) < 0) { @@ -1748,7 +1748,7 @@ char *prepstdreply(text *txt, const char *listdir, } free(line); line = get_processed_text_line(txt, 0, listaddr, listdelim, - listdir, ctrlfd); + listdir, listfd, ctrlfd); } fsync(outfd); diff --git a/src/send_digest.c b/src/send_digest.c index a44a6030..b6ab8eb3 100644 --- a/src/send_digest.c +++ b/src/send_digest.c @@ -236,7 +236,7 @@ static void finish_thread_list(thread_list_state * s) int send_digest(const char *listdir, int firstindex, int lastindex, - int issue, const char *addr, const char *mlmmjsend, int ctrlfd) + int issue, const char *addr, const char *mlmmjsend, int listfd, int ctrlfd) { int i, fd, archivefd, hdrfd; size_t len; @@ -310,7 +310,8 @@ int send_digest(const char *listdir, int firstindex, int lastindex, register_formatted(txt, "digestthreads", rewind_thread_list, get_thread_list_line, tls); - line = get_processed_text_line(txt, 1, listaddr, listdelim, listdir, ctrlfd); + line = get_processed_text_line(txt, 1, listaddr, listdelim, listdir, + listfd, ctrlfd); if (line == NULL) { log_error(LOG_ARGS, "No content in digest listtext"); @@ -338,7 +339,7 @@ int send_digest(const char *listdir, int firstindex, int lastindex, /* Skip the empty line after the subject */ line = get_processed_text_line(txt, 1, listaddr, listdelim, - listdir, ctrlfd); + listdir, listfd, ctrlfd); if (line == NULL || *line != '\0') { log_error(LOG_ARGS, "Too many headers " "in digest listtext"); @@ -432,7 +433,7 @@ errdighdrs: for (;;) { line = get_processed_text_line(txt, 0, listaddr, listdelim, - listdir, ctrlfd); + listdir, listfd, ctrlfd); if (line == NULL) break; if(dprintf(fd, "%s\n", line) < 0) { free(line); diff --git a/src/send_list.c b/src/send_list.c index 8a40440a..7e5a2912 100644 --- a/src/send_list.c +++ b/src/send_list.c @@ -153,7 +153,7 @@ static void print_subs(int fd, subs_list_state *s) void send_list(const char *listdir, const char *emailaddr, - const char *mlmmjsend, int ctrlfd) + const char *mlmmjsend, int ctrlfd, int listfd) { text *txt; subs_list_state *normalsls, *digestsls, *nomailsls; @@ -190,7 +190,8 @@ void send_list(const char *listdir, const char *emailaddr, rewind_subs_list, get_sub, digestsls); register_formatted(txt, "nomailsubs", rewind_subs_list, get_sub, nomailsls); - queuefilename = prepstdreply(txt, listdir, "$listowner$", emailaddr, NULL, ctrlfd); + queuefilename = prepstdreply(txt, listdir, "$listowner$", emailaddr, + NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt);