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