annotate src/deliver.c @ 433:81c438e1891b

Marks version number as development.
author markus schnalke <meillo@marmaro.de>
date Sat, 07 Feb 2015 11:40:21 +0100
parents 5593964ec779
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
1 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
2 ** MasqMail
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
3 ** Copyright (C) 1999-2002 Oliver Kurth
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
4 ** Copyright (C) 2008, 2010 markus schnalke <meillo@marmaro.de>
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
5 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
6 ** This program is free software; you can redistribute it and/or modify
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
7 ** it under the terms of the GNU General Public License as published by
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
8 ** the Free Software Foundation; either version 2 of the License, or
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
9 ** (at your option) any later version.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
10 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
11 ** This program is distributed in the hope that it will be useful,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
14 ** GNU General Public License for more details.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
15 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
16 ** You should have received a copy of the GNU General Public License
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
17 ** along with this program; if not, write to the Free Software
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
19 */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
20
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
21 #include <fnmatch.h>
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
22 #include <sysexits.h>
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
23 #include <netdb.h>
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
24
15
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 12
diff changeset
25 #include "masqmail.h"
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 12
diff changeset
26 #include "smtp_out.h"
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 12
diff changeset
27
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
28 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
29 ** collect failed/defered rcpts for failure/warning messages
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
30 ** returns TRUE if either there are no failures or a failure message has
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
31 ** been successfully sent
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
32 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
33 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
34 delivery_failures(message *msg, GList *rcpt_list, gchar *err_fmt, ...)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
35 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
36 gboolean ok_fail = TRUE, ok_warn = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
37 time_t now = time(NULL);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
38
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
39 GList *failed_list = NULL, *defered_list = NULL, *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
40 va_list args;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
41 va_start(args, err_fmt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
42
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
43 foreach(rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
44 address *rcpt = (address *) (rcpt_node->data);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
45
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
46 if (addr_is_defered(rcpt)) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
47 if ((now - msg->received_time) >= conf.max_defer_time){
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
48 addr_mark_failed(rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
49 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
50 defered_list = g_list_prepend(defered_list,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
51 rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
52 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
53 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
54 if (addr_is_failed(rcpt)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
55 failed_list = g_list_prepend(failed_list, rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
56 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
57 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
58 if (failed_list) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
59 ok_fail = fail_msg(msg, conf.errmsg_file, failed_list,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
60 err_fmt, args);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
61 g_list_free(failed_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
62 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
63 if (defered_list) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
64 ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
65 err_fmt, args);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 g_list_free(defered_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
67 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
68 va_end(args);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
69 return ok_fail && ok_warn;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
70 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
71
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
72 static gint
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
73 _g_list_strcasecmp(gconstpointer a, gconstpointer b)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
74 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
75 return (gint) strcasecmp(a, b);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
76 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
77
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
78 gboolean
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
79 deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
80 address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
81 {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
82 DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
83 if (append_file(msg, hdr_list, rcpt->local_part)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
84 if (env_addr != rcpt) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
85 logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
86 msg->uid, rcpt->local_part,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
87 rcpt->domain, env_addr->local_part,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
88 env_addr->domain);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
89 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
90 logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
91 msg->uid, rcpt->local_part,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
92 rcpt->domain);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
93 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
94 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
95 return TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
96 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
97
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
98 /* prevents 'Resource temporarily unavailable (11)' */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
99 if (errno != EAGAIN) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
100 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
101 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
102 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
103 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
104 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
105 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
106
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
107 gboolean
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
108 deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
109 address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
110 {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
111 guint flags = 0;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
112
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
113 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
114
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
115 flags |= (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
116 flags |= (conf.pipe_fromhack) ? MSGSTR_FROMHACK : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
117 if (pipe_out(msg, hdr_list, rcpt, &(rcpt->local_part[1]), flags)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
118 logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n",
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
119 msg->uid, rcpt->local_part,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
120 env_addr->local_part, env_addr->domain);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
121 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
122 return TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
123 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
124
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
125 if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
126 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
127 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
128 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
129 /* has no effect yet, except that mail remains in spool */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
130 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
131 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
132 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
133
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
134 gboolean
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
135 deliver_local_mda(message *msg, GList *hdr_list, address *rcpt,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
136 address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
137 {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
138 gboolean ok = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
139 gchar *cmd = g_malloc(256);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
140 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
141 guint flags = 0;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
142
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
143 DEBUG(1) debugf("attempting to deliver %s with mda\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
144
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
145 if (!expand(var_table, conf.mda, cmd, 256)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
146 logwrite(LOG_ALERT, "could not expand string %s\n", conf.mda);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
147 destroy_table(var_table);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
148 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
149 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
150
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
151 flags |= (conf.mda_fromline) ? MSGSTR_FROMLINE : 0;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
152 flags |= (conf.mda_fromhack) ? MSGSTR_FROMHACK : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
153 if (pipe_out(msg, hdr_list, rcpt, cmd, flags)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
154 logwrite(LOG_NOTICE, "%s => %s@%s with mda (cmd = '%s')\n",
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
155 msg->uid, rcpt->local_part, rcpt->domain, cmd);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
156 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
157 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
158 } else if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
159 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
160 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
161 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
162 /* has no effect yet, except that mail remains in spool */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
163 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
164
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
165 destroy_table(var_table);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
166 return ok;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
167 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
168
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
169 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
170 deliver_local(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
171 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
172 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
173 GList *rcpt_list = msgout->rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
174 GList *rcpt_node;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
175 gboolean ok = FALSE, flag = FALSE, ok_fail = FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
176
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
177 DEBUG(5) debugf("deliver_local entered\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
178
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
179 flag = (msg->data_list == NULL);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
180 if (flag && !spool_read_data(msg)) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
181 logwrite(LOG_ALERT, "could not open data spool file for %s\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
182 msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
183 return FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
184 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
185
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
186 for (rcpt_node = g_list_first(rcpt_list); rcpt_node;
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
187 rcpt_node = g_list_next(rcpt_node)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
188 GList *hdr_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
189 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
190 address *env_addr = addr_find_ancestor(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
191 address *ret_path = msg->return_path;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
192 header *retpath_hdr, *envto_hdr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
193
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
194 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
195 ** we need a private copy of the hdr list because we add
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
196 ** headers here that belong to the rcpt only. g_list_copy
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
197 ** copies only the nodes, so it is safe to g_list_free it
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
198 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
199 hdr_list = g_list_copy(msg->hdr_list);
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
200 retpath_hdr = create_header(HEAD_ENVELOPE_TO,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
201 "Envelope-to: %s\n", addr_string(env_addr));
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
202 envto_hdr = create_header(HEAD_RETURN_PATH,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
203 "Return-path: %s\n", addr_string(ret_path));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
204
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
205 hdr_list = g_list_prepend(hdr_list, envto_hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
206 hdr_list = g_list_prepend(hdr_list, retpath_hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
207
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
208 if (*rcpt->local_part == '|') {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
209 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
210 ** probably for expanded aliases, but why not done
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
211 ** like with the mda? //meillo 2010-12-06
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
212 */
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
213 if (deliver_local_pipe(msg, hdr_list, rcpt,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
214 env_addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
215 ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
216 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
217 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
218 /* figure out which mailbox type should be used
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
219 ** for this user */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
220 gchar *user = rcpt->local_part;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
221 gchar *mbox_type = conf.mbox_default;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
222
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
223 if (g_list_find_custom(conf.mbox_users, user,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
224 _g_list_strcasecmp)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
225 mbox_type = "mbox";
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
226 } else if (g_list_find_custom (conf.mda_users, user,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
227 _g_list_strcasecmp)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
228 mbox_type = "mda";
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
229 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
230
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
231 if (strcmp(mbox_type, "mbox")==0) {
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
232 if (deliver_local_mbox(msg, hdr_list, rcpt,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
233 env_addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
234 ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
235 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
236 } else if (strcmp(mbox_type, "mda") == 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
237 if (conf.mda) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
238 if (deliver_local_mda(msg, hdr_list,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
239 rcpt, env_addr)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
240 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
241 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
242 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
243 logwrite(LOG_ALERT, "mbox type is "
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
244 "mda, but no mda "
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
245 "command given in "
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
246 "configuration\n");
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
247 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
248
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
249 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
250 logwrite(LOG_ALERT, "unknown mbox type '%s'\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
251 mbox_type);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
252 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
253 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
254
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
255 destroy_header(retpath_hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
256 destroy_header(envto_hdr);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
257
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
258 g_list_free(hdr_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
259 }
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
260 ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
261 ext_strerror(errno), errno);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
262
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
263 if (flag) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
264 msg_free_data(msg);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
265 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
266 if (ok || ok_fail) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
267 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
268 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
269
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
270 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
271 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
272
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
273 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
274 ** make a list of rcpt's of a message that are local
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
275 ** return a new copy of the list
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
276 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
277 void
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
278 msg_rcptlist_local(GList *rcpt_list, GList **p_local_list,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
279 GList **p_nonlocal_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
280 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
281 GList *rcpt_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
282
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
283 foreach(rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
284 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
285 GList *dom_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
286
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
287 DEBUG(5) debugf("checking address %s\n", rcpt->address);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
288
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
289 /* search for local host list: */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
290 foreach(conf.local_hosts, dom_node) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
291 if (fnmatch(dom_node->data, rcpt->domain,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
292 FNM_CASEFOLD)==0) {
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
293 *p_local_list = g_list_append(*p_local_list,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
294 rcpt);
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
295 DEBUG(5) debugf("<%s@%s> is local\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
296 rcpt->local_part,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
297 rcpt->domain);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
298 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
299 } else {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
300 *p_nonlocal_list = g_list_append(
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
301 *p_nonlocal_list, rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
302 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
303 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
304 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
305 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
306
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
307 gboolean
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
308 deliver_msglist_host_pipe(connect_route *route, GList *msgout_list,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
309 gchar *host, GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
310 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
311 gboolean ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
312 GList *msgout_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
313
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
314 DEBUG(5) debugf("deliver_msglist_host_pipe entered\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
315
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
316 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
317 msg_out *msgout = (msg_out *) (msgout_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
318 gboolean flag, ok_fail = FALSE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
319 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
320 GList *rcpt_node, *rcpt_list = msgout->rcpt_list;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
321
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
322 DEBUG(1) debugf("attempting to deliver %s with pipe\n",
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
323 msg->uid);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
324
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
325 flag = (msg->data_list == NULL);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
326 if (flag && !spool_read_data(msg)) {
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
327 logwrite(LOG_ALERT, "could not open data spool file "
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
328 "for %s\n", msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
329 continue;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
330 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
331
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
332 ok = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
333 foreach(rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
334 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
335 gchar *cmd = g_malloc(256);
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
336 GList *var_table = var_table_rcpt(var_table_msg(NULL,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
337 msg), rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
338
403
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
339 DEBUG(1) debugf("attempting to deliver %s to %s@%s "
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
340 "with pipe\n", msg->uid,
7954b82040b3 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 387
diff changeset
341 rcpt->local_part, rcpt->domain);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
342
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
343 if (!expand(var_table, route->pipe, cmd, 256)) {
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
344 logwrite(LOG_ALERT, "could not expand string `%s'\n", route->pipe);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
345 destroy_table(var_table);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
346 continue;
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
347 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
348
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
349 if (pipe_out(msg, msg->hdr_list, rcpt, cmd, (route->pipe_fromline ? MSGSTR_FROMLINE : 0)
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
350 | (route->pipe_fromhack ? MSGSTR_FROMHACK : 0))) {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
351 logwrite(LOG_NOTICE, "%s => %s@%s with pipe (cmd = '%s')\n",
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
352 msg->uid, rcpt->local_part, rcpt->domain, cmd);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
353 addr_mark_delivered(rcpt);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
354 ok = TRUE;
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
355 } else {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
356 logwrite(LOG_ALERT, "pipe_out '%s' failed\n", route->pipe);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
357
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
358 if (route->connect_error_fail) {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
359 addr_mark_failed(rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
360 } else {
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
361 addr_mark_defered(rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
362 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
363 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
364
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
365 destroy_table(var_table);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
366 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
367 ok_fail = delivery_failures(msg, rcpt_list, "%s", strerror(errno));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
368
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
369 if (flag) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
370 msg_free_data(msg);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
371 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
372 if (ok || ok_fail) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
373 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
374 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
375 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
376
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
377 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
378 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
379
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
380 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
381 ** deliver list of messages to one host and finishes them if the message was
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
382 ** delivered to at least one rcpt.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
383 ** Returns TRUE if at least one msg was delivered to at least one rcpt.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
384 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
385 gboolean
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
386 deliver_msglist_host_smtp(connect_route *route, GList *msgout_list,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
387 gchar *host, GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
388 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
389 gboolean ok = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
390 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
391 smtp_base *psb;
178
91f8ee6514f5 removed `remote_port' config option
meillo@marmaro.de
parents: 114
diff changeset
392 gint port = 25;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
393
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
394 /* paranoid check: */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
395 if (!msgout_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
396 logwrite(LOG_ALERT, "Ooops: empty list of messages in deliver_msglist_host()\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
397 return FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
398 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
399
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
400 if (!host) {
179
3190e6864452 added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents: 178
diff changeset
401 /* XXX: what if mail_host isn't set? Is this possible? */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
402 host = route->mail_host->address;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
403 port = route->mail_host->port;
178
91f8ee6514f5 removed `remote_port' config option
meillo@marmaro.de
parents: 114
diff changeset
404 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
405
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
406 if (route->wrapper) {
372
b0708fac99dd Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents: 370
diff changeset
407 psb = smtp_out_open_child(route->wrapper);
b0708fac99dd Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents: 370
diff changeset
408 if (psb) {
b0708fac99dd Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents: 370
diff changeset
409 psb->remote_host = host;
b0708fac99dd Fixed a problem with psb->remote_host, introduced in changeset 412385b57dc4
markus schnalke <meillo@marmaro.de>
parents: 370
diff changeset
410 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
411 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
412 psb = smtp_out_open(host, port, res_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
413 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
414
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
415 if (!psb) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
416 /* smtp_out_open() failed */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
417 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
418 msg_out *msgout = (msg_out *) (msgout_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
419 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
420
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
421 for (rcpt_node = g_list_first(msgout->rcpt_list);
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
422 rcpt_node;
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
423 rcpt_node = g_list_next(rcpt_node)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
424 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
425 gboolean ret = FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
426
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
427 addr_unmark_delivered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
428 if (route->connect_error_fail) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
429 addr_mark_failed(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
430 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
431 addr_mark_defered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
432 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
433 if (route->wrapper) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
434 ret = delivery_failures(msgout->msg,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
435 msgout->rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
436 "could not open "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
437 "wrapper:\n\t%s",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
438 strerror(errno));
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
439 } else {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
440 ret = delivery_failures(msgout->msg,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
441 msgout->rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
442 "could not open "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
443 "connection to %s:%d "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
444 ":\n\t%s", host, port,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
445 h_errno != 0 ?
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
446 hstrerror(h_errno) :
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
447 strerror(errno));
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
448 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
449 if (ret) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
450 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
451 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
452 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
453 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
454 return ok;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
455 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
456
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
457 set_heloname(psb, route->helo_name ? route->helo_name : conf.host_name,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
458 route->do_correct_helo);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
459
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
460 #ifdef ENABLE_AUTH
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
461 if (route->auth_name && route->auth_login && route->auth_secret) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
462 set_auth(psb, route->auth_name, route->auth_login,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
463 route->auth_secret);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
464 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
465 #endif
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
466 if (!smtp_out_init(psb, route->instant_helo)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
467 /* smtp_out_init() failed */
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
468 if ((psb->error==smtp_fail) || (psb->error==smtp_trylater) ||
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
469 (psb->error==smtp_syntax)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
470 smtp_out_quit(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
471
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
472 foreach(msgout_list, msgout_node) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
473 msg_out *msgout =
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
474 (msg_out *)(msgout_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
475 smtp_out_mark_rcpts(psb, msgout->rcpt_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
476
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
477 if (delivery_failures(msgout->msg,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
478 msgout->rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
479 "while connected with %s, "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
480 "the server replied\n\t%s",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
481 (route->wrapper) ?
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
482 "<wrapper>" : host,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
483 psb->buffer)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
484 deliver_finish(msgout);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
485 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
486 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
487 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
488 destroy_smtpbase(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
489 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
490 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
491
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
492 if (!route->do_pipelining) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
493 psb->use_pipelining = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
494 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
495
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
496 foreach(msgout_list, msgout_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
497 msg_out *msgout = (msg_out *) (msgout_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
498 gboolean flag, ok_msg = FALSE, ok_fail = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
499 message *msg = msgout->msg;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
500
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
501 /* we may have to read the data at this point
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
502 ** and remember if we did */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
503 flag = (msg->data_list == NULL);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
504 if (flag && !spool_read_data(msg)) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
505 logwrite(LOG_ALERT, "could not open data spool "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
506 "file %s\n", msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
507 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
508 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
509
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
510 smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
511 msgout->hdr_list);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
512
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
513 ok_fail = delivery_failures(msg, msgout->rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
514 "while connected with %s, the server "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
515 "replied\n\t%s", (route->wrapper) ?
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
516 "<wrapper>" : host, psb->buffer);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
517
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
518 if ((psb->error == smtp_eof) || (psb->error == smtp_timeout)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
519 /* connection lost */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
520 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
521 } else if (psb->error != smtp_ok) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
522 if (g_list_next(msgout_node) && !smtp_out_rset(psb)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
523 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
524 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
525 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
526 ok_msg = (psb->error == smtp_ok);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
527
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
528 if (flag) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
529 msg_free_data(msg);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
530 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
531 if (ok_msg) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
532 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
533 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
534 if (ok_msg || ok_fail) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
535 deliver_finish(msgout);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
536 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
537 }
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
538 if (psb->error == smtp_ok || (psb->error == smtp_fail) ||
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
539 (psb->error == smtp_trylater) ||
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
540 (psb->error == smtp_syntax)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
541 smtp_out_quit(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
542 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
543 destroy_smtpbase(psb);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
544 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
545 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
546
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
547 gboolean
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
548 deliver_msglist_host(connect_route *route, GList *msgout_list, gchar *host,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
549 GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
550 {
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
551
311
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
552 if (route->pipe) {
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
553 DEBUG(5) debugf("with pipe\n");
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
554 return deliver_msglist_host_pipe(route, msgout_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
555 host, res_list);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
556 } else {
311
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
557 DEBUG(5) debugf("with smtp\n");
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
558 return deliver_msglist_host_smtp(route, msgout_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
559 host, res_list);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
560 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
561 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
562
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
563 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
564 ** delivers messages in msgout_list using route
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
565 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
566 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
567 deliver_route_msgout_list(connect_route *route, GList *msgout_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
568 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
569 gboolean ok = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
570 GList *mo_ph_list;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
571 GList *mo_ph_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
572
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
573 DEBUG(5) debugf("deliver_route_msgout_list entered, route->name=%s\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
574 route->name);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
575
179
3190e6864452 added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents: 178
diff changeset
576 if (route->mail_host) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
577 /* easy: deliver everything to a smart host for relay */
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
578 return deliver_msglist_host(route, msgout_list, NULL,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
579 route->resolve_list);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
580 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
581
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
582 /* this is not easy... */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
583
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
584 mo_ph_list = route_msgout_list(route, msgout_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
585 /* okay, now we have ordered our messages by the hosts. */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
586 if (!mo_ph_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
587 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
588 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
589
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
590 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
591 ** TODO: It would be nice to be able to fork for each host.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
592 ** We cannot do that yet because of complications with finishing the
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
593 ** messages. Threads could be a solution because they use the same
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
594 ** memory. But we are not thread safe yet...
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
595 */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
596 foreach(mo_ph_list, mo_ph_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
597 msgout_perhost *mo_ph = (msgout_perhost *) (mo_ph_node->data);
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
598 if (deliver_msglist_host(route, mo_ph->msgout_list,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
599 mo_ph->host, route->resolve_list)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
600 ok = TRUE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
601 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
602 destroy_msgout_perhost(mo_ph);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
603 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
604 g_list_free(mo_ph_list);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
605 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
606 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
607
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
608 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
609 ** calls route_prepare_msg()
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
610 ** delivers messages in msg_list using route by calling
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
611 ** deliver_route_msgout_list()
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
612 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
613 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
614 deliver_route_msg_list(connect_route *route, GList *msgout_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
615 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
616 GList *msgout_list_deliver = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
617 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
618 gboolean ok = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
619
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
620 DEBUG(6) debugf("deliver_route_msg_list()\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
621
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
622 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
623 msg_out *msgout = (msg_out *) (msgout_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
624 msg_out *msgout_cloned = clone_msg_out(msgout);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
625 GList *rcpt_list_non_delivered = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
626 GList *rcpt_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
627
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
628 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
629 ** we have to delete already delivered rcpt's because a
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
630 ** previous route may have delivered to it
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
631 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
632 foreach(msgout_cloned->rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
633 address *rcpt = (address *) (rcpt_node->data);
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
634 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
635 ** failed addresses already have been bounced;
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
636 ** there should be a better way to handle those.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
637 */
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
638 if (!addr_is_delivered(rcpt) &&
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
639 !addr_is_failed(rcpt) &&
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
640 !(rcpt->flags & ADDR_FLAG_LAST_ROUTE)){
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
641 rcpt_list_non_delivered = g_list_append(rcpt_list_non_delivered, rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
642 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
643 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
644 g_list_free(msgout_cloned->rcpt_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
645 msgout_cloned->rcpt_list = rcpt_list_non_delivered;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
646
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
647 if (!msgout_cloned->rcpt_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
648 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
649 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
650 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
651
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
652 /* filter by allowed envelope sender */
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
653 if (!route_sender_is_allowed(route, msgout->msg->return_path)){
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
654 DEBUG(6) debugf("sender `%s' is not allowed for this "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
655 "route\n", msgout->msg->return_path);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
656 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
657 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
658 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
659
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
660 /* filter by allowed envelope rcpts */
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
661 GList *rcpt_list_allowed = NULL;
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
662 GList *rcpt_list_notallowed = NULL;
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
663 route_split_rcpts(route, msgout_cloned->rcpt_list,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
664 &rcpt_list_allowed, &rcpt_list_notallowed);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
665 if (!rcpt_list_allowed) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
666 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
667 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
668 }
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
669
429
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
670 /* filter by allowed from header */
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
671 GList *from_hdrs = NULL;
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
672 char *from_hdr = NULL;
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
673 from_hdrs = find_header(msgout->msg->hdr_list, HEAD_FROM,
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
674 NULL);
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
675 if (from_hdrs) {
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
676 from_hdr = (char *) ((header *)from_hdrs->data)->value;
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
677 if (!route_from_hdr_is_allowed(route, from_hdr)){
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
678 DEBUG(6) debugf("from hdr `%s' is not allowed for this "
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
679 "route\n", from_hdr);
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
680 destroy_msg_out(msgout_cloned);
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
681 continue;
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
682 }
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
683 }
5593964ec779 Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents: 417
diff changeset
684
370
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
685 logwrite(LOG_NOTICE, "%s using '%s'\n", msgout->msg->uid,
d86d7b4b8995 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
686 route->name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
687
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
688 g_list_free(msgout_cloned->rcpt_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
689 msgout_cloned->rcpt_list = rcpt_list_allowed;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
690
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
691 if (route->last_route) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
692 GList *rcpt_node;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
693 foreach(msgout_cloned->rcpt_list, rcpt_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
694 address *rcpt = (address *) (rcpt_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
695 rcpt->flags |= ADDR_FLAG_LAST_ROUTE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
696 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
697 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
698
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
699 route_prepare_msgout(route, msgout_cloned);
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
700 msgout_list_deliver = g_list_append(msgout_list_deliver,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
701 msgout_cloned);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
702 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
703
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
704 if (msgout_list_deliver) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
705 if (deliver_route_msgout_list(route, msgout_list_deliver)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
706 ok = TRUE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
707 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
708 destroy_msg_out_list(msgout_list_deliver);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
709 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
710 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
711 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
712
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
713 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
714 ** copy pointers of delivered addresses to the msg's non_rcpt_list,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
715 ** to make sure that they will not be delivered again.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
716 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
717 void
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
718 update_non_rcpt_list(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
719 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
720 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
721 message *msg = msgout->msg;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
722
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
723 foreach(msgout->rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
724 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
725 if (addr_is_delivered(rcpt) || addr_is_failed(rcpt)) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
726 msg->non_rcpt_list = g_list_append(msg->non_rcpt_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
727 rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
728 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
729 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
730 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
731
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
732 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
733 ** after delivery attempts, we check if there are any rcpt addresses left in
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
734 ** the message. If all addresses have been completed, the spool files will be
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
735 ** deleted, otherwise the header spool will be written back. We never changed
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
736 ** the data spool, so there is no need to write that back.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
737 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
738 ** returns TRUE if all went well.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
739 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
740 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
741 deliver_finish(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
742 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
743 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
744 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
745 gboolean finished = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
746
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
747 update_non_rcpt_list(msgout);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
748
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
749 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
750 ** we NEVER made copies of the addresses, flags affecting addresses
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
751 ** were always set on the original address structs
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
752 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
753 foreach(msg->rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
754 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
755 if (!addr_is_finished_children(rcpt)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
756 finished = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
757 } else {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
758 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
759 ** if ALL children have been delivered, mark parent as
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
760 ** delivered. if there is one or more not delivered,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
761 ** it must have failed, we mark the parent as failed
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
762 ** as well.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
763 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
764 if (addr_is_delivered_children(rcpt)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
765 addr_mark_delivered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
766 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
767 addr_mark_failed(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
768 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
769 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
770 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
771
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
772 if (finished) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
773 if (spool_delete_all(msg)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
774 logwrite(LOG_NOTICE, "%s completed.\n", msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
775 return TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
776 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
777 return FALSE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
778 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
779
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
780 /* one not delivered address was found */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
781 if (!spool_write(msg, FALSE)) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
782 logwrite(LOG_ALERT, "could not write back spool header "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
783 "for %s\n", msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
784 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
785 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
786
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
787 DEBUG(2) debugf("spool header for %s written back.\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
788 return TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
789 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
790
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
791 int
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
792 deliver_remote(GList *remote_msgout_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
793 {
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
794 int ok = TRUE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
795 GList *route_list = NULL;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
796 GList *route_node;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
797 GList *rf_list = NULL;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
798 gchar *connect_name = NULL;
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
799
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
800 if (!remote_msgout_list) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
801 return FALSE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
802 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
803
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
804 /* perma routes */
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
805 if (conf.perma_routes) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
806 DEBUG(5) debugf("processing perma_routes\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
807
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
808 route_list = read_route_list(conf.perma_routes, TRUE);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
809 foreach(route_list, route_node) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
810 connect_route *route =
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
811 (connect_route *) (route_node->data);
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
812 if (!deliver_route_msg_list(route,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
813 remote_msgout_list)) {
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
814 ok = FALSE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
815 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
816 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
817 destroy_route_list(route_list);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
818 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
819
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
820 /* query routes */
310
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 280
diff changeset
821 connect_name = online_query();
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
822 if (!connect_name) {
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
823 DEBUG(5) debugf("online query returned false\n");
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
824 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
825 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
826
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
827 /* we are online! */
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
828 DEBUG(5) debugf("processing query_routes\n");
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
829 logwrite(LOG_NOTICE, "detected online configuration `%s'\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
830 connect_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
831
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
832 rf_list = (GList *) table_find(conf.query_routes, connect_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
833 if (!rf_list) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
834 logwrite(LOG_ALERT, "route list with name '%s' not found.\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
835 connect_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
836 return FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
837 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
838
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
839 route_list = read_route_list(rf_list, FALSE);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
840 if (!route_list) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
841 logwrite(LOG_ALERT, "could not read route list '%s'\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
842 connect_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
843 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
844 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
845
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
846 foreach(route_list, route_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
847 connect_route *route = (connect_route *) (route_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
848 /* TODO: ok gets overwritten */
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
849 ok = deliver_route_msg_list(route, remote_msgout_list);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
850 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
851 destroy_route_list(route_list);
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
852
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
853 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
854 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
855
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
856 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
857 ** This function splits the list of rcpt addresses
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
858 ** into local and remote addresses and processes them accordingly.
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
859 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
860 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
861 deliver_msg_list(GList *msg_list, guint flags)
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
862 {
343
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
863 GList *msgout_list = NULL;
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
864 GList *msg_node;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
865 GList *local_msgout_list = NULL;
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
866 GList *remote_msgout_list = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
867 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
868 GList *alias_table = NULL;
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
869 GList *globalias_table = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
870 gboolean ok = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
871
343
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
872 /* create msgout_list */
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
873 foreach(msg_list, msg_node) {
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
874 message *msg = (message *) msg_node->data;
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
875 msgout_list = g_list_append(msgout_list, create_msg_out(msg));
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
876 }
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
877
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
878 if (conf.globalias_file) {
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
879 globalias_table = table_read(conf.globalias_file, ':');
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
880 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
881 if (conf.alias_file) {
17
6c59dedd06be fixed delivery with empty or non-existent alias file
meillo@marmaro.de
parents: 15
diff changeset
882 alias_table = table_read(conf.alias_file, ':');
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
883 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
884
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
885 /* sort messages for different deliveries */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
886 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
887 msg_out *msgout = (msg_out *) (msgout_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
888 GList *rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
889 GList *local_rcpt_list = NULL;
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
890 GList *other_rcpt_list = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
891
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
892 if (!spool_lock(msgout->msg->uid)) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
893 DEBUG(5) debugf("spool_lock(%s) failed.\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
894 msgout->msg->uid);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
895 continue;
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
896 }
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
897 DEBUG(5) debugf("spool_lock(%s)\n", msgout->msg->uid);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
898
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
899 rcpt_list = g_list_copy(msgout->msg->rcpt_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
900 if (conf.log_user) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
901 address *addr = create_address_qualified(conf.log_user,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
902 TRUE, conf.host_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
903 if (addr) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
904 rcpt_list = g_list_prepend(rcpt_list, addr);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
905 } else {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
906 logwrite(LOG_ALERT, "invalid log_user "
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
907 "address `%s', ignoring\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
908 conf.log_user);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
909 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
910 }
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
911 if (globalias_table) {
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
912 GList *globaliased_rcpt_list;
417
8fedb93e9b72 Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents: 404
diff changeset
913
8fedb93e9b72 Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents: 404
diff changeset
914 DEBUG(5) debugf("Doing globalias expansion\n");
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
915 globaliased_rcpt_list = alias_expand(globalias_table,
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
916 rcpt_list,
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
917 msgout->msg->non_rcpt_list, 1);
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
918 g_list_free(rcpt_list);
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
919 rcpt_list = globaliased_rcpt_list;
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
920 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
921 if (alias_table) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
922 GList *aliased_rcpt_list;
417
8fedb93e9b72 Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents: 404
diff changeset
923
8fedb93e9b72 Added comments and debug messages.
markus schnalke <meillo@marmaro.de>
parents: 404
diff changeset
924 DEBUG(5) debugf("Doing alias expansion\n");
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
925 aliased_rcpt_list = alias_expand(alias_table,
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
926 rcpt_list,
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
927 msgout->msg->non_rcpt_list, 0);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
928 g_list_free(rcpt_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
929 rcpt_list = aliased_rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
930 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
931
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
932 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, NULL,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
933 ** &other_rcpt_list); */
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
934 local_rcpt_list = local_rcpts(rcpt_list);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
935 other_rcpt_list = remote_rcpts(rcpt_list);
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
936 g_list_free(rcpt_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
937
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
938 /* local recipients */
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
939 if ((flags & DLVR_LOCAL) && local_rcpt_list) {
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
940 msg_out *local_msgout = clone_msg_out(msgout);
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
941 local_msgout->rcpt_list = local_rcpt_list;
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
942 local_msgout_list = g_list_append(local_msgout_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
943 local_msgout);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
944 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
945
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
946 /* remote recipients, requires online delivery */
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
947 if ((flags & DLVR_ONLINE) && other_rcpt_list) {
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
948 msg_out *remote_msgout = clone_msg_out(msgout);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
949 remote_msgout->rcpt_list = other_rcpt_list;
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
950 remote_msgout_list = g_list_append(remote_msgout_list,
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
951 remote_msgout);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
952 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
953 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
954
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
955 if (alias_table) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
956 destroy_table(alias_table);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
957 }
387
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
958 if (globalias_table) {
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
959 destroy_table(globalias_table);
a408411ff8df Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents: 375
diff changeset
960 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
961
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
962 /* process local/remote msgout lists -> delivery */
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
963
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
964 if (local_msgout_list) {
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
965 DEBUG(5) debugf("local_msgout_list\n");
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
966 foreach(local_msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
967 msg_out *msgout = (msg_out *) (msgout_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
968 if (!deliver_local(msgout)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
969 ok = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
970 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
971 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
972 destroy_msg_out_list(local_msgout_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
973 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
974
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
975 if (remote_msgout_list) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
976 DEBUG(5) debugf("remote_msgout_list\n");
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
977 deliver_remote(remote_msgout_list);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
978 destroy_msg_out_list(remote_msgout_list);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
979 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
980
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
981 /* unlock spool files */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
982 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
983 msg_out *msgout = (msg_out *) (msgout_node->data);
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
984 if (spool_unlock(msgout->msg->uid)) {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
985 DEBUG(5) debugf("spool_unlock(%s)\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
986 msgout->msg->uid);
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
987 } else {
404
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
988 DEBUG(5) debugf("spool_unlock(%s) failed.\n",
899c97e877a5 Broke long lines.
markus schnalke <meillo@marmaro.de>
parents: 403
diff changeset
989 msgout->msg->uid);
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
990 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
991 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
992 destroy_msg_out_list(msgout_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
993
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
994 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
995 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
996
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
997 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
998 ** deliver() is called when a message has just been received
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
999 ** (mode_accept and smtp_in) and should be delivered immediately
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
1000 ** (neither -odq nor do_queue). Only this one message will be tried to
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
1001 ** deliver then.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1002 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1003 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
1004 deliver(message *msg)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1005 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1006 gboolean ok;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1007 GList *msg_list = g_list_append(NULL, msg);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1008
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1009 ok = deliver_msg_list(msg_list, DLVR_ALL);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1010 g_list_free(msg_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1011
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
1012 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1013 }