annotate src/accept.c @ 385:01769f722a18

Refactoring in tables.c.
author markus schnalke <meillo@marmaro.de>
date Thu, 16 Feb 2012 13:34:44 +0100
parents 5781ba87df95
children aa40710f09fe
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-2001 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) 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 "masqmail.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
22 #include "readsock.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
23
299
ca2d11aec2a3 fixed compile error; removed PROT_BSMTP; made protocol names ucase
markus schnalke <meillo@marmaro.de>
parents: 298
diff changeset
24 /* must match PROT_* in masqmail.h */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
25 gchar *prot_names[] = {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
26 "local",
299
ca2d11aec2a3 fixed compile error; removed PROT_BSMTP; made protocol names ucase
markus schnalke <meillo@marmaro.de>
parents: 298
diff changeset
27 "SMTP",
ca2d11aec2a3 fixed compile error; removed PROT_BSMTP; made protocol names ucase
markus schnalke <meillo@marmaro.de>
parents: 298
diff changeset
28 "ESMTP",
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
29 "(unknown)" /* should not happen, but better than crashing. */
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
30 };
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
31
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
32 static gchar*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 362
diff changeset
33 string_base62(gchar *res, guint value, gchar len)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
34 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
35 static gchar base62_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
36 gchar *p = res + len;
14
a8f3424347dc replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents: 13
diff changeset
37 *p = '\0';
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
38 while (p > res) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
39 *(--p) = base62_chars[value % 62];
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
40 value /= 62;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
41 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
42 return res;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
43 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
44
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
45 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
46 ** accept message from anywhere.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
47 ** A message from local is indicated by msg->recieved_host == NULL
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
48 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
49 ** The -t option: With the ACC_RCPT_FROM_HEAD flag the addrs found found
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
50 ** in To/Cc/Bcc headers are added to the recipient list.
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
51 */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
52
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
53 accept_error
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 362
diff changeset
54 accept_message_stream(FILE *in, message *msg, guint flags)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
55 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
56 gchar *line, *line1;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
57 int line_size = MAX_DATALINE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
58 gboolean in_headers = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
59 header *hdr = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
60 gint line_cnt = 0, data_size = 0;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
61
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
62 line = g_malloc(line_size);
14
a8f3424347dc replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents: 13
diff changeset
63 line[0] = '\0';
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
64
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
65 while (TRUE) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 int len = read_sockline1(in, &line, &line_size, 5 * 60, READSOCKL_CVT_CRLF);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
67
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
68 line1 = line;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
69
110
c678d0342451 changed name ACC_NODOT_TERM to ACC_DOT_IGNORE for better understanding
meillo@marmaro.de
parents: 109
diff changeset
70 if ((line[0] == '.') && (!(flags & ACC_DOT_IGNORE))) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
71 if (line[1] == '\n') {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
72 g_free(line);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
73 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
74 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
75 line1++;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
76 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
77
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
78 if ((len == -1) && (flags & (ACC_DOT_IGNORE | ACC_NODOT_RELAX))) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
79 /* we got an EOF, and the last line was not terminated by a CR */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
80 gint len1 = strlen(line1);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
81 if (len1 > 0) { /* == 0 is 'normal' (EOF after a CR) */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
82 if (line1[len1 - 1] != '\n') { /* some mail clients allow unterminated lines */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
83 line1[len1] = '\n';
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
84 line1[len1 + 1] = '\0';
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
85 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1));
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
86 data_size += strlen(line1);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
87 line_cnt++;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
88 }
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
89 }
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
90 break;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
91
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
92 } else if (len == -1) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
93 g_free(line);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
94 return AERR_EOF;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
95
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
96 } else if (len == -2) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
97 /* should not happen any more */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
98 g_free(line);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
99 return AERR_OVERFLOW;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
100
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
101 } else if (len == -3) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
102 g_free(line);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
103 return AERR_TIMEOUT;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
104
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
105 } else if (len <= 0) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
106 /* does not happen */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
107 g_free(line);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
108 DEBUG(5) debugf("read_sockline returned %d\n", len);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
109 return AERR_UNKNOWN;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
110
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
111 }
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
112
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
113 if (in_headers) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
114
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
115 /* some pop servers send the 'From ' line, skip it: */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
116 if (!msg->hdr_list && strncmp(line1, "From ", 5) == 0) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
117 continue;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
118 }
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
119
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
120 if (line1[0] == ' ' || line1[0] == '\t') {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
121 /* continuation of 'folded' header: */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
122 if (hdr) {
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 362
diff changeset
123 char *cp;
323
29de6a1c4538 Fixed an important bug with folded headers!
meillo@marmaro.de
parents: 304
diff changeset
124 cp = g_strconcat(hdr->header, line1, NULL);
29de6a1c4538 Fixed an important bug with folded headers!
meillo@marmaro.de
parents: 304
diff changeset
125 hdr->value = cp + (hdr->value - hdr->header);
29de6a1c4538 Fixed an important bug with folded headers!
meillo@marmaro.de
parents: 304
diff changeset
126 free(hdr->header);
29de6a1c4538 Fixed an important bug with folded headers!
meillo@marmaro.de
parents: 304
diff changeset
127 hdr->header = cp;
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
128 }
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
129
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
130 } else if (line1[0] == '\n') {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
131 /* an empty line marks end of headers */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
132 in_headers = FALSE;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
133 } else {
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
134 /* in all other cases we expect another header */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
135 if ((hdr = get_header(line1))) {
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
136 msg->hdr_list = g_list_append(msg->hdr_list, hdr);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
137 } else {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
138 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
139 ** if get_header() returns NULL,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
140 ** no header was recognized,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
141 ** so this seems to be the first
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
142 ** data line of a broken mailer
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
143 ** which does not send an empty
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
144 ** line after the headers
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
145 */
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
146 in_headers = FALSE;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
147 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
148 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
149 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
150 } else {
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
151 /* message body */
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
152 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1));
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
153 data_size += strlen(line1);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
154 line_cnt++;
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
155 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
156
120
cd59a5b4d3dd added support for SMTP SIZE 0 (unlimited)
meillo@marmaro.de
parents: 117
diff changeset
157 if (conf.max_msg_size && (data_size > conf.max_msg_size)) {
117
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
158 DEBUG(4) debugf("accept_message_stream(): "
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
159 "received %d bytes (conf.max_msg_size=%d)\n",
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
160 data_size, conf.max_msg_size);
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
161 return AERR_SIZE;
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
162 }
5ec5e6637049 added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents: 111
diff changeset
163
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
164 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
165
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
166 DEBUG(4) debugf("received %d lines of data (%d bytes)\n", line_cnt, data_size);
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
167
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
168 if (!msg->data_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
169 /* make sure data list is not NULL: */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
170 msg->data_list = g_list_append(NULL, g_strdup(""));
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
171 }
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
172 msg->data_list = g_list_reverse(msg->data_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
173
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
174 /* we get here after we succesfully received the mail data */
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
175
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
176 msg->data_size = data_size;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
177 msg->received_time = time(NULL);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
178
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
179 return AERR_OK;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
180 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
181
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
182 accept_error
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 362
diff changeset
183 accept_message_prepare(message *msg, guint flags)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
184 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
185 struct passwd *passwd = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
186 time_t rec_time = time(NULL);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
187
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
188 DEBUG(5) debugf("accept_message_prepare()\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
189
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
190 /* create unique message id */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
191 msg->uid = g_malloc(14);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
192 string_base62(msg->uid, rec_time, 6);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
193 msg->uid[6] = '-';
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
194 string_base62(msg->uid + 7, getpid(), 3);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
195 msg->uid[10] = '-';
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
196 string_base62(msg->uid + 11, msg->transfer_id, 2);
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
197 msg->uid[13] = '\0';
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
198
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
199 /* if local, get password entry and set return path if missing */
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
200 if (!msg->received_host) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
201 passwd = g_memdup(getpwuid(geteuid()), sizeof(struct passwd));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
202 msg->ident = g_strdup(passwd->pw_name);
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
203 if (!msg->return_path) {
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
204 gchar *path = g_strdup_printf("<%s@%s>", passwd->pw_name, conf.host_name);
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
205 DEBUG(3) debugf("setting return_path for local accept: %s\n", path);
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
206 msg->return_path = create_address(path, TRUE);
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
207 g_free(path);
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
208 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
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 /* scan headers */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
212 {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
213 gboolean has_id = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
214 gboolean has_date = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
215 gboolean has_sender = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
216 gboolean has_from = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
217 gboolean has_to_or_cc = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
218 GList *hdr_node, *hdr_node_next;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
219 header *hdr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
220
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
221 for (hdr_node = g_list_first(msg->hdr_list);
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
222 hdr_node;
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
223 hdr_node = hdr_node_next) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
224 hdr_node_next = g_list_next(hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
225 hdr = ((header *) (hdr_node->data));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
226 DEBUG(5) debugf("scanning headers: %s", hdr->header);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
227 switch (hdr->id) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
228 case HEAD_MESSAGE_ID:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
229 has_id = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
230 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
231 case HEAD_DATE:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
232 has_date = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
233 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
234 case HEAD_FROM:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
235 has_from = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
236 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
237 case HEAD_SENDER:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
238 has_sender = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
239 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
240 case HEAD_TO:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
241 case HEAD_CC:
106
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
242 has_to_or_cc = TRUE;
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
243 /* fall through */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
244 case HEAD_BCC:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
245 if (flags & ACC_RCPT_FROM_HEAD) {
109
db52c64acaa2 improved comments related to -t option
meillo@marmaro.de
parents: 106
diff changeset
246 /* -t option (see comment above) */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
247 DEBUG(5) debugf("hdr->value = %s\n", hdr->value);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
248 if (hdr->value) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
249 msg->rcpt_list = addr_list_append_rfc822(msg->rcpt_list, hdr->value, conf.host_name);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
250 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
251 }
106
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
252 if (hdr->id == HEAD_BCC) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
253 DEBUG(3) debugf("removing 'Bcc' header\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
254 msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
255 g_list_free_1(hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
256 destroy_header(hdr);
106
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
257 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
258 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
259 case HEAD_ENVELOPE_TO:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
260 if (flags & ACC_SAVE_ENVELOPE_TO) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
261 DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n");
22
7c1635972aa7 small cleanups
meillo@marmaro.de
parents: 14
diff changeset
262 msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN,
276
1abc1faeb45d for -t cmdline args are now added to the rcpt list instead of substracted
markus schnalke <meillo@marmaro.de>
parents: 275
diff changeset
263 "X-Orig-Envelope-To: %s", hdr->value));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
264 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
265 DEBUG(3) debugf("removing 'Envelope-To' header\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
266 msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
267 g_list_free_1(hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
268 destroy_header(hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
269 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
270 case HEAD_RETURN_PATH:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
271 if (flags & ACC_MAIL_FROM_HEAD) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
272 /* usually POP3 accept */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
273 msg->return_path = create_address_qualified(hdr->value, TRUE, msg->received_host);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
274 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
275 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
276 DEBUG(3) debugf("removing 'Return-Path' header\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
277 msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
278 g_list_free_1(hdr_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
279 destroy_header(hdr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
280 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
281 default:
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
282 break; /* make compiler happy */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
283 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
284 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
285
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
286 if (!msg->return_path) {
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
287 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
288 ** TODO: do we still need this as we don't fetch
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
289 ** mail anymore?
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
290 ** This can happen for pop3 accept only and if no
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
291 ** Return-Path: header was given
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
292 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
293 GList *hdr_list;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
294 header *hdr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
295
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
296 DEBUG(3) debugf("return_path == NULL\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
297
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
298 hdr_list = find_header(msg->hdr_list, HEAD_SENDER, NULL);
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
299 if (!hdr_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
300 hdr_list = find_header(msg->hdr_list, HEAD_FROM, NULL);
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
301 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
302 if (hdr_list) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
303 gchar *addr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
304 hdr = (header *) (g_list_first(hdr_list)->data);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
305
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
306 DEBUG(5) debugf("hdr->value = '%s'\n", hdr->value);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
307
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
308 addr = g_strdup(hdr->value);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
309 g_strchomp(addr);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
310
299
ca2d11aec2a3 fixed compile error; removed PROT_BSMTP; made protocol names ucase
markus schnalke <meillo@marmaro.de>
parents: 298
diff changeset
311 msg->return_path = create_address_qualified(addr, FALSE, msg->received_host);
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
312 if (msg->return_path) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
313 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path));
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
314 msg->hdr_list = g_list_append( msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: return path set from %s address\n", hdr->id == HEAD_SENDER ? "Sender:" : "From:"));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
315 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
316 g_free(addr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
317 }
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
318 if (!msg->return_path) {
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
319 /* no Sender: or From: or
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
320 create_address_qualified failed */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
321 msg->return_path = create_address_qualified("postmaster", TRUE, conf.host_name);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
322 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path));
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
323 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, "X-Warning: real return path is unknown\n"));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
324 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
325 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
326
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
327 /* here we should have our recipients, fail if not: */
276
1abc1faeb45d for -t cmdline args are now added to the rcpt list instead of substracted
markus schnalke <meillo@marmaro.de>
parents: 275
diff changeset
328 if (!msg->rcpt_list) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
329 logwrite(LOG_WARNING, "no recipients found in message\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
330 return AERR_NORCPT;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
331 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
332
299
ca2d11aec2a3 fixed compile error; removed PROT_BSMTP; made protocol names ucase
markus schnalke <meillo@marmaro.de>
parents: 298
diff changeset
333 if (!has_sender && !has_from) {
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
334 DEBUG(3) debugf("adding 'From:' header\n");
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
335 if (msg->full_sender_name) {
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
336 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_FROM, "From: \"%s\" <%s@%s>\n", msg->full_sender_name, msg->return_path->local_part, msg->return_path->domain));
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
337 } else {
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
338 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_FROM, "From: <%s@%s>\n", msg->return_path->local_part, msg->return_path->domain));
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
339 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
340 }
106
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
341 if (!has_to_or_cc) {
1f0d63713a1c masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents: 105
diff changeset
342 DEBUG(3) debugf("no To: or Cc: header, hence adding `To: undisclosed recipients:;'\n");
105
47ee3fbcecd2 add `undisclosed recipients' header if no recipient headers available
meillo@marmaro.de
parents: 102
diff changeset
343 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_TO, "To: undisclosed-recipients:;\n"));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
344 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
345 if (!has_date) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
346 DEBUG(3) debugf("adding 'Date:' header\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
347 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_DATE, "Date: %s\n", rec_timestamp()));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
348 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
349 if (!has_id) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
350 DEBUG(3) debugf("adding 'Message-ID:' header\n");
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
351 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_MESSAGE_ID, "Message-ID: <%s@%s>\n", msg->uid, conf.host_name));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
352 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
353 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
354
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
355 /* Received header: */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
356 /* At this point because we have to know the rcpts for the 'for' part */
298
6281ff92cb86 refactoring
markus schnalke <meillo@marmaro.de>
parents: 289
diff changeset
357 /* The `for' part will only be used if exactly one rcpt is present. */
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
358 gchar *for_string = NULL;
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
359 header *hdr = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
360
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
361 DEBUG(3) debugf("adding 'Received:' header\n");
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
362
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
363 if (g_list_length(msg->rcpt_list) == 1) {
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
364 address *addr = (address *) (g_list_first(msg->rcpt_list)->data);
304
d5ce2ba71e7b manual formating of Received: hdrs; changed hdr for local receival
markus schnalke <meillo@marmaro.de>
parents: 303
diff changeset
365 for_string = g_strdup_printf("\n\tfor %s", addr_string(addr));
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
366 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
367
289
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
368 if (!msg->received_host) {
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
369 /* received locally */
289
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
370 hdr = create_header(HEAD_RECEIVED,
304
d5ce2ba71e7b manual formating of Received: hdrs; changed hdr for local receival
markus schnalke <meillo@marmaro.de>
parents: 303
diff changeset
371 "Received: by %s (%s %s, from userid %d)\n\tid %s%s; %s\n",
d5ce2ba71e7b manual formating of Received: hdrs; changed hdr for local receival
markus schnalke <meillo@marmaro.de>
parents: 303
diff changeset
372 conf.host_name, PACKAGE, VERSION, geteuid(),
289
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
373 msg->uid, for_string ? for_string : "", rec_timestamp());
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
374 } else {
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
375 /* received from remote */
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
376 DEBUG(5) debugf("adding 'Received:' header (5)\n");
289
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
377 hdr = create_header(HEAD_RECEIVED,
362
9d49dffc3070 minor rework
markus schnalke <meillo@marmaro.de>
parents: 323
diff changeset
378 "Received: from %s\n\tby %s with %s (%s %s)\n\tid %s%s; %s\n",
9d49dffc3070 minor rework
markus schnalke <meillo@marmaro.de>
parents: 323
diff changeset
379 msg->received_host,
289
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
380 conf.host_name, prot_names[msg->received_prot], PACKAGE,
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
381 VERSION, msg->uid, for_string ? for_string : "",
bb3005ce0837 reformating of code
markus schnalke <meillo@marmaro.de>
parents: 276
diff changeset
382 rec_timestamp());
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
383 }
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
384 msg->hdr_list = g_list_prepend(msg->hdr_list, hdr);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
385
102
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
386 if (for_string)
f4719cffc48c removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents: 25
diff changeset
387 g_free(for_string);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
388
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
389 return AERR_OK;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
390 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
391
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
392 accept_error
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 362
diff changeset
393 accept_message(FILE *in, message *msg, guint flags)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
394 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
395 accept_error err;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
396
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
397 err = accept_message_stream(in, msg, flags);
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
398 if (err == AERR_OK) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
399 err = accept_message_prepare(msg, flags);
270
0c44b239c7fe refactoring in the small
markus schnalke <meillo@marmaro.de>
parents: 269
diff changeset
400 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
401
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
402 return err;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
403 }