1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2020 - 2024 */
6 /* Copyright (c) University of Cambridge 1995 - 2018 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
13 #ifdef ROUTER_ACCEPT /* Remainder of file */
14 #include "rf_functions.h"
18 /* Options specific to the accept router. Because some compilers do not like
19 empty declarations ("undefined" in the Standard) we put in a dummy value. */
21 optionlist accept_router_options[] = {
22 { "", opt_hidden, {NULL} }
25 /* Size of the options list. An extern variable has to be used so that its
26 address can appear in the tables drtables.c. */
28 int accept_router_options_count =
29 sizeof(accept_router_options)/sizeof(optionlist);
31 /* Default private options block for the accept router. Again, a dummy
34 accept_router_options_block accept_router_option_defaults = {
42 void accept_router_init(driver_instance *rblock) {}
43 int accept_router_entry(router_instance *rblock, address_item *addr,
44 struct passwd *pw, int verify, address_item **addr_local,
45 address_item **addr_remote, address_item **addr_new,
46 address_item **addr_succeed) {return 0;}
48 #else /*!MACRO_PREDEF*/
52 /*************************************************
53 * Initialization entry point *
54 *************************************************/
56 /* Called for each instance, after its options have been read, to enable
57 consistency checks to be done, or anything else that needs to be set up. */
60 accept_router_init(driver_instance * r)
62 router_instance * rblock = (router_instance *)r;
64 accept_router_options_block *ob =
65 (accept_router_options_block *)(rblock->options_block);
68 /* By default, log deliveries via this router as local deliveries. We can't
69 just leave it as TRUE_UNSET, because the global default is FALSE. */
71 if (rblock->log_as_local == TRUE_UNSET) rblock->log_as_local = TRUE;
76 /*************************************************
78 *************************************************/
80 /* See local README for interface description. This router returns:
83 . verifying the errors address caused a deferment or a big disaster such
84 as an expansion failure (rf_get_errors_address)
85 . expanding a headers_{add,remove} string caused a deferment or another
86 expansion error (rf_get_munge_headers)
87 . a problem in rf_get_transport: no transport when one is needed;
88 failed to expand dynamic transport; failed to find dynamic transport
89 . failure to expand or find a uid/gid (rf_get_ugid via rf_queue_add)
92 added address to addr_local or addr_remote, as appropriate for the
96 int accept_router_entry(
97 router_instance *rblock, /* data for this instantiation */
98 address_item *addr, /* address we are working on */
99 struct passwd *pw, /* passwd entry after check_local_user */
100 int verify, /* v_none/v_recipient/v_sender/v_expn */
101 address_item **addr_local, /* add it to this if it's local */
102 address_item **addr_remote, /* add it to this if it's remote */
103 address_item **addr_new, /* put new addresses on here */
104 address_item **addr_succeed) /* put old address here on success */
107 accept_router_options_block *ob =
108 (accept_router_options_block *)(rblock->options_block);
111 const uschar * errors_to;
112 uschar * remove_headers;
113 header_line * extra_headers;
115 DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
116 rblock->drinst.name, addr->address, addr->domain);
118 /* Set up the errors address, if any. */
120 if ((rc = rf_get_errors_address(addr, rblock, verify, &errors_to)) != OK)
123 /* Set up the additional and removable headers for the address. */
125 rc = rf_get_munge_headers(addr, rblock, &extra_headers, &remove_headers);
126 if (rc != OK) return rc;
128 /* Set the transport and accept the address; update its errors address and
129 header munging. Initialization ensures that there is a transport except when
132 if (!rf_get_transport(rblock->transport_name, &(rblock->transport),
133 addr, rblock->drinst.name, NULL)) return DEFER;
135 addr->transport = rblock->transport;
136 addr->prop.errors_address = errors_to;
137 addr->prop.extra_headers = extra_headers;
138 addr->prop.remove_headers = remove_headers;
140 return rf_queue_add(addr, addr_local, addr_remote, rblock, pw) ? OK : DEFER;
143 #endif /*!MACRO_PREDEF*/
144 #endif /*ROUTER_ACCEPT*/
146 /* End of routers/accept.c */