Mercurial > masqmail-0.2
annotate src/accept.c @ 190:fbb3417c1a54 default tip
Minor fixes in man pages, reported by lintian(1)
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Mon, 29 Aug 2011 19:22:51 +0200 |
parents | ec3fe72a3e99 |
children |
rev | line source |
---|---|
0 | 1 /* MasqMail |
2 Copyright (C) 1999-2001 Oliver Kurth | |
174 | 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 "pop3", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
29 "apop", |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
30 "(unknown)" /* should not happen, but better than crashing. */ |
0 | 31 }; |
32 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
33 static gchar* |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
34 string_base62(gchar * res, guint value, gchar len) |
0 | 35 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
36 static gchar base62_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
37 gchar *p = res + len; |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
38 *p = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
39 while (p > res) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
40 *(--p) = base62_chars[value % 62]; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
41 value /= 62; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
42 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
43 return res; |
0 | 44 } |
45 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
46 static gint |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
47 _g_list_addr_isequal(gconstpointer a, gconstpointer b) |
0 | 48 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
49 address *addr1 = (address *) a; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
50 address *addr2 = (address *) b; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
51 int ret; |
0 | 52 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
53 if ((ret = strcasecmp(addr1->domain, addr2->domain)) == 0) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
54 return strcmp(addr1->local_part, addr2->local_part); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
55 else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
56 return ret; |
0 | 57 } |
58 | |
59 /* accept message from anywhere. | |
60 A locally originating message is indicated by msg->recieved_host == NULL | |
61 | |
109 | 62 The -t option: |
63 The ACC_RCPT_FROM_HEAD flag adds the recipients found in To/Cc/Bcc | |
64 headers to the recipients list. | |
65 The ACC_DEL_RCPTS flag makes only sense if the ACC_RCPT_FROM_HEAD | |
66 flag is given too. With ACC_DEL_RCPTS the recipients given on the | |
67 command line are removed from the ones given in headers. | |
0 | 68 */ |
69 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
71 accept_message_stream(FILE * in, message * msg, guint flags) |
0 | 72 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
73 gchar *line, *line1; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
74 int line_size = MAX_DATALINE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
75 gboolean in_headers = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
76 header *hdr = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
77 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
|
78 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
79 line = g_malloc(line_size); |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
80 line[0] = '\0'; |
0 | 81 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
82 while (TRUE) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
83 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
|
84 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
85 line1 = line; |
0 | 86 |
110
c678d0342451
changed name ACC_NODOT_TERM to ACC_DOT_IGNORE for better understanding
meillo@marmaro.de
parents:
109
diff
changeset
|
87 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
|
88 if (line[1] == '\n') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
89 g_free(line); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
90 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
91 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
92 line1++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
93 } |
0 | 94 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
95 if (len <= 0) { |
111
43798acdfbc9
simplified a bit-operation based condition
meillo@marmaro.de
parents:
110
diff
changeset
|
96 if ((len == -1) && (flags & (ACC_DOT_IGNORE | ACC_NODOT_RELAX))) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
97 /* we got an EOF, and the last line was not terminated by a CR */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
98 gint len1 = strlen(line1); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
99 if (len1 > 0) { /* == 0 is 'normal' (EOF after a CR) */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
100 if (line1[len1 - 1] != '\n') { /* some mail clients allow unterminated lines */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
101 line1[len1] = '\n'; |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
102 line1[len1 + 1] = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
103 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
104 data_size += strlen(line1); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
105 line_cnt++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
106 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
107 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
108 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
109 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
110 g_free(line); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
111 if (len == -1) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
112 return AERR_EOF; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
113 } else if (len == -2) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
114 /* should not happen any more */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
115 return AERR_OVERFLOW; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
116 } else if (len == -3) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
117 return AERR_TIMEOUT; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
118 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
119 /* does not happen */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
120 DEBUG(5) debugf("read_sockline returned %d\n", len); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
121 return AERR_UNKNOWN; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
122 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
123 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
124 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
125 if (in_headers) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
126 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
127 /* some pop servers send the 'From ' line, skip it: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
128 if (msg->hdr_list == NULL) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
129 if (strncmp(line1, "From ", 5) == 0) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
130 continue; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
131 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
132 if (line1[0] == ' ' || line1[0] == '\t') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
133 /* continuation of 'folded' header: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
134 if (hdr) { |
179
ec3fe72a3e99
Fixed an important bug with folded headers!
meillo@marmaro.de
parents:
174
diff
changeset
|
135 char* cp; |
ec3fe72a3e99
Fixed an important bug with folded headers!
meillo@marmaro.de
parents:
174
diff
changeset
|
136 cp = g_strconcat(hdr->header, line1, NULL); |
ec3fe72a3e99
Fixed an important bug with folded headers!
meillo@marmaro.de
parents:
174
diff
changeset
|
137 hdr->value = cp + (hdr->value - hdr->header); |
ec3fe72a3e99
Fixed an important bug with folded headers!
meillo@marmaro.de
parents:
174
diff
changeset
|
138 free(hdr->header); |
ec3fe72a3e99
Fixed an important bug with folded headers!
meillo@marmaro.de
parents:
174
diff
changeset
|
139 hdr->header = cp; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
140 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
141 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
142 } else if (line1[0] == '\n') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
143 /* an empty line marks end of headers */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
144 in_headers = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
145 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
146 /* in all other cases we expect another header */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
147 if ((hdr = get_header(line1))) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
148 msg->hdr_list = g_list_append(msg->hdr_list, hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
149 else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
150 /* if get_header() returns NULL, no header was recognized, |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
151 so this seems to be the first data line of a broken mailer |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
152 which does not send an empty line after the headers */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
153 in_headers = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
154 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
155 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
156 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
157 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
158 msg->data_list = g_list_prepend(msg->data_list, g_strdup(line1)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
159 data_size += strlen(line1); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
160 line_cnt++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
161 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
162 } |
120
cd59a5b4d3dd
added support for SMTP SIZE 0 (unlimited)
meillo@marmaro.de
parents:
117
diff
changeset
|
163 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
|
164 DEBUG(4) debugf("accept_message_stream(): " |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
165 "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
|
166 data_size, conf.max_msg_size); |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
167 return AERR_SIZE; |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
168 } |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
111
diff
changeset
|
169 |
0 | 170 } |
171 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
172 if (msg->data_list != NULL) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
173 msg->data_list = g_list_reverse(msg->data_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
174 else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
175 /* 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
|
176 msg->data_list = g_list_append(NULL, g_strdup("")); |
0 | 177 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
178 DEBUG(4) debugf("received %d lines of data (%d bytes)\n", line_cnt, data_size); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
179 /* we get here after we succesfully received the mail data */ |
0 | 180 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
181 msg->data_size = data_size; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
182 msg->received_time = time(NULL); |
0 | 183 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
184 return AERR_OK; |
0 | 185 } |
186 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
187 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
188 accept_message_prepare(message * msg, guint flags) |
0 | 189 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
190 struct passwd *passwd = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
191 GList *non_rcpt_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
192 time_t rec_time = time(NULL); |
0 | 193 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
194 DEBUG(5) debugf("accept_message_prepare()\n"); |
0 | 195 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
196 /* create unique message id */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
197 msg->uid = g_malloc(14); |
0 | 198 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
199 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
|
200 msg->uid[6] = '-'; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
201 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
|
202 msg->uid[10] = '-'; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
203 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
|
204 msg->uid[13] = 0; |
0 | 205 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
206 /* if local, get password entry */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
207 if (msg->received_host == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
208 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
|
209 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
|
210 } |
0 | 211 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
212 /* set return path if local */ |
22 | 213 if (msg->return_path == NULL && msg->received_host == NULL) { |
214 gchar *path = g_strdup_printf("<%s@%s>", passwd->pw_name, conf.host_name); | |
215 DEBUG(3) debugf("setting return_path for local accept: %s\n", path); | |
216 msg->return_path = create_address(path, TRUE); | |
217 g_free(path); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
218 } |
0 | 219 |
109 | 220 /* -t option (see comment above) */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
221 if (flags & ACC_DEL_RCPTS) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
222 non_rcpt_list = msg->rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
223 msg->rcpt_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
224 } |
0 | 225 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
226 /* scan headers */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
227 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
228 gboolean has_id = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
229 gboolean has_date = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
230 gboolean has_sender = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
231 gboolean has_from = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
232 gboolean has_to_or_cc = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
233 GList *hdr_node, *hdr_node_next; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
234 header *hdr; |
0 | 235 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 hdr = ((header *) (hdr_node->data)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
240 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
|
241 switch (hdr->id) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
242 case HEAD_MESSAGE_ID: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
243 has_id = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
244 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
245 case HEAD_DATE: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
246 has_date = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
247 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
248 case HEAD_FROM: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
249 has_from = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
250 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
251 case HEAD_SENDER: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
252 has_sender = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
253 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
254 case HEAD_TO: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
255 case HEAD_CC: |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
256 has_to_or_cc = TRUE; |
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
257 /* fall through */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
258 case HEAD_BCC: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
259 if (flags & ACC_RCPT_FROM_HEAD) { |
109 | 260 /* -t option (see comment above) */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
261 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
|
262 if (hdr->value) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
263 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
|
264 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
265 } |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
266 if (hdr->id == HEAD_BCC) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
267 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
|
268 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
|
269 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
270 destroy_header(hdr); |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
271 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
272 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
273 case HEAD_ENVELOPE_TO: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
274 if (flags & ACC_SAVE_ENVELOPE_TO) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
275 DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n"); |
22 | 276 msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN, |
277 "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
|
278 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
279 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
|
280 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
|
281 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
282 destroy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
283 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
284 case HEAD_RETURN_PATH: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
285 if (flags & ACC_MAIL_FROM_HEAD) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
286 /* usually POP3 accept */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
287 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
|
288 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
|
289 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
290 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
|
291 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
|
292 g_list_free_1(hdr_node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
293 destroy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
294 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
295 default: |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
296 break; /* make compiler happy */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
297 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
298 } |
0 | 299 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 if (msg->return_path == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
301 /* 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
|
302 GList *hdr_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
303 header *hdr; |
0 | 304 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
305 DEBUG(3) debugf("return_path == NULL\n"); |
0 | 306 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
307 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
|
308 if (!hdr_list) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
309 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
|
310 if (hdr_list) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
311 gchar *addr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
312 hdr = (header *) (g_list_first(hdr_list)->data); |
0 | 313 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
314 DEBUG(5) debugf("hdr->value = '%s'\n", hdr->value); |
0 | 315 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
316 addr = g_strdup(hdr->value); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 g_strchomp(addr); |
0 | 318 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
319 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
|
320 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
13 | 321 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
322 "X-Warning: return path set from %s address\n", | |
323 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
|
324 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
325 g_free(addr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
326 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
327 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
|
328 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
|
329 DEBUG(3) debugf("setting return_path to %s\n", addr_string(msg->return_path)); |
13 | 330 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
25 | 331 "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
|
332 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
333 } |
0 | 334 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 if (flags & ACC_DEL_RCPTS) { |
109 | 336 /* remove the recipients given on the command line from the ones given in headers |
337 -t option (see comment above) */ | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
338 GList *rcpt_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
339 foreach(non_rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
340 address *rcpt = (address *) (rcpt_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
341 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 if ((node = g_list_find_custom(msg->rcpt_list, rcpt, _g_list_addr_isequal))) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
343 DEBUG(3) debugf("removing rcpt address %s\n", addr_string(node->data)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
344 msg->rcpt_list = g_list_remove_link(msg->rcpt_list, node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
345 destroy_address((address *) (node->data)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
346 g_list_free_1(node); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
347 } |
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 } |
0 | 350 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
351 /* here we should have our recipients, fail if not: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
352 if (msg->rcpt_list == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
353 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
|
354 return AERR_NORCPT; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
355 } |
0 | 356 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
357 if (!(has_sender || has_from)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
358 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
|
359 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
|
360 msg->full_sender_name |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
361 ? |
13 | 362 create_header(HEAD_FROM, "From: \"%s\" <%s@%s>\n", msg->full_sender_name, |
363 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
|
364 : |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
365 create_header(HEAD_FROM, "From: <%s@%s>\n", |
13 | 366 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
|
367 ); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
368 } |
106
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
369 if (!has_to_or_cc) { |
1f0d63713a1c
masqmail now *always* removes Bcc: headers
meillo@marmaro.de
parents:
105
diff
changeset
|
370 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
|
371 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
|
372 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
373 if (!has_date) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
374 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
|
375 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
|
376 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
377 if (!has_id) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
378 DEBUG(3) debugf("adding 'Message-ID:' header\n"); |
13 | 379 msg->hdr_list = g_list_append(msg->hdr_list, |
380 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
|
381 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
382 } |
0 | 383 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
384 /* Received header: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
385 /* 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
|
386 gchar *for_string = NULL; |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
387 header *hdr = NULL; |
0 | 388 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
389 DEBUG(3) debugf("adding 'Received:' header\n"); |
0 | 390 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
391 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
|
392 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
|
393 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
|
394 } |
0 | 395 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
396 if (msg->received_host == NULL) { |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
397 /* received locally */ |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
398 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
|
399 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
|
400 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
|
401 } else { |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
402 /* received from remote */ |
0 | 403 #ifdef ENABLE_IDENT |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 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
|
408 rec_timestamp()); |
0 | 409 #else |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
410 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
|
411 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
|
412 PACKAGE, VERSION, msg->uid, for_string ? for_string : "", rec_timestamp()); |
0 | 413 #endif |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
414 } |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
415 header_fold(hdr); |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
416 msg->hdr_list = g_list_prepend(msg->hdr_list, hdr); |
0 | 417 |
102
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
418 if (for_string) |
f4719cffc48c
removed the ACC_NO_RECVD_HDR because it is never set
meillo@marmaro.de
parents:
25
diff
changeset
|
419 g_free(for_string); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
420 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
421 /* write message to spool: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
422 /* accept is no longer responsible for this |
13 | 423 if (!spool_write(msg, TRUE)) |
424 return AERR_NOSPOOL; | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
425 */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
426 return AERR_OK; |
0 | 427 } |
428 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
429 accept_error |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
430 accept_message(FILE * in, message * msg, guint flags) |
0 | 431 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
432 accept_error err; |
0 | 433 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
434 err = accept_message_stream(in, msg, flags); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
435 if (err == AERR_OK) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
436 err = accept_message_prepare(msg, flags); |
0 | 437 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
438 return err; |
0 | 439 } |