Mercurial > hg > mlmmj
annotate src/mlmmj-process.c @ 756:f8f3f4525a2b
Cosmetic changes to help messages
author | Ben Schmidt |
---|---|
date | Fri, 08 Oct 2010 01:47:46 +1100 |
parents | dfc9ab125fd4 |
children | c3ee2bfaeb02 |
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" | |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
43 #include "do_all_the_voodoo_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 { | |
756 | 371 printf("Usage: %s -L /path/to/list\n" |
372 " -m /path/to/mail [-h] [-P] [-V]\n" | |
102 | 373 " -h: This help\n" |
374 " -L: Full path to list directory\n" | |
375 " -m: Full path to mail file\n" | |
376 " -P: Don't execute mlmmj-send\n" | |
377 " -V: Print version\n", prg); | |
378 | |
379 exit(EXIT_SUCCESS); | |
0 | 380 } |
381 | |
382 int main(int argc, char **argv) | |
383 { | |
459 | 384 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
|
385 int hdrfd, footfd, rawmailfd, donemailfd, omitfd; |
602 | 386 int subonlypost = 0, addrtocc = 1, intocc = 0, modnonsubposts = 0; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
387 int maxmailsize = 0; |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
388 int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
389 int nomaxmailsizedenymails = 0; |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
390 int notmetoo = 0; |
11 | 391 char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL; |
392 char *footerfilename = NULL, *donemailname = NULL; | |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
393 char *randomstr = NULL, *mqueuename, *omitfilename; |
47 | 394 char *mlmmjsend, *mlmmjsub, *mlmmjunsub, *mlmmjbounce; |
520 | 395 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
|
396 char *listfqdn, *listname, *fromaddr; |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
397 char *queuefilename, *recipextra = NULL, *owner = NULL; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
398 char *maxmailsizestr; |
744 | 399 char *maildata[6] = { "subject", NULL, |
400 "posteraddr", NULL, "maxmailsize", NULL }; | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
401 char *envstr, *efrom; |
295 | 402 struct stat st; |
403 uid_t uid; | |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
404 struct email_container fromemails = { 0, NULL }; |
11 | 405 struct email_container toemails = { 0, NULL }; |
135 | 406 struct email_container ccemails = { 0, NULL }; |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
407 struct email_container rpemails = { 0, NULL }; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
408 struct email_container dtemails = { 0, NULL }; |
259 | 409 struct strlist *access_rules = NULL; |
410 struct strlist *delheaders = NULL; | |
254 | 411 struct strlist allheaders; |
459 | 412 struct strlist *alternates = NULL; |
11 | 413 struct mailhdr readhdrs[] = { |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
414 { "From:", 0, NULL }, |
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
415 { "To:", 0, NULL }, |
135 | 416 { "Cc:", 0, NULL }, |
304 | 417 { "Return-Path:", 0, NULL }, |
418 { "Delivered-To:", 0, NULL }, | |
744 | 419 { "Subject:", 0, NULL }, |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
420 { NULL, 0, NULL } |
11 | 421 }; |
38 | 422 |
208
688011dbc4b7
Add a macro to make sure mlmmj binaries are invoked with full path
mmj
parents:
184
diff
changeset
|
423 CHECKFULLPATH(argv[0]); |
688011dbc4b7
Add a macro to make sure mlmmj binaries are invoked with full path
mmj
parents:
184
diff
changeset
|
424 |
47 | 425 log_set_name(argv[0]); |
426 | |
117
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
427 bindir = mydirname(argv[0]); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
428 mlmmjsend = concatstr(2, bindir, "/mlmmj-send"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
429 mlmmjsub = concatstr(2, bindir, "/mlmmj-sub"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
430 mlmmjunsub = concatstr(2, bindir, "/mlmmj-unsub"); |
9a39dff171fa
added mydirname() and mybasename() which doesn't mess with their argument, and
mortenp
parents:
103
diff
changeset
|
431 mlmmjbounce = concatstr(2, bindir, "/mlmmj-bounce"); |
245 | 432 myfree(bindir); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
433 |
12 | 434 while ((opt = getopt(argc, argv, "hVPm:L:")) != -1) { |
0 | 435 switch(opt) { |
436 case 'L': | |
437 listdir = optarg; | |
438 break; | |
439 case 'm': | |
440 mailfile = optarg; | |
441 break; | |
442 case 'h': | |
443 print_help(argv[0]); | |
444 break; | |
11 | 445 case 'P': |
446 noprocess = 1; | |
447 break; | |
0 | 448 case 'V': |
449 print_version(argv[0]); | |
69 | 450 exit(EXIT_SUCCESS); |
0 | 451 } |
452 } | |
295 | 453 |
11 | 454 if(listdir == NULL || mailfile == NULL) { |
0 | 455 fprintf(stderr, "You have to specify -L and -m\n"); |
456 fprintf(stderr, "%s -h for help\n", argv[0]); | |
457 exit(EXIT_FAILURE); | |
458 } | |
459 | |
295 | 460 /* Lets make sure no random user tries to send mail to the list */ |
461 if(listdir) { | |
462 if(stat(listdir, &st) == 0) { | |
463 uid = getuid(); | |
464 if(uid && uid != st.st_uid) { | |
465 log_error(LOG_ARGS, | |
466 "Have to invoke either as root " | |
467 "or as the user owning listdir"); | |
468 writen(STDERR_FILENO, | |
469 "Have to invoke either as root " | |
470 "or as the user owning listdir\n", 60); | |
471 exit(EXIT_FAILURE); | |
472 } | |
473 } else { | |
474 log_error(LOG_ARGS, "Could not stat %s", listdir); | |
475 exit(EXIT_FAILURE); | |
476 } | |
477 } | |
478 | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
479 do { |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
480 myfree(donemailname); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
481 myfree(randomstr); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
482 randomstr = random_str(); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
483 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
|
484 |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
485 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
|
486 S_IRUSR|S_IWUSR); |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
487 |
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
488 } while ((donemailfd < 0) && (errno == EEXIST)); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
489 |
163 | 490 if(donemailfd < 0) { |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
491 log_error(LOG_ARGS, "could not create %s", donemailname); |
245 | 492 myfree(donemailname); |
0 | 493 exit(EXIT_FAILURE); |
494 } | |
163 | 495 #if 0 |
496 log_error(LOG_ARGS, "donemailname = [%s]\n", donemailname); | |
497 #endif | |
498 if((rawmailfd = open(mailfile, O_RDONLY)) < 0) { | |
487 | 499 unlink(donemailname); |
245 | 500 myfree(donemailname); |
163 | 501 log_error(LOG_ARGS, "could not open() input mail file"); |
0 | 502 exit(EXIT_FAILURE); |
503 } | |
504 | |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
505 /* hdrfd is checked in do_all_the_voodoo_here(), because the |
308
5582a75b0a2a
added comments about - seemingly - unchecked open() calls
mortenp
parents:
305
diff
changeset
|
506 * 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
|
507 headerfilename = concatstr(2, listdir, "/control/customheaders"); |
163 | 508 hdrfd = open(headerfilename, O_RDONLY); |
245 | 509 myfree(headerfilename); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
510 |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
511 /* footfd is checked in do_all_the_voodoo_here(), see above */ |
132
24134b985e79
Move footer and customheader to control/. I've been meaning to do this
mmj
parents:
127
diff
changeset
|
512 footerfilename = concatstr(2, listdir, "/control/footer"); |
163 | 513 footfd = open(footerfilename, O_RDONLY); |
245 | 514 myfree(footerfilename); |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
515 |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
516 delheaders = ctrlvalues(listdir, "delheaders"); |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
517 if(delheaders == NULL) { |
245 | 518 delheaders = mymalloc(sizeof(struct strlist)); |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
519 delheaders->count = 0; |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
520 delheaders->strs = NULL; |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
521 } |
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
522 |
245 | 523 delheaders->strs = myrealloc(delheaders->strs, |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
524 (delheaders->count+3) * sizeof(char *)); |
245 | 525 delheaders->strs[delheaders->count++] = mystrdup("From "); |
526 delheaders->strs[delheaders->count++] = mystrdup("Return-Path:"); | |
381 | 527 delheaders->strs[delheaders->count] = NULL; |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
528 |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
529 subjectprefix = ctrlvalue(listdir, "prefix"); |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
530 |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
531 if(do_all_the_voodoo_here(rawmailfd, donemailfd, hdrfd, footfd, |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
532 (const char**)delheaders->strs, readhdrs, |
254 | 533 &allheaders, subjectprefix) < 0) { |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
534 log_error(LOG_ARGS, "Error in do_all_the_voodoo_here"); |
163 | 535 exit(EXIT_FAILURE); |
536 } | |
0 | 537 |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
538 for(i = 0; i < delheaders->count; i++) |
245 | 539 myfree(delheaders->strs[i]); |
540 myfree(delheaders->strs); | |
233
3b4fa52561d6
Implement control/delheaders in where one can specify all the headers
mmj
parents:
228
diff
changeset
|
541 |
163 | 542 close(rawmailfd); |
543 close(donemailfd); | |
0 | 544 |
350 | 545 if(hdrfd >= 0) |
163 | 546 close(hdrfd); |
350 | 547 if(footfd >= 0) |
163 | 548 close(footfd); |
11 | 549 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
550 /* From: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
551 for(i = 0; i < readhdrs[0].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
552 find_email_adr(readhdrs[0].values[i], &fromemails); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
553 } |
744 | 554 if (fromemails.emailcount) |
555 maildata[3] = fromemails.emaillist[0]; | |
568
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 /* To: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
558 for(i = 0; i < readhdrs[1].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
559 find_email_adr(readhdrs[1].values[i], &toemails); |
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 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
562 /* Cc: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
563 for(i = 0; i < readhdrs[2].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
564 find_email_adr(readhdrs[2].values[i], &ccemails); |
11 | 565 } |
566 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
567 /* Return-Path: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
568 for(i = 0; i < readhdrs[3].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
569 find_email_adr(readhdrs[3].values[i], &rpemails); |
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 |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
572 /* Delivered-To: addresses */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
573 for(i = 0; i < readhdrs[4].valuecount; i++) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
574 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
|
575 } |
135 | 576 |
744 | 577 /* Subject: */ |
578 if (readhdrs[5].valuecount) | |
579 maildata[1] = unistr_header_to_utf8(readhdrs[5].values[0]); | |
580 if (!maildata[1]) | |
581 maildata[1] = mystrdup(""); | |
582 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
583 /* envelope from */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
584 if((envstr = getenv("SENDER")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
585 /* qmail, postfix, exim */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
586 efrom = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
587 } else if(rpemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
588 /* the (first) Return-Path: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
589 efrom = mystrdup(rpemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
590 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
591 efrom = mystrdup(""); |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
592 } |
227 | 593 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
594 /* 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
|
595 if((envstr = getenv("DEFAULT")) != NULL) { |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
596 /* qmail */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
597 recipextra = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
598 } else if((envstr = getenv("EXTENSION")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
599 /* postfix */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
600 recipextra = mystrdup(envstr); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
601 } else if((envstr = getenv("LOCAL_PART_SUFFIX")) != NULL) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
602 /* exim */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
603 listdelim = getlistdelim(listdir); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
604 if (strncmp(envstr, listdelim, strlen(listdelim)) == 0) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
605 recipextra = mystrdup(envstr + strlen(listdelim)); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
606 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
607 recipextra = mystrdup(envstr); |
227 | 608 } |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
609 myfree(listdelim); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
610 } else if(dtemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
611 /* parse the (first) Delivered-To: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
612 recipextra = recipient_extra(listdir, dtemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
613 } else if(toemails.emailcount >= 1) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
614 /* parse the (first) To: header */ |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
615 recipextra = recipient_extra(listdir, toemails.emaillist[0]); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
616 } else { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
617 recipextra = NULL; |
304 | 618 } |
619 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
620 if(recipextra && (strlen(recipextra) == 0)) { |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
621 myfree(recipextra); |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
622 recipextra = NULL; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
623 } |
347
b15e8c2dc97f
When using Delivered-To: for spotting the recipient delimiter we
mmj
parents:
340
diff
changeset
|
624 |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
625 /* Why is this here, and not in listcontrol() ? -- mortenp 20060409 */ |
520 | 626 if(recipextra) { |
291 | 627 owner = concatstr(2, listdir, "/control/owner"); |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
628 if(owner && strcmp(recipextra, "owner") == 0) { |
381 | 629 /* strip envelope from before resending */ |
382 | 630 delheaders->count = 0; |
631 delheaders->strs = NULL; | |
381 | 632 delheaders->strs = myrealloc(delheaders->strs, |
633 (delheaders->count+3) * sizeof(char *)); | |
634 delheaders->strs[delheaders->count++] = | |
635 mystrdup("From "); | |
636 delheaders->strs[delheaders->count++] = | |
637 mystrdup("Return-Path:"); | |
638 delheaders->strs[delheaders->count] = NULL; | |
639 if((rawmailfd = open(mailfile, O_RDONLY)) < 0) { | |
640 log_error(LOG_ARGS, "could not open() " | |
641 "input mail file"); | |
642 exit(EXIT_FAILURE); | |
643 } | |
644 if((donemailfd = open(donemailname, | |
645 O_WRONLY|O_TRUNC)) < 0) { | |
646 log_error(LOG_ARGS, "could not open() " | |
647 "output mail file"); | |
648 exit(EXIT_FAILURE); | |
649 } | |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
650 if(do_all_the_voodoo_here(rawmailfd, donemailfd, -1, |
381 | 651 -1, (const char**)delheaders->strs, |
652 NULL, &allheaders, NULL) < 0) { | |
748
dfc9ab125fd4
Fix spelling of 'receive' and 'voodoo'; make mlmmj-recieve a symlink
Chris Webb
parents:
744
diff
changeset
|
653 log_error(LOG_ARGS, "do_all_the_voodoo_here"); |
381 | 654 exit(EXIT_FAILURE); |
655 } | |
656 close(rawmailfd); | |
657 close(donemailfd); | |
658 unlink(mailfile); | |
744 | 659 log_oper(listdir, OPLOGFNAME, "mlmmj-process: sending" |
430 | 660 " mail from %s to owner", |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
661 efrom); |
227 | 662 execlp(mlmmjsend, mlmmjsend, |
228
fda21d560980
Make it possible to specify several owner emailaddresses, not just one
mmj
parents:
227
diff
changeset
|
663 "-l", "4", |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
664 "-L", listdir, |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
665 "-F", efrom, |
228
fda21d560980
Make it possible to specify several owner emailaddresses, not just one
mmj
parents:
227
diff
changeset
|
666 "-s", owner, |
227 | 667 "-a", |
435 | 668 "-m", donemailname, (char *)NULL); |
227 | 669 log_error(LOG_ARGS, "execlp() of '%s' failed", |
670 mlmmjsend); | |
671 exit(EXIT_FAILURE); | |
672 } | |
58 | 673 #if 0 |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
674 log_error(LOG_ARGS, "listcontrol(from, %s, %s, %s, %s, %s, %s)\n", listdir, toemails.emaillist[0], mlmmjsub, mlmmjunsub, mlmmjsend, mlmmjbounce); |
58 | 675 #endif |
227 | 676 unlink(mailfile); |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
677 listcontrol(&fromemails, listdir, recipextra, |
163 | 678 mlmmjsub, mlmmjunsub, mlmmjsend, mlmmjbounce, |
679 donemailname); | |
536
ccb245244750
added unlink()ing of listcontrol messages (was in listcontrol.c)
mortenp
parents:
534
diff
changeset
|
680 |
11 | 681 return EXIT_SUCCESS; |
682 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
683 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
684 listaddr = getlistaddr(listdir); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
685 alternates = ctrlvalues(listdir, "listaddress"); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
686 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
687 /* checking incoming mail's size */ |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
688 maxmailsizestr = ctrlvalue(listdir, "maxmailsize"); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
689 if(maxmailsizestr) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
690 maxmailsize = atol(maxmailsizestr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
691 if(stat(donemailname, &st) < 0) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
692 log_error(LOG_ARGS, "stat(%s,..) failed", donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
693 exit(EXIT_FAILURE); |
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 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
696 if(st.st_size > maxmailsize) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
697 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
698 nomaxmailsizedenymails = statctrl(listdir, "nomaxmailsizedenymails"); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
699 if (nomaxmailsizedenymails) { |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
700 errno = 0; |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
701 log_error(LOG_ARGS, "Discarding %s due to" |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
702 " size limit (%d bytes too big)", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
703 donemailname, (st.st_size - maxmailsize)); |
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 exit(EXIT_SUCCESS); |
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 |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
711 listdelim = getlistdelim(listdir); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
712 listname = genlistname(listaddr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
713 listfqdn = genlistfqdn(listaddr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
714 fromaddr = concatstr(4, listname, listdelim, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
715 "bounces-help@", listfqdn); |
744 | 716 maildata[5] = maxmailsizestr; |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
717 queuefilename = prepstdreply(listdir, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
718 "maxmailsize", "$listowner$", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
719 fromemails.emaillist[0], |
744 | 720 NULL, 1, maildata+4, donemailname); |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
721 MY_ASSERT(queuefilename) |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
722 myfree(listdelim); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
723 myfree(listname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
724 myfree(listfqdn); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
725 unlink(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
726 unlink(mailfile); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
727 myfree(donemailname); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
728 myfree(maxmailsizestr); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
729 execlp(mlmmjsend, mlmmjsend, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
730 "-l", "1", |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
731 "-L", listdir, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
732 "-T", fromemails.emaillist[0], |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
733 "-F", fromaddr, |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
734 "-m", queuefilename, (char *)NULL); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
735 |
629
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
736 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
737 exit(EXIT_FAILURE); |
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 } |
61e93e5c3ecf
Added support for mail size limit (Christoph Wilke)
mortenp
parents:
626
diff
changeset
|
740 |
484 | 741 /* discard malformed mail with invalid From: */ |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
742 if(fromemails.emailcount != 1) { |
532 | 743 for(i = 0; i < fromemails.emailcount; i++) |
744 printf("fromemails.emaillist[%d] = %s\n", | |
745 i, fromemails.emaillist[i]); | |
484 | 746 discardname = concatstr(3, listdir, |
747 "/queue/discarded/", randomstr); | |
532 | 748 log_error(LOG_ARGS, "Discarding %s due to invalid From:", |
749 mailfile); | |
533 | 750 for(i = 0; i < fromemails.emailcount; i++) |
751 log_error(LOG_ARGS, "fromemails.emaillist[%d] = %s\n", | |
752 i, fromemails.emaillist[i]); | |
484 | 753 rename(mailfile, discardname); |
754 unlink(donemailname); | |
755 myfree(donemailname); | |
756 myfree(discardname); | |
757 myfree(randomstr); | |
758 /* TODO: free emailstructs */ | |
759 exit(EXIT_SUCCESS); | |
760 } | |
761 | |
381 | 762 myfree(delheaders); |
763 | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
764 if(strcmp(efrom, "") == 0) { /* don't send mails with <> in From |
305 | 765 to the list */ |
766 discardname = concatstr(3, listdir, | |
767 "/queue/discarded/", | |
768 randomstr); | |
568
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
769 errno = 0; |
99f493df54af
Add support for qmail (envelope from address in environment variable)
mortenp
parents:
562
diff
changeset
|
770 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
|
771 " from address", mailfile); |
333
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
772 rename(mailfile, discardname); |
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
773 unlink(donemailname); |
305 | 774 myfree(donemailname); |
775 myfree(discardname); | |
776 myfree(randomstr); | |
777 /* TODO: free emailstructs */ | |
778 exit(EXIT_SUCCESS); | |
779 } | |
780 | |
333
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
781 unlink(mailfile); |
d70614c2d99e
Save the raw incoming mail when discarding, not the processed one.
mmj
parents:
312
diff
changeset
|
782 |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
783 addrtocc = !(statctrl(listdir, "tocc")); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
784 if(addrtocc) { |
459 | 785 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
|
786 log_error(LOG_ARGS, "Found To: %s", |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
787 toemails.emaillist[i]); |
459 | 788 for(j = 0; j < alternates->count; j++) { |
789 chomp(alternates->strs[j]); | |
523 | 790 if(strcasecmp(alternates->strs[j], |
459 | 791 toemails.emaillist[i]) == 0) |
792 intocc = 1; | |
793 } | |
794 } | |
795 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
|
796 log_error(LOG_ARGS, "Found Cc: %s", |
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
797 ccemails.emaillist[i]); |
459 | 798 for(j = 0; j < alternates->count; j++) { |
799 chomp(alternates->strs[j]); | |
523 | 800 if(strcasecmp(alternates->strs[j], |
459 | 801 ccemails.emaillist[i]) == 0) |
802 intocc = 1; | |
803 } | |
804 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
805 } |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
806 |
459 | 807 for(i = 0; i < alternates->count; i++) |
808 myfree(alternates->strs[i]); | |
809 | |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
810 notoccdenymails = statctrl(listdir, "notoccdenymails"); |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
811 |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
812 if(addrtocc && !intocc) { |
339 | 813 /* 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
|
814 * 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
|
815 */ |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
816 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
|
817 notoccdenymails) { |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
818 log_error(LOG_ARGS, "Discarding %s because list" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
819 " address was not in To: or Cc:," |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
820 " and From: was the list or" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
821 " notoccdenymails was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
822 mailfile); |
339 | 823 myfree(listaddr); |
824 unlink(donemailname); | |
825 myfree(donemailname); | |
826 exit(EXIT_SUCCESS); | |
827 } | |
520 | 828 listdelim = getlistdelim(listdir); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
829 listname = genlistname(listaddr); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
830 listfqdn = genlistfqdn(listaddr); |
520 | 831 fromaddr = concatstr(4, listname, listdelim, "bounces-help@", |
832 listfqdn); | |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
833 queuefilename = prepstdreply(listdir, "notintocc", |
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
834 "$listowner$", fromemails.emaillist[0], |
744 | 835 NULL, 2, maildata, donemailname); |
254 | 836 MY_ASSERT(queuefilename) |
520 | 837 myfree(listdelim); |
245 | 838 myfree(listname); |
839 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
840 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
841 myfree(donemailname); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
842 execlp(mlmmjsend, mlmmjsend, |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
843 "-l", "1", |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
844 "-L", listdir, |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
845 "-T", fromemails.emaillist[0], |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
846 "-F", fromaddr, |
435 | 847 "-m", queuefilename, (char *)NULL); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
848 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
849 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
|
850 exit(EXIT_FAILURE); |
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 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
853 subonlypost = statctrl(listdir, "subonlypost"); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
854 if(subonlypost) { |
339 | 855 /* Don't send a mail about denial to the list, but silently |
440 | 856 * discard and exit. */ |
857 if (strcasecmp(listaddr, fromemails.emaillist[0]) == 0) { | |
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 was set and From: was" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
860 " the list address", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
861 mailfile); |
339 | 862 myfree(listaddr); |
863 unlink(donemailname); | |
864 myfree(donemailname); | |
865 exit(EXIT_SUCCESS); | |
866 } | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
867 if(is_subbed(listdir, fromemails.emaillist[0]) != 0) { |
602 | 868 modnonsubposts = statctrl(listdir, |
869 "modnonsubposts"); | |
870 if(modnonsubposts) { | |
871 moderated = 1; | |
872 goto startaccess; | |
873 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
874 |
602 | 875 nosubonlydenymails = statctrl(listdir, |
876 "nosubonlydenymails"); | |
877 | |
440 | 878 if(nosubonlydenymails) { |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
879 log_error(LOG_ARGS, "Discarding %s because" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
880 " subonlypost and" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
881 " nosubonlydenymails was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
882 mailfile); |
440 | 883 myfree(listaddr); |
884 unlink(donemailname); | |
885 myfree(donemailname); | |
886 exit(EXIT_SUCCESS); | |
887 } | |
520 | 888 listdelim = getlistdelim(listdir); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
889 listname = genlistname(listaddr); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
890 listfqdn = genlistfqdn(listaddr); |
520 | 891 fromaddr = concatstr(4, listname, listdelim, |
892 "bounces-help@", listfqdn); | |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
893 queuefilename = prepstdreply(listdir, "subonlypost", |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
894 "$listowner$", fromemails.emaillist[0], |
744 | 895 NULL, 2, maildata, donemailname); |
254 | 896 MY_ASSERT(queuefilename) |
245 | 897 myfree(listaddr); |
520 | 898 myfree(listdelim); |
245 | 899 myfree(listname); |
900 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
901 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
902 myfree(donemailname); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
903 execlp(mlmmjsend, mlmmjsend, |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
904 "-l", "1", |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
905 "-T", fromemails.emaillist[0], |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
906 "-F", fromaddr, |
435 | 907 "-m", queuefilename, (char *)NULL); |
221
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
908 |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
909 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
|
910 exit(EXIT_FAILURE); |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
911 } |
1673fe779f37
Add functionality for subscribers only posting and to only allow posts with
mmj
parents:
208
diff
changeset
|
912 } |
11 | 913 |
602 | 914 startaccess: |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
915 |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
916 if(!moderated) |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
917 moderated = statctrl(listdir, "moderated"); |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
918 |
439
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
919 noaccessdenymails = statctrl(listdir, "noaccessdenymails"); |
b75073f25e60
Add switches to control whether or not mlmmj sends out mails explaining
mmj
parents:
435
diff
changeset
|
920 |
254 | 921 access_rules = ctrlvalues(listdir, "access"); |
922 if (access_rules) { | |
386 | 923 enum action accret; |
339 | 924 /* 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
|
925 * discard and exit. Also do this in case it's turned off */ |
626 | 926 accret = do_access(access_rules, &allheaders, |
705 | 927 fromemails.emaillist[0], listdir); |
386 | 928 if (accret == DENY) { |
445 | 929 if ((strcasecmp(listaddr, fromemails.emaillist[0]) == |
930 0) || noaccessdenymails) { | |
534
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
931 log_error(LOG_ARGS, "Discarding %s because" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
932 " it was denied by an access" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
933 " rule, and From: was the list" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
934 " address or noaccessdenymails" |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
935 " was set", |
4f099cb2099b
Added log messages at points where mail is discarded
mortenp
parents:
533
diff
changeset
|
936 mailfile); |
445 | 937 myfree(listaddr); |
938 unlink(donemailname); | |
939 myfree(donemailname); | |
940 exit(EXIT_SUCCESS); | |
941 } | |
520 | 942 listdelim = getlistdelim(listdir); |
254 | 943 listname = genlistname(listaddr); |
944 listfqdn = genlistfqdn(listaddr); | |
520 | 945 fromaddr = concatstr(4, listname, listdelim, |
946 "bounces-help@", listfqdn); | |
254 | 947 queuefilename = prepstdreply(listdir, "access", |
359
ca217febcfbd
Rerwrite the way listtexts are handled and move Subject: out into the file
mmj
parents:
350
diff
changeset
|
948 "$listowner$", |
254 | 949 fromemails.emaillist[0], |
744 | 950 NULL, 2, maildata, donemailname); |
254 | 951 MY_ASSERT(queuefilename) |
952 myfree(listaddr); | |
520 | 953 myfree(listdelim); |
254 | 954 myfree(listname); |
955 myfree(listfqdn); | |
262
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
956 unlink(donemailname); |
846d91ae6ebe
Don't litter the queue directory when rejecting posts for one reason or the
mmj
parents:
259
diff
changeset
|
957 myfree(donemailname); |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
958 myfree(randomstr); |
254 | 959 execlp(mlmmjsend, mlmmjsend, |
960 "-l", "1", | |
529
d65b467b647d
Pass on listdir to mlmmjsend so we can get the smtpport and relayhost also
mmj
parents:
523
diff
changeset
|
961 "-L", listdir, |
254 | 962 "-T", fromemails.emaillist[0], |
963 "-F", fromaddr, | |
435 | 964 "-m", queuefilename, (char *)NULL); |
254 | 965 |
966 log_error(LOG_ARGS, "execlp() of '%s' failed", | |
967 mlmmjsend); | |
968 exit(EXIT_FAILURE); | |
386 | 969 } else if (accret == MODERATE) { |
970 moderated = 1; | |
640
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
971 } else if (accret == DISCARD) { |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
972 discardname = concatstr(3, listdir, |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
973 "/queue/discarded/", randomstr); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
974 myfree(randomstr); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
975 if(rename(donemailname, discardname) < 0) { |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
976 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
|
977 donemailname, discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
978 myfree(donemailname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
979 myfree(discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
980 exit(EXIT_FAILURE); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
981 } |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
982 myfree(donemailname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
983 myfree(discardname); |
3770bb64ea17
Added support for 'discard' keyword in access rules (Sascha Sommer)
mortenp
parents:
629
diff
changeset
|
984 exit(EXIT_SUCCESS); |
719
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
985 } else if (accret == SEND) { |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
986 moderated = 0; |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
987 } else if (accret == ALLOW) { |
30e6e309891d
Added "send" keyword to control/access handling (Ben Schmidt)
mortenp
parents:
705
diff
changeset
|
988 /* continue processing as normal */ |
254 | 989 } |
990 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
991 |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
992 notmetoo = statctrl(listdir, "notmetoo"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
993 |
69 | 994 if(moderated) { |
127
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
995 mqueuename = concatstr(3, listdir, "/moderation/", |
b525c4f78ef7
Use listdir/moderation for the mails up for moderation and use
mmj
parents:
117
diff
changeset
|
996 randomstr); |
245 | 997 myfree(randomstr); |
69 | 998 if(rename(donemailname, mqueuename) < 0) { |
163 | 999 log_error(LOG_ARGS, "could not rename(%s,%s)", |
69 | 1000 donemailname, mqueuename); |
245 | 1001 myfree(donemailname); |
1002 myfree(mqueuename); | |
69 | 1003 exit(EXIT_FAILURE); |
1004 } | |
245 | 1005 myfree(donemailname); |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1006 if (notmetoo) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1007 omitfilename = concatstr(2, mqueuename, ".omit"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1008 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
|
1009 if (omitfd < 0) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1010 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
|
1011 omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1012 myfree(mqueuename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1013 myfree(omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1014 exit(EXIT_FAILURE); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1015 } |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1016 myfree(omitfilename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1017 if(writen(omitfd, fromemails.emaillist[0], |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1018 strlen(fromemails.emaillist[0])) < 0) { |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1019 log_error(LOG_ARGS, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1020 "could not write omit file"); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1021 myfree(mqueuename); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1022 exit(EXIT_FAILURE); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1023 } |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1024 fsync(omitfd); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1025 close(omitfd); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1026 } |
744 | 1027 newmoderated(listdir, mqueuename, mlmmjsend, efrom, 2, maildata); |
69 | 1028 return EXIT_SUCCESS; |
1029 } | |
1030 | |
275
9a847bfdc764
Don't fail in mlmmj-process b/c of EEXIST on the queuefilenames
mmj
parents:
262
diff
changeset
|
1031 myfree(randomstr); |
69 | 1032 |
11 | 1033 if(noprocess) { |
245 | 1034 myfree(donemailname); |
1035 /* XXX: toemails and ccemails etc. have to be myfree() */ | |
11 | 1036 exit(EXIT_SUCCESS); |
1037 } | |
672
dfc3ec149b60
Remove trailing whitespaces and not mmap 0 sized bounce index file
mmj
parents:
660
diff
changeset
|
1038 |
727
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1039 if (notmetoo) |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1040 execlp(mlmmjsend, mlmmjsend, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1041 "-L", listdir, |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1042 "-o", fromemails.emaillist[0], |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1043 "-m", donemailname, (char *)NULL); |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1044 else |
4575d3181ca1
Added notmetoo feature where posts are not mirrored to their senders.
Ben Schmidt
parents:
719
diff
changeset
|
1045 execlp(mlmmjsend, mlmmjsend, |
0 | 1046 "-L", listdir, |
435 | 1047 "-m", donemailname, (char *)NULL); |
39 | 1048 log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend); |
18 | 1049 |
0 | 1050 return EXIT_FAILURE; |
1051 } |