char *substitute(const char *line, struct mlmmj_list *list, text *txt);
-text *open_text_file(const char *listdir, const char *filename);
-text *open_text(const char *listdir, const char *purpose, const char *action,
+text *open_text_file(struct mlmmj_list *list, const char *filename);
+text *open_text(struct mlmmj_list *list, const char *purpose, const char *action,
const char *reason, const char *type, const char *compat);
void register_unformatted(text *txt, const char *token, const char *subst);
void register_originalmail(text *txt, const char *mailname);
errno = 0;
log_error(LOG_ARGS, "A subscribe-digest request was"
" denied");
- txt = open_text(list->dir, "deny", "sub", "disabled",
+ txt = open_text(list, "deny", "sub", "disabled",
"digest", "sub-deny-digest");
MY_ASSERT(txt);
register_unformatted(txt, "subaddr",
errno = 0;
log_error(LOG_ARGS, "A subscribe-nomail request was"
" denied");
- txt = open_text(list->dir, "deny", "sub", "disabled",
+ txt = open_text(list, "deny", "sub", "disabled",
"nomail", "sub-deny-nomail");
MY_ASSERT(txt);
register_unformatted(txt, "subaddr",
errno = 0;
log_error(LOG_ARGS, "A subscribe-both request was"
" denied");
- txt = open_text(list->dir, "deny", "sub", "disabled",
+ txt = open_text(list, "deny", "sub", "disabled",
"both", "sub-deny-digest");
MY_ASSERT(txt);
register_unformatted(txt, "subaddr",
}
log_oper(list->dir, OPLOGFNAME, "%s requested help",
fromemails->emaillist[0]);
- txt = open_text(list->dir, "help", NULL, NULL, NULL, "listhelp");
+ txt = open_text(list, "help", NULL, NULL, NULL, "listhelp");
MY_ASSERT(txt);
queuefilename = prepstdreply(txt, list,
"$listowner$", fromemails->emaillist[0], NULL);
}
log_oper(list->dir, OPLOGFNAME, "%s requested faq",
fromemails->emaillist[0]);
- txt = open_text(list->dir, "faq", NULL, NULL, NULL, "listfaq");
+ txt = open_text(list, "faq", NULL, NULL, NULL, "listfaq");
MY_ASSERT(txt);
queuefilename = prepstdreply(txt, list,
"$listowner$", fromemails->emaillist[0], NULL);
}
*a = '@';
- txt = open_text(list->dir, "probe", NULL, NULL, NULL, "bounce-probe");
+ txt = open_text(list, "probe", NULL, NULL, NULL, "bounce-probe");
MY_ASSERT(txt);
register_unformatted(txt, "bouncenumbers", "%bouncenumbers%"); /* DEPRECATED */
fls = init_truncated_file_lines(addr, 0, ':');
from = concatstr(4, list->name, list->delim, "owner@", list->fqdn);
to = concatstr(3, list->name, "-moderators@", list->fqdn); /* FIXME JFA: Should this be converted? Why, why not? */
- txt = open_text(list->dir, "moderate", "post",
+ txt = open_text(list, "moderate", "post",
modreason_strs[modreason], NULL, "moderation");
MY_ASSERT(txt);
register_unformatted(txt, "subject", subject);
/* send mail to poster that the list is moderated */
- txt = open_text(list->dir, "wait", "post",
+ txt = open_text(list, "wait", "post",
modreason_strs[modreason], NULL, "moderation-poster");
MY_ASSERT(txt);
register_unformatted(txt, "subject", subject);
text *txt;
fromaddr = concatstr(4, list->name, list->delim, "bounces-help@", list->fqdn);
- txt = open_text(list->dir, "deny", "post", cause, NULL, subcause);
+ txt = open_text(list, "deny", "post", cause, NULL, subcause);
MY_ASSERT(txt);
register_unformatted(txt, "subject", subject);
register_unformatted(txt, "posteraddr", posteraddr);
mls = init_memory_lines(moderators);
myfree(moderators);
- txt = open_text(list->dir,
+ txt = open_text(list,
"gatekeep", "sub",
subreason_strs[reasonsub], subtype_strs[typesub],
"submod-moderator");
myasprintf(&from, "%s%sbounces-help@%s", list->name, list->delim,
list->fqdn);
- txt = open_text(list->dir,
+ txt = open_text(list,
"wait", "sub",
subreason_strs[reasonsub], subtype_strs[typesub],
"submod-requester");
break;
}
- txt = open_text(list->dir, "finish", "sub",
+ txt = open_text(list, "finish", "sub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
break;
}
- txt = open_text(list->dir, "notify", "sub",
+ txt = open_text(list, "notify", "sub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
myfree(randomstr);
myfree(tmpstr);
- txt = open_text(list->dir, "confirm", "sub",
+ txt = open_text(list, "confirm", "sub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
myasprintf(&fromaddr, "%s%sbounces-help@%s", list->name, list->delim,
list->fqdn);
- txt = open_text(list->dir,
+ txt = open_text(list,
"deny", "sub", "subbed", subtype_strs[typesub],
"sub-subscribed");
MY_ASSERT(txt);
break;
}
- txt = open_text(list->dir, "finish", "unsub",
+ txt = open_text(list, "finish", "unsub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
break;
}
- txt = open_text(list->dir, "notify", "unsub",
+ txt = open_text(list, "notify", "unsub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
myfree(randomstr);
myfree(tmpstr);
- txt = open_text(list->dir, "confirm", "unsub",
+ txt = open_text(list, "confirm", "unsub",
subreason_strs[reasonsub], subtype_strs[typesub],
listtext);
myfree(listtext);
myasprintf(&fromaddr, "%s%sbounes-help@%s", list->name, list->delim, list->fqdn);
- txt = open_text(list->dir,
+ txt = open_text(list,
"deny", "unsub", "unsubbed", subtype_strs[typesub],
"unsub-notsubscribed");
MY_ASSERT(txt);
}
-text *open_text_file(const char *listdir, const char *filename)
+text *open_text_file(struct mlmmj_list *list, const char *filename)
{
char *tmp;
text *txt;
txt->cond = NULL;
txt->skip = NULL;
- tmp = concatstr(3, listdir, "/text/", filename);
- txt->src->fd = open(tmp, O_RDONLY);
+ myasprintf(&tmp, "text/%s", filename);
+ txt->src->fd = openat(list->fd, tmp, O_RDONLY);
myfree(tmp);
if (txt->src->fd >= 0) return txt;
}
-text *open_text(const char *listdir, const char *purpose, const char *action,
+text *open_text(struct mlmmj_list *list, const char *purpose, const char *action,
const char *reason, const char *type, const char *compat)
{
size_t filenamelen, len;
filename = concatstr(7,purpose,"-",action,"-",reason,"-",type);
filenamelen = strlen(filename);
do {
- if ((txt = open_text_file(listdir, filename)) != NULL) break;
+ if ((txt = open_text_file(list, filename)) != NULL) break;
len = type ? strlen(type) : 0;
filename[filenamelen-len-1] = '\0';
- if ((txt = open_text_file(listdir, filename)) != NULL) break;
+ if ((txt = open_text_file(list, filename)) != NULL) break;
filename[filenamelen-len-1] = '-';
filenamelen -= len + 1;
len = reason ? strlen(reason) : 0;
filename[filenamelen-len-1] = '\0';
- if ((txt = open_text_file(listdir, filename)) != NULL) break;
+ if ((txt = open_text_file(list, filename)) != NULL) break;
filename[filenamelen-len-1] = '-';
filenamelen -= len + 1;
len = action ? strlen(action) : 0;
filename[filenamelen-len-1] = '\0';
- if ((txt = open_text_file(listdir, filename)) != NULL) break;
+ if ((txt = open_text_file(list, filename)) != NULL) break;
filename[filenamelen-len-1] = '-';
filenamelen -= len + 1;
- if ((txt = open_text_file(listdir, compat)) != NULL) {
+ if ((txt = open_text_file(list, compat)) != NULL) {
myfree(filename);
filename = mystrdup(compat);
break;
boundary = random_str();
- txt = open_text_file(list->dir, "digest");
+ txt = open_text_file(list, "digest");
if (txt == NULL) {
log_error(LOG_ARGS, "Could not open listtext 'digest'");
goto fallback_subject;
myfree(digestdir);
myfree(nomaildir);
- txt = open_text(list->dir, "list", NULL, NULL, subtype_strs[SUB_ALL],
+ txt = open_text(list, "list", NULL, NULL, subtype_strs[SUB_ALL],
"listsubs");
MY_ASSERT(txt);
register_formatted(txt, "listsubs",