1 /* $Cambridge: exim/src/src/routers/accept.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */
3 /*************************************************
4 * Exim - an Internet mail transport agent *
5 *************************************************/
7 /* Copyright (c) University of Cambridge 1995 - 2005 */
8 /* See the file NOTICE for conditions of use and distribution. */
12 #include "rf_functions.h"
16 /* Options specific to the accept router. Because some compilers do not like
17 empty declarations ("undefined" in the Standard) we put in a dummy value. */
19 optionlist accept_router_options[] = {
20 { "", opt_hidden, NULL }
23 /* Size of the options list. An extern variable has to be used so that its
24 address can appear in the tables drtables.c. */
26 int accept_router_options_count =
27 sizeof(accept_router_options)/sizeof(optionlist);
29 /* Default private options block for the accept router. Again, a dummy
32 accept_router_options_block accept_router_option_defaults = {
38 /*************************************************
39 * Initialization entry point *
40 *************************************************/
42 /* Called for each instance, after its options have been read, to enable
43 consistency checks to be done, or anything else that needs to be set up. */
45 void accept_router_init(router_instance *rblock)
48 accept_router_options_block *ob =
49 (accept_router_options_block *)(rblock->options_block);
52 /* By default, log deliveries via this router as local deliveries. We can't
53 just leave it as TRUE_UNSET, because the global default is FALSE. */
55 if (rblock->log_as_local == TRUE_UNSET) rblock->log_as_local = TRUE;
60 /*************************************************
62 *************************************************/
64 /* See local README for interface description. This router returns:
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)
76 added address to addr_local or addr_remote, as appropriate for the
80 int 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 */
91 accept_router_options_block *ob =
92 (accept_router_options_block *)(rblock->options_block);
96 uschar *remove_headers;
97 header_line *extra_headers;
99 addr_new = addr_new; /* Keep picky compilers happy */
100 addr_succeed = addr_succeed;
102 DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
103 rblock->name, addr->address, addr->domain);
105 /* Set up the errors address, if any. */
107 rc = rf_get_errors_address(addr, rblock, verify, &errors_to);
108 if (rc != OK) return rc;
110 /* Set up the additional and removeable headers for the address. */
112 rc = rf_get_munge_headers(addr, rblock, &extra_headers, &remove_headers);
113 if (rc != OK) return rc;
115 /* Set the transport and accept the address; update its errors address and
116 header munging. Initialization ensures that there is a transport except when
119 if (!rf_get_transport(rblock->transport_name, &(rblock->transport),
120 addr, rblock->name, NULL)) return DEFER;
122 addr->transport = rblock->transport;
123 addr->p.errors_address = errors_to;
124 addr->p.extra_headers = extra_headers;
125 addr->p.remove_headers = remove_headers;
127 return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)? OK : DEFER;
130 /* End of routers/accept.c */