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