Mercurial > masqmail
annotate src/accept.c @ 280:72e377210d5e
heavy refactoring of deliver.c
I need to have closer looks in there; seems as if there are possibilies
to clean up
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Mon, 06 Dec 2010 18:07:01 -0300 |
parents | 1abc1faeb45d |
children | bb3005ce0837 |
rev | line source |
---|---|
0 | 1 /* MasqMail |
2 Copyright (C) 1999-2001 Oliver Kurth | |
224 | 3 Copyright (C) 2010 markus schnalke <meillo@marmaro.de> |
0 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 */ | |
19 | |
20 #include "masqmail.h" | |
21 #include "readsock.h" | |
22 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
23 gchar *prot_names[] = { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
24 "local", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
25 "bsmtp", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
26 "smtp", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
27 "esmtp", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
28 "(unknown)" /* should not happen, but better than crashing. */ |
0 | 29 }; |
30 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
31 static gchar* |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
32 string_base62(gchar * res, guint value, gchar len) |
0 | 33 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
34 static gchar base62_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
35 gchar *p = res + len; |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
36 *p = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
37 while (p > res) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
38 *(--p) = base62_chars[value % 62]; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
39 value /= 62; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
40 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
41 return res; |
0 | 42 } |
43 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
44 static gint |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
45 _g_list_addr_isequal(gconstpointer a, gconstpointer b) |
0 | 46 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
47 address *addr1 = (address *) a; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
48 address *addr2 = (address *) b; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
49 int ret; |
0 | 50 |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
51 if ((ret = strcasecmp(addr1->domain, addr2->domain)) == 0) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
52 return strcmp(addr1->local_part, addr2->local_part); |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
53 } |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
54 return ret; |
0 | 55 } |
56 | |
57 /* accept message from anywhere. | |
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
|
58 A message from local is indicated by msg->recieved_host == NULL |
0 | 59 |
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
|
60 The -t option: With the ACC_RCPT_FROM_HEAD flag the addrs found found |
1abc1faeb45d
for -t cmdline args are now added to the rcpt list instead of substracted
markus schnalke <meillo@marmaro.de>
parents:
275
diff
changeset
|
61 in To/Cc/Bcc headers are added to the recipient list. |
0 | 62 */ |
63 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
64 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
65 accept_message_stream(FILE * in, message * msg, guint flags) |
0 | 66 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
67 gchar *line, *line1; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
68 int line_size = MAX_DATALINE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 gboolean in_headers = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 header *hdr = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
71 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
|
72 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
73 line = g_malloc(line_size); |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
74 line[0] = '\0'; |
0 | 75 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
76 while (TRUE) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
77 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
|
78 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
79 line1 = line; |
0 | 80 |
110
c678d0342451
changed name ACC_NODOT_TERM to ACC_DOT_IGNORE for better understanding
meillo@marmaro.de
parents:
109
diff
changeset
|
81 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
|
82 if (line[1] == '\n') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
83 g_free(line); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
84 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
85 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
86 line1++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
87 } |
0 | 88 |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
89 if ((len == -1) && (flags & (ACC_DOT_IGNORE | ACC_NODOT_RELAX))) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
90 /* 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
|
91 gint len1 = strlen(line1); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
92 if (len1 > 0) { /* == 0 is 'normal' (EOF after a CR) */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
93 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
|
94 line1[len1] = '\n'; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
95 line1[len1 + 1] = '\0'; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
96 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
|
97 data_size += strlen(line1); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
98 line_cnt++; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
99 } |
270
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 break; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
102 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
103 } else if (len == -1) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
104 g_free(line); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
105 return AERR_EOF; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
106 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
107 } else if (len == -2) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
108 /* should not happen any more */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
109 g_free(line); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
110 return AERR_OVERFLOW; |
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 } else if (len == -3) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
113 g_free(line); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
114 return AERR_TIMEOUT; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
115 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
116 } else if (len <= 0) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
117 /* does not happen */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
118 g_free(line); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
119 DEBUG(5) debugf("read_sockline returned %d\n", len); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
120 return AERR_UNKNOWN; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
121 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
122 } |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
123 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
124 if (in_headers) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
125 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
126 /* some pop servers send the 'From ' line, skip it: */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
127 if (!msg->hdr_list && strncmp(line1, "From ", 5) == 0) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
128 continue; |
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 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
131 if (line1[0] == ' ' || line1[0] == '\t') { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
132 /* continuation of 'folded' header: */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
133 if (hdr) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
134 hdr->header = g_strconcat(hdr->header, line1, NULL); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
135 } |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
136 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
137 } else if (line1[0] == '\n') { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
138 /* an empty line marks end of headers */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
139 in_headers = FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
140 } else { |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
141 /* in all other cases we expect another header */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
142 if ((hdr = get_header(line1))) { |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
143 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
|
144 } else { |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
145 /* if get_header() returns NULL, no header was recognized, |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
146 so this seems to be the first data line of a broken mailer |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
147 which does not send an empty line after the headers */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
148 in_headers = FALSE; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
149 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
|
150 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
151 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
152 } else { |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
153 /* message body */ |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
154 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
|
155 data_size += strlen(line1); |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
156 line_cnt++; |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
157 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
158 |
120
cd59a5b4d3dd
added support for SMTP SIZE 0 (unlimited)
meillo@marmaro.de
parents:
117
diff
changeset
|
159 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
|
160 DEBUG(4) debugf("accept_message_stream(): " |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
161 "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
|
162 data_size, conf.max_msg_size); |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
163 return AERR_SIZE; |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
164 } |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
165 |
0 | 166 } |
167 | |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
168 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
|
169 |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
170 if (!msg->data_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
171 /* 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
|
172 msg->data_list = g_list_append(NULL, g_strdup("")); |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
173 } |
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
174 msg->data_list = g_list_reverse(msg->data_list); |
0 | 175 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
176 /* we get here after we succesfully received the mail data */ |
0 | 177 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
178 msg->data_size = data_size; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
179 msg->received_time = time(NULL); |
0 | 180 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
181 return AERR_OK; |
0 | 182 } |
183 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
184 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
185 accept_message_prepare(message * msg, guint flags) |
0 | 186 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
187 struct passwd *passwd = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
188 time_t rec_time = time(NULL); |
0 | 189 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
190 DEBUG(5) debugf("accept_message_prepare()\n"); |
0 | 191 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
192 /* create unique message id */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
193 msg->uid = g_malloc(14); |
0 | 194 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
195 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
|
196 msg->uid[6] = '-'; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
197 string_base62(&(msg->uid[7]), getpid(), 3); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
198 msg->uid[10] = '-'; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
199 string_base62(&(msg->uid[11]), msg->transfer_id, 2); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
200 msg->uid[13] = 0; |
0 | 201 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
202 /* if local, get password entry */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
203 if (msg->received_host == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
204 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
|
205 msg->ident = g_strdup(passwd->pw_name); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
206 } |
0 | 207 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
208 /* set return path if local */ |
22 | 209 if (msg->return_path == NULL && msg->received_host == NULL) { |
210 gchar *path = g_strdup_printf("<%s@%s>", passwd->pw_name, conf.host_name); | |
211 DEBUG(3) debugf("setting return_path for local accept: %s\n", path); | |
212 msg->return_path = create_address(path, TRUE); | |
213 g_free(path); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
214 } |
0 | 215 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
216 /* scan headers */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
217 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
218 gboolean has_id = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
219 gboolean has_date = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
220 gboolean has_sender = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
221 gboolean has_from = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
222 gboolean has_to_or_cc = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
223 GList *hdr_node, *hdr_node_next; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
224 header *hdr; |
0 | 225 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
226 for (hdr_node = g_list_first(msg->hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
227 hdr_node != NULL; hdr_node = hdr_node_next) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
228 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
|
229 hdr = ((header *) (hdr_node->data)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
230 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
|
231 switch (hdr->id) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
232 case HEAD_MESSAGE_ID: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
233 has_id = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
234 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
235 case HEAD_DATE: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
236 has_date = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
237 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
238 case HEAD_FROM: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
239 has_from = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
240 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
241 case HEAD_SENDER: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
242 has_sender = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
243 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
244 case HEAD_TO: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
245 case HEAD_CC: |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
246 has_to_or_cc = TRUE; |
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
247 /* fall through */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
248 case HEAD_BCC: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
249 if (flags & ACC_RCPT_FROM_HEAD) { |
109 | 250 /* -t option (see comment above) */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
251 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
|
252 if (hdr->value) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
253 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
|
254 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
255 } |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
256 if (hdr->id == HEAD_BCC) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
257 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
|
258 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
|
259 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
260 destroy_header(hdr); |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
261 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
262 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
263 case HEAD_ENVELOPE_TO: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
264 if (flags & ACC_SAVE_ENVELOPE_TO) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
265 DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n"); |
22 | 266 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
|
267 "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
|
268 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
269 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
|
270 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
|
271 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
272 destroy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
273 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
274 case HEAD_RETURN_PATH: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
275 if (flags & ACC_MAIL_FROM_HEAD) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
276 /* usually POP3 accept */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
277 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
|
278 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
|
279 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
280 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
|
281 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
|
282 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
283 destroy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
284 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
285 default: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
286 break; /* make compiler happy */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
287 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
288 } |
0 | 289 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
290 if (msg->return_path == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
291 /* this can happen for pop3 accept only and if no Return-path: header was given */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
292 GList *hdr_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
293 header *hdr; |
0 | 294 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
295 DEBUG(3) debugf("return_path == NULL\n"); |
0 | 296 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
297 hdr_list = find_header(msg->hdr_list, HEAD_SENDER, NULL); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
298 if (!hdr_list) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
299 hdr_list = find_header(msg->hdr_list, HEAD_FROM, NULL); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 if (hdr_list) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
301 gchar *addr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
302 hdr = (header *) (g_list_first(hdr_list)->data); |
0 | 303 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
304 DEBUG(5) debugf("hdr->value = '%s'\n", hdr->value); |
0 | 305 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
306 addr = g_strdup(hdr->value); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
307 g_strchomp(addr); |
0 | 308 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
309 if ((msg->return_path = create_address_qualified(addr, FALSE, msg->received_host)) != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
310 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
13 | 311 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
312 "X-Warning: return path set from %s address\n", | |
313 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
|
314 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
315 g_free(addr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
316 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 if (msg->return_path == NULL) { /* no Sender: or From: or create_address_qualified failed */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
318 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
|
319 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
13 | 320 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
25 | 321 "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
|
322 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
323 } |
0 | 324 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
325 /* 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
|
326 if (!msg->rcpt_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
327 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
|
328 return AERR_NORCPT; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
329 } |
0 | 330 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
331 if (!(has_sender || has_from)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
332 DEBUG(3) debugf("adding 'From' header\n"); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
333 msg->hdr_list = g_list_append(msg->hdr_list, |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
334 msg->full_sender_name |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 ? |
13 | 336 create_header(HEAD_FROM, "From: \"%s\" <%s@%s>\n", msg->full_sender_name, |
337 msg->return_path->local_part, msg->return_path->domain) | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
338 : |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
339 create_header(HEAD_FROM, "From: <%s@%s>\n", |
13 | 340 msg->return_path->local_part, msg->return_path->domain) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
341 ); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 } |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
343 if (!has_to_or_cc) { |
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
344 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
|
345 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
|
346 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
347 if (!has_date) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
348 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
|
349 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
|
350 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
351 if (!has_id) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
352 DEBUG(3) debugf("adding 'Message-ID:' header\n"); |
13 | 353 msg->hdr_list = g_list_append(msg->hdr_list, |
354 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
|
355 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
356 } |
0 | 357 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
358 /* Received header: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
359 /* At this point because we have to know the rcpts for the 'for' part */ |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
360 gchar *for_string = NULL; |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
361 header *hdr = NULL; |
0 | 362 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
363 DEBUG(3) debugf("adding 'Received:' header\n"); |
0 | 364 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
365 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
|
366 address *addr = (address *) (g_list_first(msg->rcpt_list)->data); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
367 for_string = g_strdup_printf(" for %s", addr_string(addr)); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
368 } |
0 | 369 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
370 if (msg->received_host == NULL) { |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
371 /* received locally */ |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
372 hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n", |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
373 passwd->pw_name, conf.host_name, prot_names[msg->received_prot], |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
374 PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp()); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
375 } else { |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
376 /* received from remote */ |
0 | 377 #ifdef ENABLE_IDENT |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
378 DEBUG(5) debugf("adding 'Received:' header (5)\n"); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
379 hdr = create_header(HEAD_RECEIVED, "Received: from %s (ident=%s) by %s with %s (%s %s) id %s%s; %s\n", |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
380 msg->received_host, msg->ident ? msg->ident : "unknown", conf.host_name, |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
381 prot_names[msg->received_prot], PACKAGE, VERSION, msg->uid, for_string ? for_string : "", |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
382 rec_timestamp()); |
0 | 383 #else |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
384 hdr = create_header(HEAD_RECEIVED, "Received: from %s by %s with %s (%s %s) id %s%s; %s\n", |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
385 msg->received_host, conf.host_name, prot_names[msg->received_prot], |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
386 PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp()); |
0 | 387 #endif |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
388 } |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
389 header_fold(hdr); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
390 msg->hdr_list = g_list_prepend(msg->hdr_list, hdr); |
0 | 391 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
392 if (for_string) |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
393 g_free(for_string); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
394 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
395 return AERR_OK; |
0 | 396 } |
397 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
398 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
399 accept_message(FILE * in, message * msg, guint flags) |
0 | 400 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
401 accept_error err; |
0 | 402 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
403 err = accept_message_stream(in, msg, flags); |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
404 if (err == AERR_OK) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
405 err = accept_message_prepare(msg, flags); |
270
0c44b239c7fe
refactoring in the small
markus schnalke <meillo@marmaro.de>
parents:
269
diff
changeset
|
406 } |
0 | 407 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
408 return err; |
0 | 409 } |