annotate src/deliver.c @ 367:b27f66555ba8

Reformated multiline comments to have leading asterisks on each line Now we use: /* ** comment */ This makes the indent style simpler, too.
author markus schnalke <meillo@marmaro.de>
date Thu, 20 Oct 2011 10:20:59 +0200
parents 41958685480d
children d86d7b4b8995
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)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
47 if ((now - msg->received_time) >= conf.max_defer_time) {
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 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
50 defered_list = g_list_prepend(defered_list, rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
51 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
52 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
53 if (addr_is_failed(rcpt)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
54 failed_list = g_list_prepend(failed_list, rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
55 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
56 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
57 if (failed_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
58 ok_fail = fail_msg(msg, conf.errmsg_file, failed_list, err_fmt, args);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
59 g_list_free(failed_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
60 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
61 if (defered_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
62 ok_warn = warn_msg(msg, conf.warnmsg_file, defered_list, err_fmt, args);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
63 g_list_free(defered_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
64 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
65 va_end(args);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 return ok_fail && ok_warn;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
67 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
68
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
69 static gint
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
70 _g_list_strcasecmp(gconstpointer a, gconstpointer b)
0
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 return (gint) strcasecmp(a, b);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
73 }
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 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
76 deliver_local_mbox(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
77 {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
78 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
79 if (append_file(msg, hdr_list, rcpt->local_part)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
80 if (env_addr != rcpt) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
81 logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain, env_addr->local_part, env_addr->domain);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
82 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
83 logwrite(LOG_NOTICE, "%s => <%s@%s> with mbox\n", msg->uid, rcpt->local_part, rcpt->domain);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
84 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
85 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
86 return TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
87 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
88
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
89 /* prevents 'Resource temporarily unavailable (11)' */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
90 if (errno != EAGAIN) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
91 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
92 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
93 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
94 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
95 return FALSE;
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 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
99 deliver_local_pipe(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
100 {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
101 guint flags;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
102
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
103 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
104
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
105 flags = (conf.pipe_fromline) ? MSGSTR_FROMLINE : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
106 flags |= (conf.pipe_fromhack) ? MSGSTR_FROMHACK : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
107 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
108 logwrite(LOG_NOTICE, "%s => %s <%s@%s> with pipe\n",
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
109 msg->uid, rcpt->local_part, env_addr->local_part, env_addr->domain);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
110 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
111 return TRUE;
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
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
114 if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
115 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
116 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
117 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
118 /* 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
119 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
120 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
121 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
122
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
123 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
124 deliver_local_mda(message *msg, GList *hdr_list, address *rcpt, address *env_addr)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
125 {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
126 gboolean ok = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
127 gchar *cmd = g_malloc(256);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
128 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
129 guint flags;
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 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
132
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
133 if (!expand(var_table, conf.mda, cmd, 256)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
134 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
135 destroy_table(var_table);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
136 return FALSE;
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
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
139 flags = (conf.mda_fromline) ? MSGSTR_FROMLINE : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
140 flags |= (conf.mda_fromhack) ? MSGSTR_FROMHACK : 0;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
141 if (pipe_out(msg, hdr_list, rcpt, cmd, flags)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
142 logwrite(LOG_NOTICE, "%s => %s@%s with mda (cmd = '%s')\n",
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
143 msg->uid, rcpt->local_part, rcpt->domain, cmd);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
144 addr_mark_delivered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
145 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
146 } else if ((errno != (1024 + EX_TEMPFAIL)) && (errno != EAGAIN)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
147 addr_mark_failed(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
148 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
149 addr_mark_defered(rcpt);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
150 /* 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
151 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
152
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
153 destroy_table(var_table);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
154 return ok;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
155 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
156
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
157 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
158 deliver_local(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
159 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
160 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
161 GList *rcpt_list = msgout->rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
162 GList *rcpt_node;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
163 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
164
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
165 DEBUG(5) debugf("deliver_local entered\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
166
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
167 flag = (msg->data_list == NULL);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
168 if (flag && !spool_read_data(msg)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
169 logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
170 return FALSE;
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
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
173 for (rcpt_node = g_list_first(rcpt_list); rcpt_node; rcpt_node = g_list_next(rcpt_node)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
174 GList *hdr_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
175 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
176 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
177 address *ret_path = msg->return_path;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
178 header *retpath_hdr, *envto_hdr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
179
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
180 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
181 ** 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
182 ** 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
183 ** 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
184 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
185 hdr_list = g_list_copy(msg->hdr_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
186 retpath_hdr = create_header(HEAD_ENVELOPE_TO, "Envelope-to: %s\n", addr_string(env_addr));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
187 envto_hdr = create_header(HEAD_RETURN_PATH, "Return-path: %s\n", addr_string(ret_path));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
188
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
189 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
190 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
191
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
192 if (rcpt->local_part[0] == '|') {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
193 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
194 ** 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
195 ** 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
196 */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
197 if (deliver_local_pipe(msg, hdr_list, rcpt, env_addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
198 ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
199 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
200 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
201 /* figure out which mailbox type should be used for this user */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
202 gchar *user = rcpt->local_part;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
203 gchar *mbox_type = conf.mbox_default;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
204
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
205 if (g_list_find_custom (conf.mbox_users, user, _g_list_strcasecmp)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
206 mbox_type = "mbox";
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
207 } else if (g_list_find_custom (conf.mda_users, user, _g_list_strcasecmp)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
208 mbox_type = "mda";
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
209 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
210
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
211 if (strcmp(mbox_type, "mbox") == 0) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
212 if (deliver_local_mbox(msg, hdr_list, rcpt, env_addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
213 ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
214 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
215 } 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
216 if (conf.mda) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
217 if (deliver_local_mda(msg, hdr_list, rcpt, env_addr)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
218 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
219 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
220 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
221 logwrite(LOG_ALERT, "mbox type is mda, but no mda command given in configuration\n");
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
222 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
223
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
224 } else {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
225 logwrite(LOG_ALERT, "unknown mbox type '%s'\n", mbox_type);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
226 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
227 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
228
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
229 destroy_header(retpath_hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
230 destroy_header(envto_hdr);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
231
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
232 g_list_free(hdr_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
233 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
234 ok_fail = delivery_failures(msg, rcpt_list, "%s (%d)", ext_strerror(errno), errno);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
235
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
236 if (flag) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
237 msg_free_data(msg);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
238 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
239 if (ok || ok_fail) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
240 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
241 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
242
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
243 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
244 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
245
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
246 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
247 ** 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
248 ** 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
249 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
250 void
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
251 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
252 GList **p_nonlocal_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
253 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
254 GList *rcpt_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
255
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
256 foreach(rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
257 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
258 GList *dom_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
259
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
260 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
261
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
262 /* search for local host list: */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
263 foreach(conf.local_hosts, dom_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
264 if (strcasecmp(dom_node->data, rcpt->domain) == 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
265 *p_local_list = g_list_append(*p_local_list, rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
266 DEBUG(5) debugf("<%s@%s> is local\n", rcpt->local_part, rcpt->domain);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
267 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
268 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
269 *p_nonlocal_list = g_list_append(*p_nonlocal_list, rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
270 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
271 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
272 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
273 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
274
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
275 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
276 deliver_msglist_host_pipe(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
277 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
278 gboolean ok = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
279 GList *msgout_node;
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 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
282
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
283 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
284 msg_out *msgout = (msg_out *) (msgout_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
285 gboolean flag, ok_fail = FALSE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
286 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
287 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
288
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
289 DEBUG(1) debugf("attempting to deliver %s with pipe\n", msg->uid);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
290
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
291 flag = (msg->data_list == NULL);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
292 if (flag && !spool_read_data(msg)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
293 logwrite(LOG_ALERT, "could not open data spool file for %s\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
294 continue;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
295 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
296
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
297 ok = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
298 foreach(rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
299 address *rcpt = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
300 gchar *cmd = g_malloc(256);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
301 GList *var_table = var_table_rcpt(var_table_msg(NULL, msg), rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
302
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
303 DEBUG(1) debugf("attempting to deliver %s to %s@%s with pipe\n",
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
304 msg->uid, rcpt->local_part, rcpt->domain);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
305
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
306 if (!expand(var_table, route->pipe, cmd, 256)) {
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
307 logwrite(LOG_ALERT, "could not expand string `%s'\n", route->pipe);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
308 destroy_table(var_table);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
309 continue;
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
310 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
311
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
312 if (pipe_out(msg, msg->hdr_list, rcpt, cmd, (route->pipe_fromline ? MSGSTR_FROMLINE : 0)
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
313 | (route->pipe_fromhack ? MSGSTR_FROMHACK : 0))) {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
314 logwrite(LOG_NOTICE, "%s => %s@%s with pipe (cmd = '%s')\n",
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
315 msg->uid, rcpt->local_part, rcpt->domain, cmd);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
316 addr_mark_delivered(rcpt);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
317 ok = TRUE;
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
318 } else {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
319 logwrite(LOG_ALERT, "pipe_out '%s' failed\n", route->pipe);
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
320
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
321 if (route->connect_error_fail) {
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
322 addr_mark_failed(rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
323 } else {
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
324 addr_mark_defered(rcpt);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
325 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
326 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
327
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
328 destroy_table(var_table);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
329 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
330 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
331
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
332 if (flag) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
333 msg_free_data(msg);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
334 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
335 if (ok || ok_fail) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
336 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
337 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
338 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
339
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
340 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
341 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
342
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
343 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
344 ** 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
345 ** 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
346 ** 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
347 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
348 gboolean
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
349 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
350 gchar *host, GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
351 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
352 gboolean ok = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
353 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
354 smtp_base *psb;
178
91f8ee6514f5 removed `remote_port' config option
meillo@marmaro.de
parents: 114
diff changeset
355 gint port = 25;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
356
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
357 /* paranoid check: */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
358 if (!msgout_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
359 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
360 return FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
361 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
362
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
363 if (!host) {
179
3190e6864452 added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents: 178
diff changeset
364 /* 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
365 host = route->mail_host->address;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
366 port = route->mail_host->port;
178
91f8ee6514f5 removed `remote_port' config option
meillo@marmaro.de
parents: 114
diff changeset
367 }
10
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 (route->wrapper) {
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
370 psb = smtp_out_open_child(route->wrapper, host);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
371 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
372 psb = smtp_out_open(host, port, res_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
373 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
374
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
375 if (!psb) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
376 /* smtp_out_open() failed */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
377 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
378 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
379 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
380
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
381 for (rcpt_node = g_list_first(msgout->rcpt_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
382 rcpt_node;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
383 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
384 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
385 gboolean ret = FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
386
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
387 addr_unmark_delivered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
388 if (route->connect_error_fail) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
389 addr_mark_failed(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
390 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
391 addr_mark_defered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
392 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
393 if (route->wrapper) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
394 ret = delivery_failures(msgout->msg, msgout->rcpt_list, "could not open wrapper:\n\t%s", strerror(errno));
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
395 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
396 ret = delivery_failures(msgout->msg, msgout->rcpt_list, "could not open connection to %s:%d :\n\t%s", host, port, h_errno != 0 ? hstrerror(h_errno) : strerror(errno));
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
397 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
398 if (ret) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
399 deliver_finish(msgout);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
400 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
401 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
402 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
403 return ok;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
404 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
405
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
406 set_heloname(psb, route->helo_name ? route->helo_name : conf.host_name, route->do_correct_helo);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
407
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
408 #ifdef ENABLE_AUTH
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
409 if (route->auth_name && route->auth_login && route->auth_secret) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
410 set_auth(psb, route->auth_name, route->auth_login, route->auth_secret);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
411 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
412 #endif
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
413 if (!smtp_out_init(psb, route->instant_helo)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
414 /* smtp_out_init() failed */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
415 if ((psb->error==smtp_fail) || (psb->error==smtp_trylater) || (psb->error==smtp_syntax)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
416 smtp_out_quit(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
417
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
418 foreach(msgout_list, msgout_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
419 msg_out *msgout = (msg_out *) (msgout_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
420 smtp_out_mark_rcpts(psb, msgout->rcpt_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
421
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
422 if (delivery_failures(msgout->msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
423 deliver_finish(msgout);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
424 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
425 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
426 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
427 destroy_smtpbase(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
428 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
429 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
430
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
431 if (!route->do_pipelining) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
432 psb->use_pipelining = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
433 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
434
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
435 foreach(msgout_list, msgout_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
436 msg_out *msgout = (msg_out *) (msgout_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
437 gboolean flag, ok_msg = FALSE, ok_fail = FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
438 message *msg = msgout->msg;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
439
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
440 /* we may have to read the data at this point and remember if we did */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
441 flag = (msg->data_list == NULL);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
442 if (flag && !spool_read_data(msg)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
443 logwrite(LOG_ALERT, "could not open data spool file %s\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
444 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
445 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
446
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
447 smtp_out_msg(psb, msg, msgout->return_path, msgout->rcpt_list, msgout->hdr_list);
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 ok_fail = delivery_failures(msg, msgout->rcpt_list, "while connected with %s, the server replied\n\t%s", host, psb->buffer);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
450
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
451 if ((psb->error == smtp_eof) || (psb->error == smtp_timeout)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
452 /* connection lost */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
453 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
454 } else if (psb->error != smtp_ok) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
455 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
456 break;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
457 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
458 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
459 ok_msg = (psb->error == smtp_ok);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
460
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
461 if (flag) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
462 msg_free_data(msg);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
463 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
464 if (ok_msg) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
465 ok = TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
466 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
467 if (ok_msg || ok_fail) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
468 deliver_finish(msgout);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
469 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
470 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
471 if (psb->error == smtp_ok || (psb->error == smtp_fail)
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
472 || (psb->error == smtp_trylater) || (psb->error == smtp_syntax)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
473 smtp_out_quit(psb);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
474 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
475 destroy_smtpbase(psb);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
476 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
477 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
478
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
479 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
480 deliver_msglist_host(connect_route *route, GList *msgout_list, gchar *host, GList *res_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
481 {
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
482
311
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
483 if (route->pipe) {
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
484 DEBUG(5) debugf("with pipe\n");
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
485 return deliver_msglist_host_pipe(route, msgout_list, host, res_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
486 } else {
311
e230bcd0f1c6 removed protocol option from route config
meillo@marmaro.de
parents: 310
diff changeset
487 DEBUG(5) debugf("with smtp\n");
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
488 return deliver_msglist_host_smtp(route, msgout_list, host, res_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
489 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
490 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
491
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
492 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
493 ** delivers messages in msgout_list using route
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
494 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
495 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
496 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
497 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
498 gboolean ok = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
499 GList *mo_ph_list;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
500 GList *mo_ph_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
501
15
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 12
diff changeset
502 DEBUG(5) debugf("deliver_route_msgout_list entered, route->name = %s\n", route->name);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
503
179
3190e6864452 added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents: 178
diff changeset
504 if (route->mail_host) {
3190e6864452 added comments to deliver.c (stuff to check)
meillo@marmaro.de
parents: 178
diff changeset
505 /* this is easy... deliver everything to a smart host for relay */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
506 return deliver_msglist_host(route, msgout_list, NULL, route->resolve_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
507 }
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 /* this is not easy... */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
510
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
511 mo_ph_list = route_msgout_list(route, msgout_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
512 /* 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
513 if (!mo_ph_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
514 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
515 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
516
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
517 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
518 ** 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
519 ** 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
520 ** 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
521 ** 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
522 */
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
523 foreach(mo_ph_list, mo_ph_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
524 msgout_perhost *mo_ph = (msgout_perhost *) (mo_ph_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
525 if (deliver_msglist_host(route, mo_ph->msgout_list, mo_ph->host, route->resolve_list)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
526 ok = TRUE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
527 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
528 destroy_msgout_perhost(mo_ph);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
529 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
530 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
531 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
532 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
533
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
534 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
535 ** calls route_prepare_msg()
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
536 ** 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
537 ** deliver_route_msgout_list()
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
538 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
539 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
540 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
541 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
542 GList *msgout_list_deliver = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
543 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
544 gboolean ok = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
545
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
546 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
547
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
548 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
549 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
550 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
551 GList *rcpt_list_non_delivered = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
552 GList *rcpt_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
553
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
554 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
555 ** 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
556 ** 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
557 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
558 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
559 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
560 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
561 ** 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
562 ** 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
563 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
564 if (!addr_is_delivered(rcpt) && !addr_is_failed(rcpt)
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
565 && !(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
566 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
567 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
568 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
569 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
570 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
571
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
572 if (!msgout_cloned->rcpt_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
573 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
574 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
575 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
576
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
577 /* filter by allowed envelope sender */
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
578 if (!route_sender_is_allowed(route, msgout->msg->return_path)) {
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
579 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
580 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
581 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
582
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
583 /* filter by allowed envelope rcpts */
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
584 GList *rcpt_list_allowed = NULL;
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
585 GList *rcpt_list_notallowed = NULL;
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
586 route_split_rcpts(route, msgout_cloned->rcpt_list, &rcpt_list_allowed, &rcpt_list_notallowed);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
587 if (!rcpt_list_allowed) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
588 destroy_msg_out(msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
589 continue;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
590 }
317
55b7bde95d37 reworked allowed and denied addrs for routes
meillo@marmaro.de
parents: 315
diff changeset
591
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
592 logwrite(LOG_NOTICE, "%s using '%s'\n", msgout->msg->uid, route->name);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
593
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
594 g_list_free(msgout_cloned->rcpt_list);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
595 msgout_cloned->rcpt_list = rcpt_list_allowed;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
596
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
597 if (route->last_route) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
598 GList *rcpt_node;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
599 foreach(msgout_cloned->rcpt_list, rcpt_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
600 address *rcpt = (address *) (rcpt_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
601 rcpt->flags |= ADDR_FLAG_LAST_ROUTE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
602 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
603 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
604
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
605 route_prepare_msgout(route, msgout_cloned);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
606 msgout_list_deliver = g_list_append(msgout_list_deliver, msgout_cloned);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
607 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
608
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
609 if (msgout_list_deliver) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
610 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
611 ok = TRUE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
612 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
613 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
614 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
615 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
616 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
617
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
618 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
619 ** 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
620 ** 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
621 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
622 void
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
623 update_non_rcpt_list(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
624 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
625 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
626 message *msg = msgout->msg;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
627
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
628 foreach(msgout->rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
629 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
630 if (addr_is_delivered(rcpt) || addr_is_failed(rcpt)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
631 msg->non_rcpt_list = g_list_append(msg->non_rcpt_list, rcpt);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
632 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
633 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
634 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
635
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
636 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
637 ** 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
638 ** 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
639 ** 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
640 ** 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
641 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
642 ** returns TRUE if all went well.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
643 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
644 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
645 deliver_finish(msg_out *msgout)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
646 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
647 GList *rcpt_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
648 message *msg = msgout->msg;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
649 gboolean finished = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
650
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
651 update_non_rcpt_list(msgout);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
652
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
653 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
654 ** 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
655 ** 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
656 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
657 foreach(msg->rcpt_list, rcpt_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
658 address *rcpt = (address *) (rcpt_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
659 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
660 finished = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
661 } else {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
662 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
663 ** 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
664 ** 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
665 ** 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
666 ** as well.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
667 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
668 if (addr_is_delivered_children(rcpt)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
669 addr_mark_delivered(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
670 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
671 addr_mark_failed(rcpt);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
672 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
673 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
674 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
675
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
676 if (finished) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
677 if (spool_delete_all(msg)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
678 logwrite(LOG_NOTICE, "%s completed.\n", msg->uid);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
679 return TRUE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
680 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
681 return FALSE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
682 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
683
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
684 /* one not delivered address was found */
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
685 if (!spool_write(msg, FALSE)) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
686 logwrite(LOG_ALERT, "could not write back spool header for %s\n", msg->uid);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
687 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
688 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
689
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
690 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
691 return TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
692 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
693
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
694 int
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
695 deliver_remote(GList *remote_msgout_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
696 {
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
697 int ok = TRUE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
698 GList *route_list = NULL;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
699 GList *route_node;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
700 GList *rf_list = NULL;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
701 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
702
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
703 if (!remote_msgout_list) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
704 return FALSE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
705 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
706
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
707 /* perma routes */
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
708 if (conf.perma_routes) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
709 DEBUG(5) debugf("processing perma_routes\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
710
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
711 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
712 foreach(route_list, route_node) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
713 connect_route *route = (connect_route *) (route_node->data);
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
714 if (!deliver_route_msg_list(route, remote_msgout_list)) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
715 ok = FALSE;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
716 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
717 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
718 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
719 }
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
720
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
721 /* query routes */
310
f10a56dc7481 reworked online_detect to the simpler online_query
meillo@marmaro.de
parents: 280
diff changeset
722 connect_name = online_query();
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
723 if (!connect_name) {
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
724 DEBUG(5) debugf("online query returned false\n");
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
725 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
726 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
727
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
728 /* we are online! */
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
729 DEBUG(5) debugf("processing query_routes\n");
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
730 logwrite(LOG_NOTICE, "detected online configuration `%s'\n", connect_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
731
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
732 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
733 if (!rf_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
734 logwrite(LOG_ALERT, "route list with name '%s' not found.\n", connect_name);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
735 return FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
736 }
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
737
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
738 route_list = read_route_list(rf_list, FALSE);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
739 if (!route_list) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
740 logwrite(LOG_ALERT, "could not read route list '%s'\n", connect_name);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
741 return FALSE;
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
742 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
743
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
744 foreach(route_list, route_node) {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
745 connect_route *route = (connect_route *) (route_node->data);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
746 /* 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
747 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
748 }
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
749 destroy_route_list(route_list);
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
750
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
751 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
752 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
753
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
754 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
755 ** 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
756 ** into local and remote addresses and processes them accordingly.
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
757 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
758 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
759 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
760 {
343
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
761 GList *msgout_list = NULL;
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
762 GList *msg_node;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
763 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
764 GList *remote_msgout_list = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
765 GList *msgout_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
766 GList *alias_table = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
767 gboolean ok = TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
768
343
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
769 /* create msgout_list */
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
770 foreach(msg_list, msg_node) {
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
771 message *msg = (message *) msg_node->data;
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
772 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
773 }
9149d893eb52 refactoring: ``insourced'' create_msg_out_list()
markus schnalke <meillo@marmaro.de>
parents: 321
diff changeset
774
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
775 if (conf.alias_file) {
17
6c59dedd06be fixed delivery with empty or non-existent alias file
meillo@marmaro.de
parents: 15
diff changeset
776 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
777 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
778
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
779 /* sort messages for different deliveries */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
780 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
781 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
782 GList *rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
783 GList *local_rcpt_list = NULL;
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
784 GList *other_rcpt_list = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
785
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
786 if (!spool_lock(msgout->msg->uid)) {
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
787 DEBUG(5) debugf("spool_lock(%s) failed.\n", msgout->msg->uid);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
788 continue;
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
789 }
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
790 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
791
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
792 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
793 if (conf.log_user) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
794 address *addr = create_address_qualified(conf.log_user, TRUE, conf.host_name);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
795 if (addr) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
796 rcpt_list = g_list_prepend(rcpt_list, addr);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
797 } else {
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
798 logwrite(LOG_ALERT, "invalid log_user address `%s', ignoring\n", conf.log_user);
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
799 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
800 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
801 if (alias_table) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
802 GList *aliased_rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
803 aliased_rcpt_list = alias_expand(alias_table, rcpt_list, msgout->msg->non_rcpt_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
804 g_list_free(rcpt_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
805 rcpt_list = aliased_rcpt_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
806 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
807
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
808 /* split_rcpts(rcpt_list, NULL, &local_rcpt_list, NULL, &other_rcpt_list); */
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
809 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
810 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
811 g_list_free(rcpt_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
812
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
813 /* local recipients */
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
814 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
815 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
816 local_msgout->rcpt_list = local_rcpt_list;
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
817 local_msgout_list = g_list_append(local_msgout_list, local_msgout);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
818 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
819
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
820 /* remote recipients, requires online delivery */
237
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
821 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
822 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
823 remote_msgout->rcpt_list = other_rcpt_list;
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
824 remote_msgout_list = g_list_append(remote_msgout_list, remote_msgout);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
825 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
826 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
827
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
828 if (alias_table) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
829 destroy_table(alias_table);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
830 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
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 /* 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
833
5f9f3a65032e refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents: 224
diff changeset
834 if (local_msgout_list) {
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
835 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
836 foreach(local_msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
837 msg_out *msgout = (msg_out *) (msgout_node->data);
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
838 if (!deliver_local(msgout)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
839 ok = FALSE;
280
72e377210d5e heavy refactoring of deliver.c
markus schnalke <meillo@marmaro.de>
parents: 237
diff changeset
840 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
841 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
842 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
843 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
844
354
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
845 if (remote_msgout_list) {
08932c629849 reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents: 350
diff changeset
846 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
847 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
848 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
849 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
850
344
0410c8aabac2 improved comments and debug messages
markus schnalke <meillo@marmaro.de>
parents: 343
diff changeset
851 /* unlock spool files */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
852 foreach(msgout_list, msgout_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
853 msg_out *msgout = (msg_out *) (msgout_node->data);
114
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
854 if (spool_unlock(msgout->msg->uid)) {
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
855 DEBUG(5) debugf("spool_unlock(%s)\n", msgout->msg->uid);
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
856 } else {
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
857 DEBUG(5) debugf("spool_unlock(%s) failed.\n", msgout->msg->uid);
a80ebfa16cd5 better debugging output (thanks to Paolo)
meillo@marmaro.de
parents: 76
diff changeset
858 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
859 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
860 destroy_msg_out_list(msgout_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
861
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
862 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
863 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
864
321
412385b57dc4 refactoring
meillo@marmaro.de
parents: 317
diff changeset
865 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
866 ** 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
867 ** (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
868 ** (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
869 ** deliver then.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
870 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
871 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 354
diff changeset
872 deliver(message *msg)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
873 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
874 gboolean ok;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
875 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
876
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
877 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
878 g_list_free(msg_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
879
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
880 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
881 }