Commit | Line | Data |
---|---|---|
0756eb3c PH |
1 | /* $Cambridge: exim/src/src/routers/accept.c,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */ |
2 | ||
3 | /************************************************* | |
4 | * Exim - an Internet mail transport agent * | |
5 | *************************************************/ | |
6 | ||
7 | /* Copyright (c) University of Cambridge 1995 - 2004 */ | |
8 | /* See the file NOTICE for conditions of use and distribution. */ | |
9 | ||
10 | ||
11 | #include "../exim.h" | |
12 | #include "rf_functions.h" | |
13 | #include "accept.h" | |
14 | ||
15 | ||
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. */ | |
18 | ||
19 | optionlist accept_router_options[] = { | |
20 | { "", opt_hidden, NULL } | |
21 | }; | |
22 | ||
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. */ | |
25 | ||
26 | int accept_router_options_count = | |
27 | sizeof(accept_router_options)/sizeof(optionlist); | |
28 | ||
29 | /* Default private options block for the accept router. Again, a dummy | |
30 | value is used. */ | |
31 | ||
32 | accept_router_options_block accept_router_option_defaults = { | |
33 | NULL /* dummy */ | |
34 | }; | |
35 | ||
36 | ||
37 | ||
38 | /************************************************* | |
39 | * Initialization entry point * | |
40 | *************************************************/ | |
41 | ||
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. */ | |
44 | ||
45 | void accept_router_init(router_instance *rblock) | |
46 | { | |
47 | /* | |
48 | accept_router_options_block *ob = | |
49 | (accept_router_options_block *)(rblock->options_block); | |
50 | */ | |
51 | ||
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. */ | |
54 | ||
55 | if (rblock->log_as_local == TRUE_UNSET) rblock->log_as_local = TRUE; | |
56 | } | |
57 | ||
58 | ||
59 | ||
60 | /************************************************* | |
61 | * Main entry point * | |
62 | *************************************************/ | |
63 | ||
64 | /* See local README for interface description. This router returns: | |
65 | ||
66 | DEFER | |
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) | |
74 | ||
75 | OK | |
76 | added address to addr_local or addr_remote, as appropriate for the | |
77 | type of transport | |
78 | */ | |
79 | ||
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 */ | |
89 | { | |
90 | /* | |
91 | accept_router_options_block *ob = | |
92 | (accept_router_options_block *)(rblock->options_block); | |
93 | */ | |
94 | int rc; | |
95 | uschar *errors_to; | |
96 | uschar *remove_headers; | |
97 | header_line *extra_headers; | |
98 | ||
99 | addr_new = addr_new; /* Keep picky compilers happy */ | |
100 | addr_succeed = addr_succeed; | |
101 | ||
102 | DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n", | |
103 | rblock->name, addr->address, addr->domain); | |
104 | ||
105 | /* Set up the errors address, if any. */ | |
106 | ||
107 | rc = rf_get_errors_address(addr, rblock, verify, &errors_to); | |
108 | if (rc != OK) return rc; | |
109 | ||
110 | /* Set up the additional and removeable headers for the address. */ | |
111 | ||
112 | rc = rf_get_munge_headers(addr, rblock, &extra_headers, &remove_headers); | |
113 | if (rc != OK) return rc; | |
114 | ||
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 | |
117 | verifying. */ | |
118 | ||
119 | if (!rf_get_transport(rblock->transport_name, &(rblock->transport), | |
120 | addr, rblock->name, NULL)) return DEFER; | |
121 | ||
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; | |
126 | ||
127 | return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)? OK : DEFER; | |
128 | } | |
129 | ||
130 | /* End of routers/accept.c */ |