rev |
line source |
meillo@0
|
1 /* MasqMail
|
meillo@0
|
2 Copyright (C) 1999-2001 Oliver Kurth
|
meillo@224
|
3 Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
|
meillo@0
|
4
|
meillo@0
|
5 This program is free software; you can redistribute it and/or modify
|
meillo@0
|
6 it under the terms of the GNU General Public License as published by
|
meillo@0
|
7 the Free Software Foundation; either version 2 of the License, or
|
meillo@0
|
8 (at your option) any later version.
|
meillo@0
|
9
|
meillo@0
|
10 This program is distributed in the hope that it will be useful,
|
meillo@0
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
meillo@0
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
meillo@0
|
13 GNU General Public License for more details.
|
meillo@0
|
14
|
meillo@0
|
15 You should have received a copy of the GNU General Public License
|
meillo@0
|
16 along with this program; if not, write to the Free Software
|
meillo@0
|
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
meillo@0
|
18 */
|
meillo@0
|
19 #include <config.h>
|
meillo@0
|
20
|
meillo@0
|
21 #include <stdio.h>
|
meillo@0
|
22 #include <stdarg.h>
|
meillo@0
|
23 #include <errno.h>
|
meillo@0
|
24 #include <stdlib.h>
|
meillo@0
|
25 #include <string.h>
|
meillo@0
|
26 #include <ctype.h>
|
meillo@0
|
27 #include <unistd.h>
|
meillo@0
|
28 #include <pwd.h>
|
meillo@0
|
29 #include <sys/types.h>
|
meillo@0
|
30 #include <sys/socket.h>
|
meillo@0
|
31 #include <netinet/in.h>
|
meillo@0
|
32 #include <time.h>
|
meillo@0
|
33 #include <sys/time.h>
|
meillo@0
|
34 #include <netinet/in.h>
|
meillo@0
|
35 #include <arpa/inet.h>
|
meillo@0
|
36 #include <netdb.h>
|
meillo@0
|
37 #include <syslog.h>
|
meillo@0
|
38 #include <signal.h>
|
meillo@0
|
39 #include <fcntl.h>
|
meillo@0
|
40
|
meillo@0
|
41 #include <glib.h>
|
meillo@0
|
42
|
meillo@0
|
43 #ifdef ENABLE_IDENT
|
meillo@0
|
44 #include "libident/ident.h"
|
meillo@0
|
45 #endif
|
meillo@0
|
46
|
meillo@0
|
47 #include "lookup.h"
|
meillo@0
|
48
|
meillo@10
|
49 typedef struct _interface {
|
meillo@10
|
50 gchar *address;
|
meillo@10
|
51 gint port;
|
meillo@0
|
52 } interface;
|
meillo@0
|
53
|
meillo@0
|
54 #define ADDR_FLAG_DELIVERED 0x01
|
meillo@0
|
55 #define ADDR_FLAG_DEFERED 0x02
|
meillo@0
|
56 #define ADDR_FLAG_FAILED 0x04
|
meillo@0
|
57 #define ADDR_FLAG_LAST_ROUTE 0x40
|
meillo@0
|
58
|
meillo@10
|
59 typedef struct _address {
|
meillo@10
|
60 gchar *address;
|
meillo@10
|
61 gchar *local_part;
|
meillo@10
|
62 gchar *domain;
|
meillo@10
|
63 gint flags;
|
meillo@10
|
64 GList *children;
|
meillo@10
|
65 struct _address *parent;
|
meillo@0
|
66 } address;
|
meillo@0
|
67
|
meillo@0
|
68 #define addr_mark_delivered(addr) { addr->flags |= ADDR_FLAG_DELIVERED; }
|
meillo@0
|
69 #define addr_unmark_delivered(addr) { addr->flags &= ~ADDR_FLAG_DELIVERED; }
|
meillo@0
|
70 #define addr_is_delivered(addr) ((addr->flags & ADDR_FLAG_DELIVERED) != 0 )
|
meillo@0
|
71
|
meillo@0
|
72 #define addr_mark_defered(addr) { addr->flags |= ADDR_FLAG_DEFERED; }
|
meillo@0
|
73 #define addr_unmark_defered(addr) { addr->flags &= ~ADDR_FLAG_DEFERED; }
|
meillo@0
|
74 #define addr_is_defered(addr) ((addr->flags & ADDR_FLAG_DEFERED) != 0 )
|
meillo@0
|
75
|
meillo@0
|
76 #define addr_mark_failed(addr) { addr->flags |= ADDR_FLAG_FAILED; }
|
meillo@0
|
77 #define addr_unmark_failed(addr) { addr->flags &= ~ADDR_FLAG_FAILED; }
|
meillo@0
|
78 #define addr_is_failed(addr) ((addr->flags & ADDR_FLAG_FAILED) != 0 )
|
meillo@0
|
79
|
meillo@10
|
80 typedef struct _connect_route {
|
meillo@10
|
81 gchar *name;
|
meillo@10
|
82 gchar *filename;
|
meillo@0
|
83
|
meillo@10
|
84 gboolean is_local_net;
|
meillo@10
|
85 gboolean last_route;
|
meillo@0
|
86
|
meillo@317
|
87 GList *allowed_senders;
|
meillo@317
|
88 GList *denied_senders;
|
meillo@317
|
89 GList *allowed_recipients;
|
meillo@317
|
90 GList *denied_recipients;
|
meillo@0
|
91
|
meillo@10
|
92 interface *mail_host;
|
meillo@10
|
93 gchar *wrapper;
|
meillo@10
|
94 gboolean connect_error_fail;
|
meillo@0
|
95
|
meillo@10
|
96 gchar *helo_name;
|
meillo@10
|
97 gboolean do_correct_helo;
|
meillo@222
|
98 gboolean instant_helo;
|
meillo@10
|
99 gboolean do_pipelining;
|
meillo@0
|
100
|
meillo@10
|
101 gchar *set_h_from_domain;
|
meillo@10
|
102 gchar *set_h_reply_to_domain;
|
meillo@10
|
103 gchar *set_return_path_domain;
|
meillo@0
|
104
|
meillo@10
|
105 GList *map_h_from_addresses;
|
meillo@10
|
106 GList *map_h_reply_to_addresses;
|
meillo@10
|
107 GList *map_h_mail_followup_to_addresses;
|
meillo@10
|
108 GList *map_return_path_addresses;
|
meillo@0
|
109
|
meillo@10
|
110 gboolean expand_h_sender_domain;
|
meillo@10
|
111 gboolean expand_h_sender_address;
|
meillo@0
|
112
|
meillo@10
|
113 GList *resolve_list;
|
meillo@0
|
114
|
meillo@10
|
115 gchar *auth_name;
|
meillo@10
|
116 gchar *auth_login;
|
meillo@10
|
117 gchar *auth_secret;
|
meillo@0
|
118
|
meillo@10
|
119 gchar *pipe;
|
meillo@10
|
120
|
meillo@10
|
121 gboolean pipe_fromline;
|
meillo@10
|
122 gboolean pipe_fromhack;
|
meillo@0
|
123 } connect_route;
|
meillo@0
|
124
|
meillo@10
|
125 typedef struct _masqmail_conf {
|
meillo@10
|
126 gint mail_uid;
|
meillo@10
|
127 gint mail_gid;
|
meillo@0
|
128
|
meillo@10
|
129 gint orig_uid;
|
meillo@10
|
130 gint orig_gid;
|
meillo@0
|
131
|
meillo@10
|
132 gboolean run_as_user;
|
meillo@0
|
133
|
meillo@10
|
134 gchar *mail_dir;
|
meillo@10
|
135 gchar *lock_dir;
|
meillo@10
|
136 gchar *spool_dir;
|
meillo@10
|
137 gchar *log_dir;
|
meillo@0
|
138
|
meillo@10
|
139 gint debug_level;
|
meillo@10
|
140 gboolean use_syslog;
|
meillo@10
|
141 guint log_max_pri;
|
meillo@0
|
142
|
meillo@10
|
143 gchar *host_name;
|
meillo@10
|
144 GList *local_hosts;
|
meillo@10
|
145 GList *local_addresses;
|
meillo@10
|
146 GList *not_local_addresses;
|
meillo@10
|
147 GList *local_nets;
|
meillo@10
|
148 GList *listen_addresses;
|
meillo@0
|
149
|
meillo@117
|
150 /* ANSI C defines unsigned long to be at least 32bit
|
meillo@117
|
151 i.e. ca. 4GB max; that should be enough. */
|
meillo@117
|
152 gulong max_msg_size;
|
meillo@117
|
153
|
meillo@10
|
154 gboolean do_save_envelope_to;
|
meillo@0
|
155
|
meillo@10
|
156 gboolean defer_all;
|
meillo@10
|
157 gboolean do_relay;
|
meillo@0
|
158
|
meillo@10
|
159 GList *ident_trusted_nets;
|
meillo@0
|
160
|
meillo@10
|
161 gboolean do_queue;
|
meillo@0
|
162
|
meillo@10
|
163 gboolean do_verbose;
|
meillo@0
|
164
|
meillo@10
|
165 gchar *mbox_default;
|
meillo@10
|
166 GList *mbox_users;
|
meillo@10
|
167 GList *mda_users;
|
meillo@0
|
168
|
meillo@10
|
169 gchar *mda;
|
meillo@10
|
170 gboolean mda_fromline;
|
meillo@10
|
171 gboolean mda_fromhack;
|
meillo@0
|
172
|
meillo@10
|
173 gboolean pipe_fromline;
|
meillo@10
|
174 gboolean pipe_fromhack;
|
meillo@0
|
175
|
meillo@10
|
176 gchar *alias_file;
|
meillo@244
|
177 int (*localpartcmp) (const char *, const char *);
|
meillo@0
|
178
|
meillo@10
|
179 GList *local_net_routes;
|
meillo@10
|
180 GList *connect_routes; /* list of pairs which point to lists */
|
meillo@0
|
181
|
meillo@310
|
182 gchar *online_query;
|
meillo@0
|
183
|
meillo@10
|
184 gchar *errmsg_file;
|
meillo@10
|
185 gchar *warnmsg_file;
|
meillo@10
|
186 GList *warn_intervals;
|
meillo@10
|
187 gint max_defer_time;
|
meillo@0
|
188
|
meillo@10
|
189 gchar *log_user;
|
meillo@0
|
190 } masqmail_conf;
|
meillo@0
|
191
|
meillo@0
|
192 extern masqmail_conf conf;
|
meillo@0
|
193
|
meillo@10
|
194 typedef struct _table_pair {
|
meillo@10
|
195 gchar *key;
|
meillo@10
|
196 gpointer *value;
|
meillo@0
|
197 } table_pair;
|
meillo@0
|
198
|
meillo@0
|
199
|
meillo@299
|
200 /* must match the contents of prot_names[] in accept.c */
|
meillo@10
|
201 typedef enum _prot_id {
|
meillo@10
|
202 PROT_LOCAL = 0,
|
meillo@10
|
203 PROT_SMTP,
|
meillo@10
|
204 PROT_ESMTP,
|
meillo@10
|
205 PROT_NUM
|
meillo@10
|
206 } prot_id;
|
meillo@0
|
207
|
meillo@0
|
208 extern gchar *prot_names[];
|
meillo@0
|
209
|
meillo@10
|
210 typedef enum _header_id {
|
meillo@10
|
211 HEAD_FROM = 0,
|
meillo@10
|
212 HEAD_SENDER,
|
meillo@10
|
213 HEAD_TO,
|
meillo@10
|
214 HEAD_CC,
|
meillo@10
|
215 HEAD_BCC,
|
meillo@10
|
216 HEAD_DATE,
|
meillo@10
|
217 HEAD_MESSAGE_ID,
|
meillo@10
|
218 HEAD_REPLY_TO,
|
meillo@10
|
219 HEAD_SUBJECT,
|
meillo@10
|
220 HEAD_RETURN_PATH,
|
meillo@10
|
221 HEAD_ENVELOPE_TO,
|
meillo@10
|
222 HEAD_RECEIVED,
|
meillo@10
|
223 HEAD_NUM_IDS,
|
meillo@10
|
224 HEAD_STATUS,
|
meillo@10
|
225 HEAD_UNKNOWN = HEAD_NUM_IDS,
|
meillo@10
|
226 HEAD_NONE = -1,
|
meillo@10
|
227 } header_id;
|
meillo@0
|
228
|
meillo@10
|
229 typedef struct _header_name {
|
meillo@10
|
230 gchar *header;
|
meillo@10
|
231 header_id id;
|
meillo@10
|
232 } header_name;
|
meillo@0
|
233
|
meillo@10
|
234 typedef struct _header {
|
meillo@10
|
235 header_id id;
|
meillo@10
|
236 gchar *header;
|
meillo@10
|
237 gchar *value;
|
meillo@10
|
238 } header;
|
meillo@0
|
239
|
meillo@0
|
240
|
meillo@10
|
241 typedef struct _message {
|
meillo@10
|
242 gchar *uid;
|
meillo@0
|
243
|
meillo@10
|
244 gchar *received_host;
|
meillo@10
|
245 prot_id received_prot;
|
meillo@10
|
246 gchar *ident;
|
meillo@10
|
247 gint transfer_id; /* for multiple messages per transfer */
|
meillo@0
|
248
|
meillo@10
|
249 address *return_path;
|
meillo@10
|
250 GList *rcpt_list;
|
meillo@10
|
251 GList *non_rcpt_list;
|
meillo@0
|
252
|
meillo@10
|
253 GList *hdr_list;
|
meillo@10
|
254 GList *data_list;
|
meillo@0
|
255
|
meillo@10
|
256 gint data_size;
|
meillo@10
|
257 time_t received_time;
|
meillo@10
|
258 time_t warned_time;
|
meillo@0
|
259
|
meillo@10
|
260 gchar *full_sender_name;
|
meillo@10
|
261 } message;
|
meillo@0
|
262
|
meillo@10
|
263 typedef struct _msg_out {
|
meillo@10
|
264 message *msg;
|
meillo@0
|
265
|
meillo@10
|
266 address *return_path;
|
meillo@10
|
267 GList *rcpt_list;
|
meillo@0
|
268
|
meillo@10
|
269 GList *hdr_list;
|
meillo@10
|
270 GList *xtra_hdr_list;
|
meillo@10
|
271 } msg_out;
|
meillo@10
|
272
|
meillo@10
|
273 typedef struct _msgout_perhost {
|
meillo@10
|
274 gchar *host;
|
meillo@10
|
275 GList *msgout_list;
|
meillo@0
|
276 } msgout_perhost;
|
meillo@0
|
277
|
meillo@0
|
278 /* flags for accept() */
|
meillo@10
|
279 #define ACC_RCPT_FROM_HEAD 0x08 /* -t option, get rcpts from headers */
|
meillo@110
|
280 #define ACC_DOT_IGNORE 0x10 /* a dot on a line itself does not end the message (-oi option) */
|
meillo@10
|
281 #define ACC_MAIL_FROM_HEAD 0x40 /* get return path from header */
|
meillo@10
|
282 #define ACC_NODOT_RELAX 0x80 /* do not be picky if message ist not terminated by a dot on a line */
|
meillo@10
|
283 #define ACC_SAVE_ENVELOPE_TO 0x0100 /* save an existent Envelope-to header as X-Orig-Envelope-to */
|
meillo@0
|
284
|
meillo@0
|
285 #define DLVR_LOCAL 0x01
|
meillo@0
|
286 #define DLVR_LAN 0x02
|
meillo@0
|
287 #define DLVR_ONLINE 0x04
|
meillo@0
|
288 #define DLVR_ALL (DLVR_LOCAL|DLVR_LAN|DLVR_ONLINE)
|
meillo@0
|
289
|
meillo@0
|
290 /* transport flags */
|
meillo@0
|
291 #define MSGSTR_FROMLINE 0x01
|
meillo@0
|
292 #define MSGSTR_FROMHACK 0x02
|
meillo@0
|
293
|
meillo@10
|
294 typedef enum _accept_error {
|
meillo@10
|
295 AERR_OK = 0,
|
meillo@10
|
296 AERR_TIMEOUT,
|
meillo@10
|
297 AERR_EOF,
|
meillo@10
|
298 AERR_OVERFLOW,
|
meillo@10
|
299 AERR_SYNTAX,
|
meillo@10
|
300 AERR_NOSPOOL,
|
meillo@10
|
301 AERR_NORCPT,
|
meillo@117
|
302 AERR_SIZE, /* max msg size exeeded (SMTP SIZE) */
|
meillo@10
|
303 AERR_UNKNOWN
|
meillo@10
|
304 } accept_error;
|
meillo@0
|
305
|
meillo@0
|
306 #define BUF_LEN 1024
|
meillo@0
|
307 #define MAX_ADDRESS 256
|
meillo@0
|
308 #define MAX_DATALINE 4096
|
meillo@0
|
309
|
meillo@10
|
310 typedef enum _smtp_cmd_id {
|
meillo@10
|
311 SMTP_HELO = 0,
|
meillo@10
|
312 SMTP_EHLO,
|
meillo@10
|
313 SMTP_MAIL_FROM,
|
meillo@10
|
314 SMTP_RCPT_TO,
|
meillo@10
|
315 SMTP_DATA,
|
meillo@10
|
316 SMTP_QUIT,
|
meillo@10
|
317 SMTP_RSET,
|
meillo@10
|
318 SMTP_NOOP,
|
meillo@10
|
319 SMTP_HELP,
|
meillo@10
|
320 SMTP_NUM_IDS,
|
meillo@10
|
321 SMTP_EOF = -1,
|
meillo@10
|
322 SMTP_ERROR = -2,
|
meillo@0
|
323 } smtp_cmd_id;
|
meillo@0
|
324
|
meillo@10
|
325 typedef struct _smtp_cmd {
|
meillo@10
|
326 smtp_cmd_id id;
|
meillo@10
|
327 gchar *cmd;
|
meillo@0
|
328 } smtp_cmd;
|
meillo@0
|
329
|
meillo@10
|
330 typedef struct _smtp_connection {
|
meillo@10
|
331 gchar *remote_host;
|
meillo@0
|
332
|
meillo@10
|
333 prot_id prot;
|
meillo@10
|
334 gint next_id;
|
meillo@0
|
335
|
meillo@10
|
336 gboolean helo_seen;
|
meillo@10
|
337 gboolean from_seen;
|
meillo@10
|
338 gboolean rcpt_seen;
|
meillo@10
|
339
|
meillo@10
|
340 message *msg;
|
meillo@10
|
341 } smtp_connection;
|
meillo@0
|
342
|
meillo@0
|
343 /* alias.c*/
|
meillo@10
|
344 gboolean addr_is_local(address * addr);
|
meillo@10
|
345 GList *alias_expand(GList * alias_table, GList * rcpt_list, GList * non_rcpt_list);
|
meillo@0
|
346
|
meillo@0
|
347 /* child.c */
|
meillo@0
|
348 int child(const char *command);
|
meillo@0
|
349
|
meillo@0
|
350 /* conf.c */
|
meillo@0
|
351 void init_conf();
|
meillo@10
|
352 gboolean read_conf(gchar * filename);
|
meillo@10
|
353 connect_route *read_route(gchar * filename, gboolean is_local_net);
|
meillo@10
|
354 GList *read_route_list(GList * rf_list, gboolean is_local_net);
|
meillo@10
|
355 void destroy_route(connect_route * r);
|
meillo@10
|
356 void destroy_route_list(GList * list);
|
meillo@0
|
357 connect_route *create_local_route();
|
meillo@0
|
358
|
meillo@0
|
359 /* expand.c */
|
meillo@10
|
360 GList *var_table_rcpt(GList * var_table, address * rcpt);
|
meillo@10
|
361 GList *var_table_msg(GList * var_table, message * msg);
|
meillo@10
|
362 GList *var_table_conf(GList * var_table);
|
meillo@10
|
363 gint expand(GList * var_list, gchar * format, gchar * result, gint result_len);
|
meillo@0
|
364
|
meillo@0
|
365 /* message.c */
|
meillo@0
|
366 message *create_message(void);
|
meillo@10
|
367 void destroy_message(message * msg);
|
meillo@10
|
368 void destroy_msg_list(GList * msg_list);
|
meillo@10
|
369 void msg_free_data(message * msg);
|
meillo@10
|
370 gint msg_calc_size(message * msg, gboolean is_smtp);
|
meillo@0
|
371
|
meillo@10
|
372 msg_out *create_msg_out(message * msg);
|
meillo@10
|
373 msg_out *clone_msg_out(msg_out * msgout_orig);
|
meillo@10
|
374 GList *create_msg_out_list(GList * msg_list);
|
meillo@10
|
375 void destroy_msg_out(msg_out * msgout);
|
meillo@10
|
376 void destroy_msg_out_list(GList * msgout_list);
|
meillo@0
|
377
|
meillo@0
|
378 /* address.c */
|
meillo@10
|
379 address *create_address(gchar * path, gboolean is_rfc821);
|
meillo@10
|
380 address *create_address_qualified(gchar * path, gboolean is_rfc821, gchar * domain);
|
meillo@10
|
381 address *create_address_pipe(gchar * path);
|
meillo@10
|
382 void destroy_address(address * addr);
|
meillo@10
|
383 address *copy_modify_address(const address * orig, gchar * l_part, gchar * dom);
|
meillo@0
|
384 #define copy_address(addr) copy_modify_address(addr, NULL, NULL)
|
meillo@242
|
385 gboolean addr_isequal(address * addr1, address * addr2, int (*cmpfunc) (const char*, const char*));
|
meillo@242
|
386 gboolean addr_isequal_parent(address * addr1, address * addr2, int (*cmpfunc) (const char*, const char*));
|
meillo@10
|
387 address *addr_find_ancestor(address * addr);
|
meillo@10
|
388 gboolean addr_is_delivered_children(address * addr);
|
meillo@10
|
389 gboolean addr_is_finished_children(address * addr);
|
meillo@10
|
390 gchar *addr_string(address * addr);
|
meillo@0
|
391
|
meillo@0
|
392 /* accept.c */
|
meillo@10
|
393 accept_error accept_message(FILE * in, message * msg, guint flags);
|
meillo@10
|
394 accept_error accept_message_prepare(message * msg, guint flags);
|
meillo@0
|
395
|
meillo@0
|
396 /* header.c */
|
meillo@0
|
397 gchar *rec_timestamp();
|
meillo@10
|
398 GList *find_header(GList * hdr_list, header_id id, gchar * hdr_str);
|
meillo@10
|
399 void header_unfold(header * hdr);
|
meillo@303
|
400 void header_fold(header * hdr, unsigned int maxlen);
|
meillo@10
|
401 header *create_header(header_id id, gchar * fmt, ...);
|
meillo@10
|
402 void destroy_header(header * hdr);
|
meillo@10
|
403 header *copy_header(header * hdr);
|
meillo@10
|
404 header *get_header(gchar * line);
|
meillo@0
|
405
|
meillo@0
|
406 /* smtp_in.c */
|
meillo@10
|
407 void smtp_in(FILE * in, FILE * out, gchar * remote_host, gchar * ident);
|
meillo@0
|
408
|
meillo@0
|
409 /* listen.c */
|
meillo@10
|
410 void listen_port(GList * addr_list, gint qival, char *argv[]);
|
meillo@0
|
411
|
meillo@0
|
412 /* parse.c */
|
meillo@10
|
413 gboolean split_address(const gchar * path, gchar ** local_part, gchar ** domain, gboolean is_rfc821);
|
meillo@10
|
414 gboolean parse_address_rfc822(gchar * string, gchar ** local_begin, gchar ** local_end, gchar ** domain_begin, gchar ** domain_end, gchar ** address_end);
|
meillo@10
|
415 gboolean parse_address_rfc821(gchar * string, gchar ** local_begin, gchar ** local_end, gchar ** domain_begin, gchar ** domain_end, gchar ** address_end);
|
meillo@10
|
416 address *_create_address(gchar * string, gchar ** end, gboolean is_rfc821);
|
meillo@10
|
417 address *create_address_rfc821(gchar * string, gchar ** end);
|
meillo@10
|
418 address *create_address_rfc822(gchar * string, gchar ** end);
|
meillo@10
|
419 GList *addr_list_append_rfc822(GList * addr_list, gchar * string, gchar * domain);
|
meillo@0
|
420
|
meillo@0
|
421 /* connect.c */
|
meillo@10
|
422 mxip_addr *connect_hostlist(int *psockfd, gchar * host, guint port, GList * addr_list);
|
meillo@10
|
423 mxip_addr *connect_resolvelist(int *psockfd, gchar * host, guint port, GList * res_funcs);
|
meillo@0
|
424
|
meillo@0
|
425 /* deliver.c */
|
meillo@10
|
426 void msg_rcptlist_local(GList * rcpt_list, GList **, GList **);
|
meillo@10
|
427 gboolean deliver_local(msg_out * msgout);
|
meillo@10
|
428 gboolean deliver_msglist_host(connect_route * route, GList * msg_list, gchar * host, GList * res_list);
|
meillo@10
|
429 gboolean deliver_route_msgout_list(connect_route * route, GList * msgout_list);
|
meillo@10
|
430 gboolean deliver_route_msg_list(connect_route * route, GList * msgout_list);
|
meillo@10
|
431 gboolean deliver_finish(msg_out * msgout);
|
meillo@10
|
432 gboolean deliver_finish_list(GList * msgout_list);
|
meillo@10
|
433 gboolean deliver_msg_list(GList * msg_list, guint flags);
|
meillo@10
|
434 gboolean deliver(message * msg);
|
meillo@0
|
435
|
meillo@0
|
436 /* fail_msg.c */
|
meillo@10
|
437 gboolean fail_msg(message * msg, gchar * template, GList * failed_rcpts, gchar * err_fmt, va_list args);
|
meillo@10
|
438 gboolean warn_msg(message * msg, gchar * template, GList * failed_rcpts, gchar * err_fmt, va_list args);
|
meillo@0
|
439
|
meillo@0
|
440 /* interface.c */
|
meillo@10
|
441 gboolean init_sockaddr(struct sockaddr_in *name, interface * iface);
|
meillo@10
|
442 int make_server_socket(interface * iface);
|
meillo@0
|
443
|
meillo@0
|
444 /* local.c */
|
meillo@10
|
445 gboolean append_file(message * msg, GList * hdr_list, gchar * user);
|
meillo@10
|
446 gboolean pipe_out(message * msg, GList * hdr_list, address * rcpt, gchar * cmd, guint flags);
|
meillo@0
|
447
|
meillo@0
|
448 /* log.c */
|
meillo@0
|
449 gchar *ext_strerror(int err);
|
meillo@0
|
450 gboolean logopen(void);
|
meillo@0
|
451 void logclose(void);
|
meillo@0
|
452 void vlogwrite(int pri, const char *fmt, va_list args);
|
meillo@0
|
453 void logwrite(int pri, const char *fmt, ...);
|
meillo@0
|
454 void debugf(const char *fmt, ...);
|
meillo@0
|
455 void vdebugf(const char *fmt, va_list args);
|
meillo@0
|
456 void maillog(const char *fmt, ...);
|
meillo@0
|
457
|
meillo@0
|
458 /* spool.c */
|
meillo@10
|
459 gboolean spool_read_data(message * msg);
|
meillo@10
|
460 message *msg_spool_read(gchar * uid, gboolean do_readdata);
|
meillo@10
|
461 gboolean spool_write(message * msg, gboolean do_writedata);
|
meillo@10
|
462 gboolean spool_lock(gchar * uid);
|
meillo@10
|
463 gboolean spool_unlock(gchar * uid);
|
meillo@10
|
464 gboolean spool_delete_all(message * msg);
|
meillo@0
|
465
|
meillo@0
|
466 /* queue.c */
|
meillo@0
|
467 GList *read_queue(gboolean do_readdata);
|
meillo@0
|
468 gboolean queue_run(void);
|
meillo@0
|
469 gboolean queue_run_online(void);
|
meillo@0
|
470 void queue_list(void);
|
meillo@10
|
471 gboolean queue_delete(gchar * uid);
|
meillo@0
|
472
|
meillo@0
|
473 /* online.c */
|
meillo@310
|
474 gchar *online_query();
|
meillo@0
|
475
|
meillo@0
|
476 /* permissions.c */
|
meillo@0
|
477 gboolean is_ingroup(uid_t uid, gid_t gid);
|
meillo@10
|
478 void set_euidgid(gint uid, gint gid, uid_t * old_uid, gid_t * old_gid);
|
meillo@10
|
479 void set_identity(uid_t old_uid, gchar * task_name);
|
meillo@0
|
480
|
meillo@0
|
481 /* rewrite.c */
|
meillo@10
|
482 gboolean set_address_header_domain(header * hdr, gchar * domain);
|
meillo@10
|
483 gboolean map_address_header(header * hdr, GList * table);
|
meillo@0
|
484
|
meillo@0
|
485 /* route.c */
|
meillo@10
|
486 msgout_perhost *create_msgout_perhost(gchar * host);
|
meillo@10
|
487 void destroy_msgout_perhost(msgout_perhost * mo_ph);
|
meillo@10
|
488 void rewrite_headers(msg_out * msgout, connect_route * route);
|
meillo@237
|
489 void split_rcpts(GList* rcpt_list, GList* localnets, GList** rl_local, GList** rl_localnet, GList** rl_others);
|
meillo@10
|
490 gboolean route_strip_msgout(connect_route * route, msg_out * msgout);
|
meillo@10
|
491 msg_out *route_prepare_msgout(connect_route * route, msg_out * msgout);
|
meillo@10
|
492 GList *route_msgout_list(connect_route * route, GList * msgout_list);
|
meillo@317
|
493 gboolean route_sender_is_allowed(connect_route * route, address * ret_path);
|
meillo@317
|
494 void route_split_rcpts(connect_route * route, GList * rcpt_list, GList ** p_rcpt_list, GList ** p_non_rcpt_list);
|
meillo@0
|
495
|
meillo@0
|
496 /* tables.c */
|
meillo@10
|
497 table_pair *create_pair(gchar * key, gpointer value);
|
meillo@10
|
498 table_pair *create_pair_string(gchar * key, gpointer value);
|
meillo@10
|
499 table_pair *parse_table_pair(gchar * line, char delim);
|
meillo@10
|
500 gpointer *table_find_func(GList * table_list, gchar * key, int (*cmp_func) (const char *, const char *));
|
meillo@10
|
501 gpointer *table_find(GList * table_list, gchar * key);
|
meillo@10
|
502 gpointer *table_find_case(GList * table_list, gchar * key);
|
meillo@10
|
503 gpointer *table_find_fnmatch(GList * table_list, gchar * key);
|
meillo@10
|
504 GList *table_read(gchar * fname, gchar delim);
|
meillo@10
|
505 void destroy_table(GList * table);
|
meillo@0
|
506
|
meillo@0
|
507 /* timeival.c */
|
meillo@254
|
508 gint time_interval(gchar * str);
|
meillo@0
|
509
|
meillo@0
|
510 /* permissions.c */
|
meillo@0
|
511 gboolean is_privileged_user(uid_t uid);
|
meillo@0
|
512
|
meillo@0
|
513 /* other things */
|
meillo@0
|
514
|
meillo@0
|
515 #define foreach(list, node)\
|
meillo@0
|
516 for((node) = g_list_first(list);\
|
meillo@0
|
517 (node);\
|
meillo@0
|
518 (node) = g_list_next(node))
|
meillo@0
|
519
|
meillo@0
|
520 #ifdef ENABLE_DEBUG
|
meillo@0
|
521 #define DEBUG(level) if(level <= conf.debug_level)
|
meillo@0
|
522 #else
|
meillo@0
|
523 /* hopefully the compiler optmizes this away... */
|
meillo@0
|
524 #define DEBUG(level) if(0)
|
meillo@0
|
525 #endif
|
meillo@0
|
526
|
meillo@0
|
527 #define LOG_VERBOSE 0x100
|
meillo@0
|
528
|
meillo@0
|
529 #ifndef HAVE_GETLINE
|
meillo@0
|
530 #define getline(buf, size, file) getdelim(buf, size, '\n', file)
|
meillo@0
|
531 #endif
|
meillo@0
|
532
|
meillo@0
|
533 #ifndef HAVE_FDATASYNC
|
meillo@0
|
534 #define fdatasync(fd) fsync(fd)
|
meillo@0
|
535 #endif
|
meillo@0
|
536
|
meillo@0
|
537 #ifndef CONF_DIR
|
meillo@0
|
538 #define CONF_DIR "/etc/masqmail"
|
meillo@0
|
539 #endif
|
meillo@0
|
540
|
meillo@0
|
541 #define CONF_FILE CONF_DIR"/masqmail.conf"
|
meillo@0
|
542
|
meillo@0
|
543 #define PIDFILEDIR "/var/run/masqmail/"
|
meillo@0
|
544
|
meillo@0
|
545 #ifndef va_copy
|
meillo@0
|
546 #ifdef __va_copy
|
meillo@0
|
547 #define va_copy(ap1, ap2) __va_copy(ap1, ap2)
|
meillo@0
|
548 #else
|
meillo@0
|
549 #define va_copy(ap1, ap2) G_VA_COPY(ap1, ap2)
|
meillo@0
|
550 #endif
|
meillo@0
|
551 #endif
|
meillo@0
|
552
|
meillo@0
|
553 /* *BSD needs this: */
|
meillo@0
|
554 extern char **environ;
|