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