Mercurial > hg > mlmmj
annotate src/mlmmj-process.c @ 744:926f184eec44
Add a $subject$ substitution for list texts
author | Ben Schmidt |
---|---|
date | Mon, 20 Sep 2010 02:25:54 +1000 |
parents | b72bcb7e08a2 |
children | dfc9ab125fd4 |
rev | line source |
---|---|
484 | 1 /* Copyright (C) 2003, 2003, 2004 Mads Martin Joergensen <mmj at mmj.dk> |
0 | 2 * |
3 * $Id$ | |
4 * | |
225 | 5 * Permission is hereby granted, free of charge, to any person obtaining a copy |
6 * of this software and associated documentation files (the "Software"), to | |
7 * deal in the Software without restriction, including without limitation the | |
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
9 * sell copies of the Software, and to permit persons to whom the Software is | |
10 * furnished to do so, subject to the following conditions: | |
11 * | |
12 * The above copyright notice and this permission notice shall be included in | |
13 * all copies or substantial portions of the Software. | |
14 * | |
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
21 * IN THE SOFTWARE. | |
0 | 22 */ |
23 | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <unistd.h> | |
27 #include <errno.h> | |
28 #include <string.h> | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 #include <fcntl.h> | |
37 | 32 #include <libgen.h> |
254 | 33 #include <regex.h> |
0 | 34 |
35 #include "mlmmj.h" | |
36 #include "wrappers.h" | |
37 #include "find_email_adr.h" | |
38 #include "incindexfile.h" | |
39 #include "getlistaddr.h" | |
520 | 40 #include "getlistdelim.h" |
0 | 41 #include "listcontrol.h" |
42 #include "strgen.h" | |
11 | 43 #include "do_all_the_voodo_here.h" |
25 | 44 #include "log_error.h" |
69 | 45 #include "mygetline.h" |
46 #include "statctrl.h" | |
89 | 47 #include "ctrlvalue.h" |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
48 #include "ctrlvalues.h" |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
49 #include "getlistaddr.h" |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
50 #include "prepstdreply.h" |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
51 #include "subscriberfuncs.h" |
245 | 52 #include "memory.h" |
430 | 53 #include "log_oper.h" |
459 | 54 #include "chomp.h" |
744 | 55 #include "unistr.h" |
254 | 56 |
57 enum action { | |
58 ALLOW, | |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
59 SEND, |
386 | 60 DENY, |
640
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
61 MODERATE, |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
62 DISCARD |
254 | 63 }; |
64 | |
65 | |
626 | 66 static char *action_strs[] = { |
67 "allowed", | |
68 "denied", | |
640
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
69 "moderated", |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
70 "discarded" |
254 | 71 }; |
72 | |
73 | |
69 | 74 void newmoderated(const char *listdir, const char *mailfilename, |
744 | 75 const char *mlmmjsend, const char *efromsender, |
76 size_t tokencount, char **data) | |
69 | 77 { |
744 | 78 size_t i; |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
79 char *from, *listfqdn, *listname, *moderators = NULL; |
520 | 80 char *buf, *replyto, *listaddr = getlistaddr(listdir), *listdelim; |
705 | 81 char *queuefilename = NULL, *moderatorsfilename, *efromismod = NULL; |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
82 char *mailbasename = mybasename(mailfilename), *tmp, *to; |
729
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
83 int moderatorsfd, foundaddr = 0, notifymod = 0, status; |
744 | 84 char *maildata[10] = { "moderateaddr", NULL, "moderators", NULL }; |
729
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
85 pid_t childpid, pid; |
181 | 86 #if 0 |
69 | 87 printf("mailfilename = [%s], mailbasename = [%s]\n", mailfilename, |
88 mailbasename); | |
181 | 89 #endif |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
90 listfqdn = genlistfqdn(listaddr); |
69 | 91 listname = genlistname(listaddr); |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
92 |
744 | 93 MY_ASSERT(tokencount<=3) |
94 for (i=0; i<tokencount; i++) { | |
95 maildata[4+2*i] = data[2*i]; | |
96 maildata[5+2*i] = data[1+2*i]; | |
97 } | |
98 tokencount += 2; | |
99 | |
184 | 100 moderatorsfilename = concatstr(2, listdir, "/control/moderators"); |
163 | 101 if((moderatorsfd = open(moderatorsfilename, O_RDONLY)) < 0) { |
69 | 102 log_error(LOG_ARGS, "Could not open '%s'", moderatorsfilename); |
245 | 103 myfree(moderatorsfilename); |
69 | 104 exit(EXIT_FAILURE); |
105 } | |
245 | 106 myfree(moderatorsfilename); |
69 | 107 |
705 | 108 if(statctrl(listdir, "ifmodsendonlymodmoderate")) |
109 efromismod = concatstr(2, efromsender, "\n"); | |
110 | |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
111 while((buf = mygetline(moderatorsfd))) { |
705 | 112 if(efromismod && strcmp(buf, efromismod) == 0) |
113 foundaddr = 1; | |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
114 tmp = moderators; |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
115 moderators = concatstr(2, moderators, buf); |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
116 myfree(buf); |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
117 myfree(tmp); |
69 | 118 } |
119 | |
705 | 120 if(!foundaddr) { |
121 myfree(efromismod); | |
122 efromismod = NULL; | |
123 } | |
124 | |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
125 close(moderatorsfd); |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
126 |
520 | 127 listdelim = getlistdelim(listdir); |
128 replyto = concatstr(6, listname, listdelim, "moderate-", mailbasename, | |
129 "@", listfqdn); | |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
130 |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
131 maildata[1] = replyto; |
705 | 132 if(efromismod) { |
133 myfree(moderators); | |
134 maildata[3] = efromismod; | |
135 } else | |
136 maildata[3] = moderators; | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
137 |
520 | 138 from = concatstr(4, listname, listdelim, "owner@", listfqdn); |
139 to = concatstr(3, listname, "-moderators@", listfqdn); /* FIXME JFA: Should this be converted? Why, why not? */ | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
140 |
520 | 141 myfree(listdelim); |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
142 myfree(listname); |
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
143 myfree(listfqdn); |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
144 |
365
24a86824b6b8
Substitute all of them and convert moderation to prepstdreply
mmj
parents:
363
diff
changeset
|
145 queuefilename = prepstdreply(listdir, "moderation", "$listowner$", |
744 | 146 to, replyto, tokencount, maildata, |
729
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
147 mailfilename); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
148 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
149 /* we might need to exec more than one mlmmj-send */ |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
150 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
151 notifymod = !efromismod && statctrl(listdir,"notifymod"); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
152 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
153 if (notifymod) { |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
154 childpid = fork(); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
155 if(childpid < 0) |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
156 log_error(LOG_ARGS, "Could not fork; poster not notified"); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
157 } else |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
158 childpid = -1; |
69 | 159 |
729
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
160 if(childpid != 0) { |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
161 if(childpid > 0) { |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
162 do /* Parent waits for the child */ |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
163 pid = waitpid(childpid, &status, 0); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
164 while(pid == -1 && errno == EINTR); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
165 } |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
166 if(efromismod) |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
167 execlp(mlmmjsend, mlmmjsend, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
168 "-l", "1", |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
169 "-L", listdir, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
170 "-F", from, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
171 "-m", queuefilename, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
172 "-T", efromsender, (char *)NULL); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
173 else |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
174 execlp(mlmmjsend, mlmmjsend, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
175 "-l", "2", |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
176 "-L", listdir, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
177 "-F", from, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
178 "-m", queuefilename, (char *)NULL); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
179 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
180 exit(EXIT_FAILURE); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
181 } |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
182 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
183 myfree(queuefilename); |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
184 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
185 /* send mail to poster that the list is moderated */ |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
186 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
187 queuefilename = prepstdreply(listdir, "moderation-poster", |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
188 "$listowner$", efromsender, |
744 | 189 NULL, tokencount-1, maildata+2, mailfilename); |
729
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
190 |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
191 execlp(mlmmjsend, mlmmjsend, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
192 "-l", "1", |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
193 "-L", listdir, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
194 "-F", from, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
195 "-m", queuefilename, |
d78eb18576b0
Added feature to notify users when their posts are moderated
Ben Schmidt
parents:
727
diff
changeset
|
196 "-T", efromsender, (char *)NULL); |
69 | 197 |
198 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); | |
199 exit(EXIT_FAILURE); | |
200 } | |
18 | 201 |
254 | 202 |
626 | 203 static enum action do_access(struct strlist *rule_strs, struct strlist *hdrs, |
204 const char *from, const char *listdir) | |
254 | 205 { |
626 | 206 int i, j; |
254 | 207 unsigned int match; |
208 char *rule_ptr; | |
209 char errbuf[128]; | |
210 int err; | |
626 | 211 enum action act; |
212 unsigned int not; | |
213 regex_t regexp; | |
214 char *hdr; | |
254 | 215 |
626 | 216 for (i=0; i<rule_strs->count; i++) { |
254 | 217 |
218 rule_ptr = rule_strs->strs[i]; | |
626 | 219 |
254 | 220 if (strncmp(rule_ptr, "allow", 5) == 0) { |
221 rule_ptr += 5; | |
626 | 222 act = ALLOW; |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
223 } else if (strncmp(rule_ptr, "send", 4) == 0) { |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
224 rule_ptr += 4; |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
225 act = SEND; |
254 | 226 } else if (strncmp(rule_ptr, "deny", 4) == 0) { |
227 rule_ptr += 4; | |
626 | 228 act = DENY; |
386 | 229 } else if (strncmp(rule_ptr, "moderate", 8) == 0) { |
230 rule_ptr += 8; | |
626 | 231 act = MODERATE; |
640
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
232 } else if (strncmp(rule_ptr, "discard", 7) == 0) { |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
233 rule_ptr += 7; |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
234 act = DISCARD; |
254 | 235 } else { |
236 errno = 0; | |
626 | 237 log_error(LOG_ARGS, "Unable to parse rule #%d \"%s\":" |
238 " Missing action keyword. Denying post from \"%s\"", | |
239 i, rule_strs->strs[i], from); | |
240 log_oper(listdir, OPLOGFNAME, "Unable to parse rule #%d \"%s\":" | |
241 " Missing action keyword. Denying post from \"%s\"", | |
242 i, rule_strs->strs[i], from); | |
254 | 243 return DENY; |
244 } | |
245 | |
246 if (*rule_ptr == ' ') { | |
257 | 247 rule_ptr++; |
248 } else if (*rule_ptr == '\0') { | |
626 | 249 /* the rule is a keyword and no regexp */ |
250 log_oper(listdir, OPLOGFNAME, "mlmmj-process: access -" | |
251 " A mail from \"%s\" was %s by rule #%d \"%s\"", | |
252 from, action_strs[act], i, rule_strs->strs[i]); | |
253 return act; | |
257 | 254 } else { |
254 | 255 /* we must have space or end of string */ |
256 errno = 0; | |
626 | 257 log_error(LOG_ARGS, "Unable to parse rule #%d \"%s\":" |
258 " Invalid character after action keyword." | |
259 " Denying post from \"%s\"", i, rule_strs->strs[i], from); | |
260 log_oper(listdir, OPLOGFNAME, "Unable to parse rule #%d \"%s\":" | |
261 " Invalid character after action keyword." | |
262 " Denying post from \"%s\"", i, rule_strs->strs[i], from); | |
254 | 263 return DENY; |
264 } | |
265 | |
266 if (*rule_ptr == '!') { | |
267 rule_ptr++; | |
626 | 268 not = 1; |
254 | 269 } else { |
626 | 270 not = 0; |
254 | 271 } |
272 | |
292 | 273 /* remove unanchored ".*" from beginning of regexp to stop the |
274 * regexp matching to loop so long time it seems like it's | |
275 * hanging */ | |
626 | 276 if (strncmp(rule_ptr, "^.*", 3) == 0) { |
277 rule_ptr += 3; | |
278 } | |
279 while (strncmp(rule_ptr, ".*", 2) == 0) { | |
280 rule_ptr += 2; | |
281 } | |
292 | 282 |
626 | 283 if ((err = regcomp(®exp, rule_ptr, |
254 | 284 REG_EXTENDED | REG_NOSUB | REG_ICASE))) { |
626 | 285 regerror(err, ®exp, errbuf, sizeof(errbuf)); |
286 regfree(®exp); | |
254 | 287 errno = 0; |
626 | 288 log_error(LOG_ARGS, "regcomp() failed for rule #%d \"%s\"" |
254 | 289 " (message: '%s') (expression: '%s')" |
626 | 290 " Denying post from \"%s\"", |
291 i, rule_strs->strs[i], errbuf, rule_ptr, from); | |
292 log_oper(listdir, OPLOGFNAME, "regcomp() failed for rule" | |
293 " #%d \"%s\" (message: '%s') (expression: '%s')" | |
294 " Denying post from \"%s\"", | |
295 i, rule_strs->strs[i], errbuf, rule_ptr, from); | |
254 | 296 return DENY; |
297 } | |
298 | |
299 match = 0; | |
626 | 300 for (j=0; j<hdrs->count; j++) { |
301 if (regexec(®exp, hdrs->strs[j], 0, NULL, 0) | |
254 | 302 == 0) { |
303 match = 1; | |
304 break; | |
305 } | |
306 } | |
386 | 307 |
626 | 308 regfree(®exp); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
309 |
626 | 310 if (match != not) { |
311 if (match) { | |
312 hdr = mystrdup(hdrs->strs[j]); | |
313 chomp(hdr); | |
314 log_oper(listdir, OPLOGFNAME, "mlmmj-process: access -" | |
315 " A mail from \"%s\" with header \"%s\" was %s by" | |
316 " rule #%d \"%s\"", from, hdr, action_strs[act], | |
317 i, rule_strs->strs[i]); | |
318 myfree(hdr); | |
319 } else { | |
320 log_oper(listdir, OPLOGFNAME, "mlmmj-process: access -" | |
321 " A mail from \"%s\" was %s by rule #%d \"%s\"" | |
322 " because no header matched.", from, | |
323 action_strs[act], i, rule_strs->strs[i]); | |
386 | 324 } |
626 | 325 return act; |
254 | 326 } |
327 | |
328 } | |
329 | |
626 | 330 log_oper(listdir, OPLOGFNAME, "mlmmj-process: access -" |
331 " A mail from \"%s\" didn't match any rules, and" | |
332 " was denied by default.", from); | |
254 | 333 return DENY; |
334 } | |
335 | |
336 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
337 static char *recipient_extra(const char *listdir, const char *addr) |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
338 { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
339 char *listdelim; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
340 char *delim, *atsign, *ret; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
341 size_t len; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
342 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
343 if (!addr) |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
344 return NULL; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
345 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
346 listdelim = getlistdelim(listdir); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
347 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
348 delim = strstr(addr, listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
349 if (!delim) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
350 myfree(listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
351 return NULL; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
352 } |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
353 delim += strlen(listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
354 myfree(listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
355 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
356 atsign = strrchr(delim, '@'); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
357 if (!atsign) |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
358 return NULL; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
359 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
360 len = atsign - delim; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
361 ret = (char *)mymalloc(len + 1); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
362 strncpy(ret, delim, len); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
363 ret[len] = '\0'; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
364 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
365 return ret; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
366 } |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
367 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
368 |
0 | 369 static void print_help(const char *prg) |
370 { | |
102 | 371 printf("Usage: %s -L /path/to/list -m /path/to/mail [-h] [-P] [-V]\n" |
372 " -h: This help\n" | |
373 " -L: Full path to list directory\n" | |
374 " -m: Full path to mail file\n" | |
375 " -P: Don't execute mlmmj-send\n" | |
376 " -V: Print version\n", prg); | |
377 | |
378 exit(EXIT_SUCCESS); | |
0 | 379 } |
380 | |
381 int main(int argc, char **argv) | |
382 { | |
459 | 383 int i, j, opt, noprocess = 0, moderated = 0; |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
384 int hdrfd, footfd, rawmailfd, donemailfd, omitfd; |
602 | 385 int subonlypost = 0, addrtocc = 1, intocc = 0, modnonsubposts = 0; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
386 int maxmailsize = 0; |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
387 int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
388 int nomaxmailsizedenymails = 0; |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
389 int notmetoo = 0; |
11 | 390 char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL; |
391 char *footerfilename = NULL, *donemailname = NULL; | |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
392 char *randomstr = NULL, *mqueuename, *omitfilename; |
47 | 393 char *mlmmjsend, *mlmmjsub, *mlmmjunsub, *mlmmjbounce; |
520 | 394 char *bindir, *subjectprefix, *discardname, *listaddr, *listdelim; |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
395 char *listfqdn, *listname, *fromaddr; |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
396 char *queuefilename, *recipextra = NULL, *owner = NULL; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
397 char *maxmailsizestr; |
744 | 398 char *maildata[6] = { "subject", NULL, |
399 "posteraddr", NULL, "maxmailsize", NULL }; | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
400 char *envstr, *efrom; |
295 | 401 struct stat st; |
402 uid_t uid; | |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
403 struct email_container fromemails = { 0, NULL }; |
11 | 404 struct email_container toemails = { 0, NULL }; |
135 | 405 struct email_container ccemails = { 0, NULL }; |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
406 struct email_container rpemails = { 0, NULL }; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
407 struct email_container dtemails = { 0, NULL }; |
259 | 408 struct strlist *access_rules = NULL; |
409 struct strlist *delheaders = NULL; | |
254 | 410 struct strlist allheaders; |
459 | 411 struct strlist *alternates = NULL; |
11 | 412 struct mailhdr readhdrs[] = { |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
413 { "From:", 0, NULL }, |
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
414 { "To:", 0, NULL }, |
135 | 415 { "Cc:", 0, NULL }, |
304 | 416 { "Return-Path:", 0, NULL }, |
417 { "Delivered-To:", 0, NULL }, | |
744 | 418 { "Subject:", 0, NULL }, |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
419 { NULL, 0, NULL } |
11 | 420 }; |
38 | 421 |
208
688011dbc4b7
Add a macro to make sure mlmmj binaries are invoked with full path
mmj
parents:
184
diff
changeset
|
422 CHECKFULLPATH(argv[0]); |
688011dbc4b7
Add a macro to make sure mlmmj binaries are invoked with full path
mmj
parents:
184
diff
changeset
|
423 |
47 | 424 log_set_name(argv[0]); |
425 | |
117
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
426 bindir = mydirname(argv[0]); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
427 mlmmjsend = concatstr(2, bindir, "/mlmmj-send"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
428 mlmmjsub = concatstr(2, bindir, "/mlmmj-sub"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
429 mlmmjunsub = concatstr(2, bindir, "/mlmmj-unsub"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
430 mlmmjbounce = concatstr(2, bindir, "/mlmmj-bounce"); |
245 | 431 myfree(bindir); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
432 |
12 | 433 while ((opt = getopt(argc, argv, "hVPm:L:")) != -1) { |
0 | 434 switch(opt) { |
435 case 'L': | |
436 listdir = optarg; | |
437 break; | |
438 case 'm': | |
439 mailfile = optarg; | |
440 break; | |
441 case 'h': | |
442 print_help(argv[0]); | |
443 break; | |
11 | 444 case 'P': |
445 noprocess = 1; | |
446 break; | |
0 | 447 case 'V': |
448 print_version(argv[0]); | |
69 | 449 exit(EXIT_SUCCESS); |
0 | 450 } |
451 } | |
295 | 452 |
11 | 453 if(listdir == NULL || mailfile == NULL) { |
0 | 454 fprintf(stderr, "You have to specify -L and -m\n"); |
455 fprintf(stderr, "%s -h for help\n", argv[0]); | |
456 exit(EXIT_FAILURE); | |
457 } | |
458 | |
295 | 459 /* Lets make sure no random user tries to send mail to the list */ |
460 if(listdir) { | |
461 if(stat(listdir, &st) == 0) { | |
462 uid = getuid(); | |
463 if(uid && uid != st.st_uid) { | |
464 log_error(LOG_ARGS, | |
465 "Have to invoke either as root " | |
466 "or as the user owning listdir"); | |
467 writen(STDERR_FILENO, | |
468 "Have to invoke either as root " | |
469 "or as the user owning listdir\n", 60); | |
470 exit(EXIT_FAILURE); | |
471 } | |
472 } else { | |
473 log_error(LOG_ARGS, "Could not stat %s", listdir); | |
474 exit(EXIT_FAILURE); | |
475 } | |
476 } | |
477 | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
478 do { |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
479 myfree(donemailname); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
480 myfree(randomstr); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
481 randomstr = random_str(); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
482 donemailname = concatstr(3, listdir, "/queue/", randomstr); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
483 |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
484 donemailfd = open(donemailname, O_RDWR|O_CREAT|O_EXCL, |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
485 S_IRUSR|S_IWUSR); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
486 |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
487 } while ((donemailfd < 0) && (errno == EEXIST)); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
488 |
163 | 489 if(donemailfd < 0) { |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
490 log_error(LOG_ARGS, "could not create %s", donemailname); |
245 | 491 myfree(donemailname); |
0 | 492 exit(EXIT_FAILURE); |
493 } | |
163 | 494 #if 0 |
495 log_error(LOG_ARGS, "donemailname = [%s]\n", donemailname); | |
496 #endif | |
497 if((rawmailfd = open(mailfile, O_RDONLY)) < 0) { | |
487 | 498 unlink(donemailname); |
245 | 499 myfree(donemailname); |
163 | 500 log_error(LOG_ARGS, "could not open() input mail file"); |
0 | 501 exit(EXIT_FAILURE); |
502 } | |
503 | |
308
5582a75b0a2a
added comments about - seemingly - unchecked open() calls
mortenp
parents:
305
diff
changeset
|
504 /* hdrfd is checked in do_all_the_voodo_here(), because the |
5582a75b0a2a
added comments about - seemingly - unchecked open() calls
mortenp
parents:
305
diff
changeset
|
505 * customheaders file might not exist */ |
132
24134b985e79
Move footer and customheader to control/. I've been meaning to do this
mmj
parents:
127
diff
changeset
|
506 headerfilename = concatstr(2, listdir, "/control/customheaders"); |
163 | 507 hdrfd = open(headerfilename, O_RDONLY); |
245 | 508 myfree(headerfilename); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
509 |
308
5582a75b0a2a
added comments about - seemingly - unchecked open() calls
mortenp
parents:
305
diff
changeset
|
510 /* footfd is checked in do_all_the_voodo_here(), see above */ |
132
24134b985e79
Move footer and customheader to control/. I've been meaning to do this
mmj
parents:
127
diff
changeset
|
511 footerfilename = concatstr(2, listdir, "/control/footer"); |
163 | 512 footfd = open(footerfilename, O_RDONLY); |
245 | 513 myfree(footerfilename); |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
514 |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
515 delheaders = ctrlvalues(listdir, "delheaders"); |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
516 if(delheaders == NULL) { |
245 | 517 delheaders = mymalloc(sizeof(struct strlist)); |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
518 delheaders->count = 0; |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
519 delheaders->strs = NULL; |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
520 } |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
521 |
245 | 522 delheaders->strs = myrealloc(delheaders->strs, |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
523 (delheaders->count+3) * sizeof(char *)); |
245 | 524 delheaders->strs[delheaders->count++] = mystrdup("From "); |
525 delheaders->strs[delheaders->count++] = mystrdup("Return-Path:"); | |
381 | 526 delheaders->strs[delheaders->count] = NULL; |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
527 |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
528 subjectprefix = ctrlvalue(listdir, "prefix"); |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
529 |
163 | 530 if(do_all_the_voodo_here(rawmailfd, donemailfd, hdrfd, footfd, |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
531 (const char**)delheaders->strs, readhdrs, |
254 | 532 &allheaders, subjectprefix) < 0) { |
183
2ec251b9a2f8
getlistaddr was tought that listaddress moved to control/listaddress
mmj
parents:
181
diff
changeset
|
533 log_error(LOG_ARGS, "Error in do_all_the_voodo_here"); |
163 | 534 exit(EXIT_FAILURE); |
535 } | |
0 | 536 |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
537 for(i = 0; i < delheaders->count; i++) |
245 | 538 myfree(delheaders->strs[i]); |
539 myfree(delheaders->strs); | |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
540 |
163 | 541 close(rawmailfd); |
542 close(donemailfd); | |
0 | 543 |
350 | 544 if(hdrfd >= 0) |
163 | 545 close(hdrfd); |
350 | 546 if(footfd >= 0) |
163 | 547 close(footfd); |
11 | 548 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
549 /* From: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
550 for(i = 0; i < readhdrs[0].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
551 find_email_adr(readhdrs[0].values[i], &fromemails); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
552 } |
744 | 553 if (fromemails.emailcount) |
554 maildata[3] = fromemails.emaillist[0]; | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
555 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
556 /* To: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
557 for(i = 0; i < readhdrs[1].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
558 find_email_adr(readhdrs[1].values[i], &toemails); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
559 } |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
560 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
561 /* Cc: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
562 for(i = 0; i < readhdrs[2].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
563 find_email_adr(readhdrs[2].values[i], &ccemails); |
11 | 564 } |
565 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
566 /* Return-Path: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
567 for(i = 0; i < readhdrs[3].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
568 find_email_adr(readhdrs[3].values[i], &rpemails); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
569 } |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
570 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
571 /* Delivered-To: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
572 for(i = 0; i < readhdrs[4].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
573 find_email_adr(readhdrs[4].values[i], &dtemails); |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
574 } |
135 | 575 |
744 | 576 /* Subject: */ |
577 if (readhdrs[5].valuecount) | |
578 maildata[1] = unistr_header_to_utf8(readhdrs[5].values[0]); | |
579 if (!maildata[1]) | |
580 maildata[1] = mystrdup(""); | |
581 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
582 /* envelope from */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
583 if((envstr = getenv("SENDER")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
584 /* qmail, postfix, exim */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
585 efrom = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
586 } else if(rpemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
587 /* the (first) Return-Path: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
588 efrom = mystrdup(rpemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
589 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
590 efrom = mystrdup(""); |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
591 } |
227 | 592 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
593 /* address extension (the "foo" part of "user+foo@domain.tld") */ |
594
9d4d9beb8642
Changed mlmmj-process to look at environment variable DEFAULT instead of EXT for qmail
mortenp
parents:
568
diff
changeset
|
594 if((envstr = getenv("DEFAULT")) != NULL) { |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
595 /* qmail */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
596 recipextra = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
597 } else if((envstr = getenv("EXTENSION")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
598 /* postfix */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
599 recipextra = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
600 } else if((envstr = getenv("LOCAL_PART_SUFFIX")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
601 /* exim */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
602 listdelim = getlistdelim(listdir); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
603 if (strncmp(envstr, listdelim, strlen(listdelim)) == 0) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
604 recipextra = mystrdup(envstr + strlen(listdelim)); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
605 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
606 recipextra = mystrdup(envstr); |
227 | 607 } |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
608 myfree(listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
609 } else if(dtemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
610 /* parse the (first) Delivered-To: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
611 recipextra = recipient_extra(listdir, dtemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
612 } else if(toemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
613 /* parse the (first) To: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
614 recipextra = recipient_extra(listdir, toemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
615 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
616 recipextra = NULL; |
304 | 617 } |
618 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
619 if(recipextra && (strlen(recipextra) == 0)) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
620 myfree(recipextra); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
621 recipextra = NULL; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
622 } |
347
b15e8c2dc97f
When using Delivered-To: for spotting the recipient delimiter we
mmj
parents:
340
diff
changeset
|
623 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
624 /* Why is this here, and not in listcontrol() ? -- mortenp 20060409 */ |
520 | 625 if(recipextra) { |
291 | 626 owner = concatstr(2, listdir, "/control/owner"); |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
627 if(owner && strcmp(recipextra, "owner") == 0) { |
381 | 628 /* strip envelope from before resending */ |
382 | 629 delheaders->count = 0; |
630 delheaders->strs = NULL; | |
381 | 631 delheaders->strs = myrealloc(delheaders->strs, |
632 (delheaders->count+3) * sizeof(char *)); | |
633 delheaders->strs[delheaders->count++] = | |
634 mystrdup("From "); | |
635 delheaders->strs[delheaders->count++] = | |
636 mystrdup("Return-Path:"); | |
637 delheaders->strs[delheaders->count] = NULL; | |
638 if((rawmailfd = open(mailfile, O_RDONLY)) < 0) { | |
639 log_error(LOG_ARGS, "could not open() " | |
640 "input mail file"); | |
641 exit(EXIT_FAILURE); | |
642 } | |
643 if((donemailfd = open(donemailname, | |
644 O_WRONLY|O_TRUNC)) < 0) { | |
645 log_error(LOG_ARGS, "could not open() " | |
646 "output mail file"); | |
647 exit(EXIT_FAILURE); | |
648 } | |
649 if(do_all_the_voodo_here(rawmailfd, donemailfd, -1, | |
650 -1, (const char**)delheaders->strs, | |
651 NULL, &allheaders, NULL) < 0) { | |
652 log_error(LOG_ARGS, "do_all_the_voodo_here"); | |
653 exit(EXIT_FAILURE); | |
654 } | |
655 close(rawmailfd); | |
656 close(donemailfd); | |
657 unlink(mailfile); | |
744 | 658 log_oper(listdir, OPLOGFNAME, "mlmmj-process: sending" |
430 | 659 " mail from %s to owner", |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
660 efrom); |
227 | 661 execlp(mlmmjsend, mlmmjsend, |
228
fda21d560980
Make it possible to specify several owner emailaddresses, not just one
mmj
parents:
227
diff
changeset
|
662 "-l", "4", |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
663 "-L", listdir, |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
664 "-F", efrom, |
228
fda21d560980
Make it possible to specify several owner emailaddresses, not just one
mmj
parents:
227
diff
changeset
|
665 "-s", owner, |
227 | 666 "-a", |
435 | 667 "-m", donemailname, (char *)NULL); |
227 | 668 log_error(LOG_ARGS, "execlp() of '%s' failed", |
669 mlmmjsend); | |
670 exit(EXIT_FAILURE); | |
671 } | |
58 | 672 #if 0 |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
673 log_error(LOG_ARGS, "listcontrol(from, %s, %s, %s, %s, %s, %s)\n", listdir, toemails.emaillist[0], mlmmjsub, mlmmjunsub, mlmmjsend, mlmmjbounce); |
58 | 674 #endif |
227 | 675 unlink(mailfile); |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
676 listcontrol(&fromemails, listdir, recipextra, |
163 | 677 mlmmjsub, mlmmjunsub, mlmmjsend, mlmmjbounce, |
678 donemailname); | |
536
ccb245244750
added unlink()ing of listcontrol messages (was in listcontrol.c)
mortenp
parents:
534
diff
changeset
|
679 |
11 | 680 return EXIT_SUCCESS; |
681 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
682 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
683 listaddr = getlistaddr(listdir); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
684 alternates = ctrlvalues(listdir, "listaddress"); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
685 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
686 /* checking incoming mail's size */ |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
687 maxmailsizestr = ctrlvalue(listdir, "maxmailsize"); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
688 if(maxmailsizestr) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
689 maxmailsize = atol(maxmailsizestr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
690 if(stat(donemailname, &st) < 0) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
691 log_error(LOG_ARGS, "stat(%s,..) failed", donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
692 exit(EXIT_FAILURE); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
693 } |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
694 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
695 if(st.st_size > maxmailsize) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
696 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
697 nomaxmailsizedenymails = statctrl(listdir, "nomaxmailsizedenymails"); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
698 if (nomaxmailsizedenymails) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
699 errno = 0; |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
700 log_error(LOG_ARGS, "Discarding %s due to" |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
701 " size limit (%d bytes too big)", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
702 donemailname, (st.st_size - maxmailsize)); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
703 unlink(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
704 unlink(mailfile); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
705 myfree(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
706 myfree(maxmailsizestr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
707 exit(EXIT_SUCCESS); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
708 } |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
709 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
710 listdelim = getlistdelim(listdir); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
711 listname = genlistname(listaddr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
712 listfqdn = genlistfqdn(listaddr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
713 fromaddr = concatstr(4, listname, listdelim, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
714 "bounces-help@", listfqdn); |
744 | 715 maildata[5] = maxmailsizestr; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
716 queuefilename = prepstdreply(listdir, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
717 "maxmailsize", "$listowner$", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
718 fromemails.emaillist[0], |
744 | 719 NULL, 1, maildata+4, donemailname); |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
720 MY_ASSERT(queuefilename) |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
721 myfree(listdelim); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
722 myfree(listname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
723 myfree(listfqdn); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
724 unlink(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
725 unlink(mailfile); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
726 myfree(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
727 myfree(maxmailsizestr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
728 execlp(mlmmjsend, mlmmjsend, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
729 "-l", "1", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
730 "-L", listdir, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
731 "-T", fromemails.emaillist[0], |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
732 "-F", fromaddr, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
733 "-m", queuefilename, (char *)NULL); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
734 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
735 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
736 exit(EXIT_FAILURE); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
737 } |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
738 } |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
739 |
484 | 740 /* discard malformed mail with invalid From: */ |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
741 if(fromemails.emailcount != 1) { |
532 | 742 for(i = 0; i < fromemails.emailcount; i++) |
743 printf("fromemails.emaillist[%d] = %s\n", | |
744 i, fromemails.emaillist[i]); | |
484 | 745 discardname = concatstr(3, listdir, |
746 "/queue/discarded/", randomstr); | |
532 | 747 log_error(LOG_ARGS, "Discarding %s due to invalid From:", |
748 mailfile); | |
533 | 749 for(i = 0; i < fromemails.emailcount; i++) |
750 log_error(LOG_ARGS, "fromemails.emaillist[%d] = %s\n", | |
751 i, fromemails.emaillist[i]); | |
484 | 752 rename(mailfile, discardname); |
753 unlink(donemailname); | |
754 myfree(donemailname); | |
755 myfree(discardname); | |
756 myfree(randomstr); | |
757 /* TODO: free emailstructs */ | |
758 exit(EXIT_SUCCESS); | |
759 } | |
760 | |
381 | 761 myfree(delheaders); |
762 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
763 if(strcmp(efrom, "") == 0) { /* don't send mails with <> in From |
305 | 764 to the list */ |
765 discardname = concatstr(3, listdir, | |
766 "/queue/discarded/", | |
767 randomstr); | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
768 errno = 0; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
769 log_error(LOG_ARGS, "Discarding %s due to missing envelope" |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
770 " from address", mailfile); |
333
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
771 rename(mailfile, discardname); |
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
772 unlink(donemailname); |
305 | 773 myfree(donemailname); |
774 myfree(discardname); | |
775 myfree(randomstr); | |
776 /* TODO: free emailstructs */ | |
777 exit(EXIT_SUCCESS); | |
778 } | |
779 | |
333
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
780 unlink(mailfile); |
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
781 |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
782 addrtocc = !(statctrl(listdir, "tocc")); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
783 if(addrtocc) { |
459 | 784 for(i = 0; i < toemails.emailcount; i++) { |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
785 log_error(LOG_ARGS, "Found To: %s", |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
786 toemails.emaillist[i]); |
459 | 787 for(j = 0; j < alternates->count; j++) { |
788 chomp(alternates->strs[j]); | |
523 | 789 if(strcasecmp(alternates->strs[j], |
459 | 790 toemails.emaillist[i]) == 0) |
791 intocc = 1; | |
792 } | |
793 } | |
794 for(i = 0; i < ccemails.emailcount; i++) { | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
795 log_error(LOG_ARGS, "Found Cc: %s", |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
796 ccemails.emaillist[i]); |
459 | 797 for(j = 0; j < alternates->count; j++) { |
798 chomp(alternates->strs[j]); | |
523 | 799 if(strcasecmp(alternates->strs[j], |
459 | 800 ccemails.emaillist[i]) == 0) |
801 intocc = 1; | |
802 } | |
803 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
804 } |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
805 |
459 | 806 for(i = 0; i < alternates->count; i++) |
807 myfree(alternates->strs[i]); | |
808 | |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
809 notoccdenymails = statctrl(listdir, "notoccdenymails"); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
810 |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
811 if(addrtocc && !intocc) { |
339 | 812 /* Don't send a mail about denial to the list, but silently |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
813 * discard and exit. Also don't in case of it being turned off |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
814 */ |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
815 if ((strcasecmp(listaddr, fromemails.emaillist[0]) == 0) || |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
816 notoccdenymails) { |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
817 log_error(LOG_ARGS, "Discarding %s because list" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
818 " address was not in To: or Cc:," |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
819 " and From: was the list or" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
820 " notoccdenymails was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
821 mailfile); |
339 | 822 myfree(listaddr); |
823 unlink(donemailname); | |
824 myfree(donemailname); | |
825 exit(EXIT_SUCCESS); | |
826 } | |
520 | 827 listdelim = getlistdelim(listdir); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
828 listname = genlistname(listaddr); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
829 listfqdn = genlistfqdn(listaddr); |
520 | 830 fromaddr = concatstr(4, listname, listdelim, "bounces-help@", |
831 listfqdn); | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
832 queuefilename = prepstdreply(listdir, "notintocc", |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
833 "$listowner$", fromemails.emaillist[0], |
744 | 834 NULL, 2, maildata, donemailname); |
254 | 835 MY_ASSERT(queuefilename) |
520 | 836 myfree(listdelim); |
245 | 837 myfree(listname); |
838 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
839 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
840 myfree(donemailname); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
841 execlp(mlmmjsend, mlmmjsend, |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
842 "-l", "1", |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
843 "-L", listdir, |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
844 "-T", fromemails.emaillist[0], |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
845 "-F", fromaddr, |
435 | 846 "-m", queuefilename, (char *)NULL); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
847 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
848 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
849 exit(EXIT_FAILURE); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
850 } |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
851 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
852 subonlypost = statctrl(listdir, "subonlypost"); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
853 if(subonlypost) { |
339 | 854 /* Don't send a mail about denial to the list, but silently |
440 | 855 * discard and exit. */ |
856 if (strcasecmp(listaddr, fromemails.emaillist[0]) == 0) { | |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
857 log_error(LOG_ARGS, "Discarding %s because" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
858 " subonlypost was set and From: was" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
859 " the list address", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
860 mailfile); |
339 | 861 myfree(listaddr); |
862 unlink(donemailname); | |
863 myfree(donemailname); | |
864 exit(EXIT_SUCCESS); | |
865 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
866 if(is_subbed(listdir, fromemails.emaillist[0]) != 0) { |
602 | 867 modnonsubposts = statctrl(listdir, |
868 "modnonsubposts"); | |
869 if(modnonsubposts) { | |
870 moderated = 1; | |
871 goto startaccess; | |
872 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
873 |
602 | 874 nosubonlydenymails = statctrl(listdir, |
875 "nosubonlydenymails"); | |
876 | |
440 | 877 if(nosubonlydenymails) { |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
878 log_error(LOG_ARGS, "Discarding %s because" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
879 " subonlypost and" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
880 " nosubonlydenymails was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
881 mailfile); |
440 | 882 myfree(listaddr); |
883 unlink(donemailname); | |
884 myfree(donemailname); | |
885 exit(EXIT_SUCCESS); | |
886 } | |
520 | 887 listdelim = getlistdelim(listdir); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
888 listname = genlistname(listaddr); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
889 listfqdn = genlistfqdn(listaddr); |
520 | 890 fromaddr = concatstr(4, listname, listdelim, |
891 "bounces-help@", listfqdn); | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
892 queuefilename = prepstdreply(listdir, "subonlypost", |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
893 "$listowner$", fromemails.emaillist[0], |
744 | 894 NULL, 2, maildata, donemailname); |
254 | 895 MY_ASSERT(queuefilename) |
245 | 896 myfree(listaddr); |
520 | 897 myfree(listdelim); |
245 | 898 myfree(listname); |
899 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
900 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
901 myfree(donemailname); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
902 execlp(mlmmjsend, mlmmjsend, |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
903 "-l", "1", |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
904 "-T", fromemails.emaillist[0], |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
905 "-F", fromaddr, |
435 | 906 "-m", queuefilename, (char *)NULL); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
907 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
908 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
909 exit(EXIT_FAILURE); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
910 } |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
911 } |
11 | 912 |
602 | 913 startaccess: |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
914 |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
915 if(!moderated) |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
916 moderated = statctrl(listdir, "moderated"); |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
917 |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
918 noaccessdenymails = statctrl(listdir, "noaccessdenymails"); |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
919 |
254 | 920 access_rules = ctrlvalues(listdir, "access"); |
921 if (access_rules) { | |
386 | 922 enum action accret; |
339 | 923 /* Don't send a mail about denial to the list, but silently |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
924 * discard and exit. Also do this in case it's turned off */ |
626 | 925 accret = do_access(access_rules, &allheaders, |
705 | 926 fromemails.emaillist[0], listdir); |
386 | 927 if (accret == DENY) { |
445 | 928 if ((strcasecmp(listaddr, fromemails.emaillist[0]) == |
929 0) || noaccessdenymails) { | |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
930 log_error(LOG_ARGS, "Discarding %s because" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
931 " it was denied by an access" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
932 " rule, and From: was the list" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
933 " address or noaccessdenymails" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
934 " was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
935 mailfile); |
445 | 936 myfree(listaddr); |
937 unlink(donemailname); | |
938 myfree(donemailname); | |
939 exit(EXIT_SUCCESS); | |
940 } | |
520 | 941 listdelim = getlistdelim(listdir); |
254 | 942 listname = genlistname(listaddr); |
943 listfqdn = genlistfqdn(listaddr); | |
520 | 944 fromaddr = concatstr(4, listname, listdelim, |
945 "bounces-help@", listfqdn); | |
254 | 946 queuefilename = prepstdreply(listdir, "access", |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
947 "$listowner$", |
254 | 948 fromemails.emaillist[0], |
744 | 949 NULL, 2, maildata, donemailname); |
254 | 950 MY_ASSERT(queuefilename) |
951 myfree(listaddr); | |
520 | 952 myfree(listdelim); |
254 | 953 myfree(listname); |
954 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
955 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
956 myfree(donemailname); |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
957 myfree(randomstr); |
254 | 958 execlp(mlmmjsend, mlmmjsend, |
959 "-l", "1", | |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
960 "-L", listdir, |
254 | 961 "-T", fromemails.emaillist[0], |
962 "-F", fromaddr, | |
435 | 963 "-m", queuefilename, (char *)NULL); |
254 | 964 |
965 log_error(LOG_ARGS, "execlp() of '%s' failed", | |
966 mlmmjsend); | |
967 exit(EXIT_FAILURE); | |
386 | 968 } else if (accret == MODERATE) { |
969 moderated = 1; | |
640
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
970 } else if (accret == DISCARD) { |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
971 discardname = concatstr(3, listdir, |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
972 "/queue/discarded/", randomstr); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
973 myfree(randomstr); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
974 if(rename(donemailname, discardname) < 0) { |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
975 log_error(LOG_ARGS, "could not rename(%s,%s)", |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
976 donemailname, discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
977 myfree(donemailname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
978 myfree(discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
979 exit(EXIT_FAILURE); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
980 } |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
981 myfree(donemailname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
982 myfree(discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
983 exit(EXIT_SUCCESS); |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
984 } else if (accret == SEND) { |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
985 moderated = 0; |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
986 } else if (accret == ALLOW) { |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
987 /* continue processing as normal */ |
254 | 988 } |
989 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
990 |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
991 notmetoo = statctrl(listdir, "notmetoo"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
992 |
69 | 993 if(moderated) { |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
994 mqueuename = concatstr(3, listdir, "/moderation/", |
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
995 randomstr); |
245 | 996 myfree(randomstr); |
69 | 997 if(rename(donemailname, mqueuename) < 0) { |
163 | 998 log_error(LOG_ARGS, "could not rename(%s,%s)", |
69 | 999 donemailname, mqueuename); |
245 | 1000 myfree(donemailname); |
1001 myfree(mqueuename); | |
69 | 1002 exit(EXIT_FAILURE); |
1003 } | |
245 | 1004 myfree(donemailname); |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1005 if (notmetoo) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1006 omitfilename = concatstr(2, mqueuename, ".omit"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1007 omitfd = open(omitfilename, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1008 if (omitfd < 0) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1009 log_error(LOG_ARGS, "could not open %s", |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1010 omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1011 myfree(mqueuename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1012 myfree(omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1013 exit(EXIT_FAILURE); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1014 } |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1015 myfree(omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1016 if(writen(omitfd, fromemails.emaillist[0], |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1017 strlen(fromemails.emaillist[0])) < 0) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1018 log_error(LOG_ARGS, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1019 "could not write omit file"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1020 myfree(mqueuename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1021 exit(EXIT_FAILURE); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1022 } |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1023 fsync(omitfd); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1024 close(omitfd); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1025 } |
744 | 1026 newmoderated(listdir, mqueuename, mlmmjsend, efrom, 2, maildata); |
69 | 1027 return EXIT_SUCCESS; |
1028 } | |
1029 | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
1030 myfree(randomstr); |
69 | 1031 |
11 | 1032 if(noprocess) { |
245 | 1033 myfree(donemailname); |
1034 /* XXX: toemails and ccemails etc. have to be myfree() */ | |
11 | 1035 exit(EXIT_SUCCESS); |
1036 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
1037 |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1038 if (notmetoo) |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1039 execlp(mlmmjsend, mlmmjsend, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1040 "-L", listdir, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1041 "-o", fromemails.emaillist[0], |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1042 "-m", donemailname, (char *)NULL); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1043 else |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1044 execlp(mlmmjsend, mlmmjsend, |
0 | 1045 "-L", listdir, |
435 | 1046 "-m", donemailname, (char *)NULL); |
39 | 1047 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
18 | 1048 |
0 | 1049 return EXIT_FAILURE; |
1050 } |