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