Merge branch 'debian'
[hcoop/debian/exim4.git] / src / routers / accept.c
CommitLineData
420a0d19
CE
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
2ea97746 5/* Copyright (c) University of Cambridge 1995 - 2018 */
420a0d19
CE
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
2ea97746
CE
35#ifdef MACRO_PREDEF
36
37/* Dummy entries */
38void accept_router_init(router_instance *rblock) {}
39int accept_router_entry(router_instance *rblock, address_item *addr,
40 struct passwd *pw, int verify, address_item **addr_local,
41 address_item **addr_remote, address_item **addr_new,
42 address_item **addr_succeed) {return 0;}
43
44#else /*!MACRO_PREDEF*/
45
46
420a0d19
CE
47
48/*************************************************
49* Initialization entry point *
50*************************************************/
51
52/* Called for each instance, after its options have been read, to enable
53consistency checks to be done, or anything else that needs to be set up. */
54
55void accept_router_init(router_instance *rblock)
56{
57/*
58accept_router_options_block *ob =
59 (accept_router_options_block *)(rblock->options_block);
60*/
61
62/* By default, log deliveries via this router as local deliveries. We can't
63just leave it as TRUE_UNSET, because the global default is FALSE. */
64
65if (rblock->log_as_local == TRUE_UNSET) rblock->log_as_local = TRUE;
66}
67
68
69
70/*************************************************
71* Main entry point *
72*************************************************/
73
74/* See local README for interface description. This router returns:
75
76DEFER
77 . verifying the errors address caused a deferment or a big disaster such
78 as an expansion failure (rf_get_errors_address)
79 . expanding a headers_{add,remove} string caused a deferment or another
80 expansion error (rf_get_munge_headers)
81 . a problem in rf_get_transport: no transport when one is needed;
82 failed to expand dynamic transport; failed to find dynamic transport
83 . failure to expand or find a uid/gid (rf_get_ugid via rf_queue_add)
84
85OK
86 added address to addr_local or addr_remote, as appropriate for the
87 type of transport
88*/
89
90int accept_router_entry(
91 router_instance *rblock, /* data for this instantiation */
92 address_item *addr, /* address we are working on */
93 struct passwd *pw, /* passwd entry after check_local_user */
94 int verify, /* v_none/v_recipient/v_sender/v_expn */
95 address_item **addr_local, /* add it to this if it's local */
96 address_item **addr_remote, /* add it to this if it's remote */
97 address_item **addr_new, /* put new addresses on here */
98 address_item **addr_succeed) /* put old address here on success */
99{
100/*
101accept_router_options_block *ob =
102 (accept_router_options_block *)(rblock->options_block);
103*/
104int rc;
105uschar *errors_to;
106uschar *remove_headers;
107header_line *extra_headers;
108
109addr_new = addr_new; /* Keep picky compilers happy */
110addr_succeed = addr_succeed;
111
112DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
113 rblock->name, addr->address, addr->domain);
114
115/* Set up the errors address, if any. */
116
117rc = rf_get_errors_address(addr, rblock, verify, &errors_to);
118if (rc != OK) return rc;
119
2ea97746 120/* Set up the additional and removable headers for the address. */
420a0d19
CE
121
122rc = rf_get_munge_headers(addr, rblock, &extra_headers, &remove_headers);
123if (rc != OK) return rc;
124
125/* Set the transport and accept the address; update its errors address and
126header munging. Initialization ensures that there is a transport except when
127verifying. */
128
129if (!rf_get_transport(rblock->transport_name, &(rblock->transport),
130 addr, rblock->name, NULL)) return DEFER;
131
132addr->transport = rblock->transport;
2ea97746
CE
133addr->prop.errors_address = errors_to;
134addr->prop.extra_headers = extra_headers;
135addr->prop.remove_headers = remove_headers;
420a0d19
CE
136
137return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)? OK : DEFER;
138}
139
2ea97746 140#endif /*!MACRO_PREDEF*/
420a0d19 141/* End of routers/accept.c */