Start
[exim.git] / src / src / routers / accept.c
CommitLineData
0756eb3c
PH
1/* $Cambridge: exim/src/src/routers/accept.c,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
7/* Copyright (c) University of Cambridge 1995 - 2004 */
8/* See the file NOTICE for conditions of use and distribution. */
9
10
11#include "../exim.h"
12#include "rf_functions.h"
13#include "accept.h"
14
15
16/* Options specific to the accept router. Because some compilers do not like
17empty declarations ("undefined" in the Standard) we put in a dummy value. */
18
19optionlist accept_router_options[] = {
20 { "", opt_hidden, NULL }
21};
22
23/* Size of the options list. An extern variable has to be used so that its
24address can appear in the tables drtables.c. */
25
26int accept_router_options_count =
27 sizeof(accept_router_options)/sizeof(optionlist);
28
29/* Default private options block for the accept router. Again, a dummy
30value is used. */
31
32accept_router_options_block accept_router_option_defaults = {
33 NULL /* dummy */
34};
35
36
37
38/*************************************************
39* Initialization entry point *
40*************************************************/
41
42/* Called for each instance, after its options have been read, to enable
43consistency checks to be done, or anything else that needs to be set up. */
44
45void accept_router_init(router_instance *rblock)
46{
47/*
48accept_router_options_block *ob =
49 (accept_router_options_block *)(rblock->options_block);
50*/
51
52/* By default, log deliveries via this router as local deliveries. We can't
53just leave it as TRUE_UNSET, because the global default is FALSE. */
54
55if (rblock->log_as_local == TRUE_UNSET) rblock->log_as_local = TRUE;
56}
57
58
59
60/*************************************************
61* Main entry point *
62*************************************************/
63
64/* See local README for interface description. This router returns:
65
66DEFER
67 . verifying the errors address caused a deferment or a big disaster such
68 as an expansion failure (rf_get_errors_address)
69 . expanding a headers_{add,remove} string caused a deferment or another
70 expansion error (rf_get_munge_headers)
71 . a problem in rf_get_transport: no transport when one is needed;
72 failed to expand dynamic transport; failed to find dynamic transport
73 . failure to expand or find a uid/gid (rf_get_ugid via rf_queue_add)
74
75OK
76 added address to addr_local or addr_remote, as appropriate for the
77 type of transport
78*/
79
80int accept_router_entry(
81 router_instance *rblock, /* data for this instantiation */
82 address_item *addr, /* address we are working on */
83 struct passwd *pw, /* passwd entry after check_local_user */
84 BOOL verify, /* TRUE when verifying */
85 address_item **addr_local, /* add it to this if it's local */
86 address_item **addr_remote, /* add it to this if it's remote */
87 address_item **addr_new, /* put new addresses on here */
88 address_item **addr_succeed) /* put old address here on success */
89{
90/*
91accept_router_options_block *ob =
92 (accept_router_options_block *)(rblock->options_block);
93*/
94int rc;
95uschar *errors_to;
96uschar *remove_headers;
97header_line *extra_headers;
98
99addr_new = addr_new; /* Keep picky compilers happy */
100addr_succeed = addr_succeed;
101
102DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
103 rblock->name, addr->address, addr->domain);
104
105/* Set up the errors address, if any. */
106
107rc = rf_get_errors_address(addr, rblock, verify, &errors_to);
108if (rc != OK) return rc;
109
110/* Set up the additional and removeable headers for the address. */
111
112rc = rf_get_munge_headers(addr, rblock, &extra_headers, &remove_headers);
113if (rc != OK) return rc;
114
115/* Set the transport and accept the address; update its errors address and
116header munging. Initialization ensures that there is a transport except when
117verifying. */
118
119if (!rf_get_transport(rblock->transport_name, &(rblock->transport),
120 addr, rblock->name, NULL)) return DEFER;
121
122addr->transport = rblock->transport;
123addr->p.errors_address = errors_to;
124addr->p.extra_headers = extra_headers;
125addr->p.remove_headers = remove_headers;
126
127return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)? OK : DEFER;
128}
129
130/* End of routers/accept.c */