1
/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.13 2005/06/27 15:11:04 tom Exp $ */
1
3
/*************************************************
2
4
* Exim - an Internet mail transport agent *
3
5
*************************************************/
5
/* Copyright (c) University of Cambridge 1995 - 2004 */
7
/* Copyright (c) University of Cambridge 1995 - 2005 */
6
8
/* See the file NOTICE for conditions of use and distribution. */
39
41
(void *)offsetof(redirect_router_options_block, file_transport_name) },
40
42
{ "forbid_blackhole", opt_bit | (RDON_BLACKHOLE << 16),
41
43
(void *)offsetof(redirect_router_options_block, bit_options) },
44
{ "forbid_exim_filter", opt_bit | (RDON_EXIM_FILTER << 16),
45
(void *)offsetof(redirect_router_options_block, bit_options) },
42
46
{ "forbid_file", opt_bool,
43
47
(void *)offsetof(redirect_router_options_block, forbid_file) },
48
{ "forbid_filter_dlfunc", opt_bit | (RDON_DLFUNC << 16),
49
(void *)offsetof(redirect_router_options_block, bit_options) },
44
50
{ "forbid_filter_existstest", opt_bit | (RDON_EXISTS << 16),
45
51
(void *)offsetof(redirect_router_options_block, bit_options) },
46
52
{ "forbid_filter_logwrite",opt_bit | (RDON_LOG << 16),
47
53
(void *)offsetof(redirect_router_options_block, bit_options) },
48
54
{ "forbid_filter_lookup", opt_bit | (RDON_LOOKUP << 16),
49
55
(void *)offsetof(redirect_router_options_block, bit_options) },
51
56
{ "forbid_filter_perl", opt_bit | (RDON_PERL << 16),
52
57
(void *)offsetof(redirect_router_options_block, bit_options) },
54
58
{ "forbid_filter_readfile", opt_bit | (RDON_READFILE << 16),
55
59
(void *)offsetof(redirect_router_options_block, bit_options) },
56
60
{ "forbid_filter_readsocket", opt_bit | (RDON_READSOCK << 16),
63
67
(void *)offsetof(redirect_router_options_block, bit_options) },
64
68
{ "forbid_pipe", opt_bool,
65
69
(void *)offsetof(redirect_router_options_block, forbid_pipe) },
70
{ "forbid_sieve_filter",opt_bit | (RDON_SIEVE_FILTER << 16),
71
(void *)offsetof(redirect_router_options_block, bit_options) },
66
72
{ "hide_child_in_errmsg", opt_bool,
67
73
(void *)offsetof(redirect_router_options_block, hide_child_in_errmsg) },
68
74
{ "ignore_eacces", opt_bit | (RDON_EACCES << 16),
91
97
(void *)offsetof(redirect_router_options_block, reply_transport_name) },
92
98
{ "rewrite", opt_bit | (RDON_REWRITE << 16),
93
99
(void *)offsetof(redirect_router_options_block, bit_options) },
100
{ "sieve_subaddress", opt_stringptr,
101
(void *)offsetof(redirect_router_options_block, sieve_subaddress) },
102
{ "sieve_useraddress", opt_stringptr,
103
(void *)offsetof(redirect_router_options_block, sieve_useraddress) },
104
{ "sieve_vacation_directory", opt_stringptr,
105
(void *)offsetof(redirect_router_options_block, sieve_vacation_directory) },
94
106
{ "skip_syntax_errors", opt_bool,
95
107
(void *)offsetof(redirect_router_options_block, skip_syntax_errors) },
108
#ifdef EXPERIMENTAL_SRS
109
{ "srs", opt_stringptr,
110
(void *)offsetof(redirect_router_options_block, srs) },
111
{ "srs_alias", opt_stringptr,
112
(void *)offsetof(redirect_router_options_block, srs_alias) },
113
{ "srs_condition", opt_stringptr,
114
(void *)offsetof(redirect_router_options_block, srs_condition) },
115
{ "srs_dbinsert", opt_stringptr,
116
(void *)offsetof(redirect_router_options_block, srs_dbinsert) },
117
{ "srs_dbselect", opt_stringptr,
118
(void *)offsetof(redirect_router_options_block, srs_dbselect) },
96
120
{ "syntax_errors_text", opt_stringptr,
97
121
(void *)offsetof(redirect_router_options_block, syntax_errors_text) },
98
122
{ "syntax_errors_to", opt_stringptr,
120
144
NULL, /* include_directory */
121
145
NULL, /* pipe_transport_name */
122
146
NULL, /* reply_transport_name */
147
NULL, /* sieve_subaddress */
148
NULL, /* sieve_useraddress */
149
NULL, /* sieve_vacation_directory */
123
150
NULL, /* syntax_errors_text */
124
151
NULL, /* syntax_errors_to */
125
152
NULL, /* qualify_domain */
126
153
NULL, /* owners */
127
154
NULL, /* owngroups */
155
#ifdef EXPERIMENTAL_SRS
157
NULL, /* srs_alias */
158
NULL, /* srs_condition */
159
NULL, /* srs_dbinsert */
160
NULL, /* srs_dbselect */
128
162
022, /* modemask */
129
163
RDO_REWRITE, /* bit_options */
130
164
FALSE, /* check_ancestor */
160
194
"%sone of \"file\" or \"data\" must be specified",
161
195
rblock->name, (ob->file == NULL)? "" : "only ");
163
/* Onetime aliases can only be real addresses. Headers can't be manipulated. */
197
/* Onetime aliases can only be real addresses. Headers can't be manipulated.
198
The combination of one_time and unseen is not allowed. We can't check the
199
expansion of "unseen" here, but we assume that if it is set to anything other
200
than false, there is likely to be a problem. */
165
202
if (ob->one_time)
169
206
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s router:\n "
170
207
"\"headers_add\" and \"headers_remove\" are not permitted with "
171
208
"\"one_time\"", rblock->name);
209
if (rblock->unseen || rblock->expand_unseen != NULL)
210
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s router:\n "
211
"\"unseen\" may not be used with \"one_time\"", rblock->name);
174
214
/* The defaults for check_owner and check_group depend on other settings. The
517
561
ugid.gid_set = TRUE;
564
#ifdef EXPERIMENTAL_SRS
565
/* Perform SRS on recipient/return-path as required */
571
if(ob->srs_condition != NULL)
572
usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL);
576
int srs_action = 0, n_srs;
580
/* What are we doing? */
581
if(Ustrcmp(ob->srs, "forward") == 0)
583
else if(Ustrcmp(ob->srs, "reverseandforward") == 0)
587
if((ob->srs_dbinsert == NULL) ^ (ob->srs_dbselect == NULL))
590
else if(Ustrcmp(ob->srs, "reverse") == 0)
596
srs_orig_recipient = addr->address;
600
eximsrs_db_set(TRUE, ob->srs_dbselect);
601
/* Comment this out for now...
603
// eximsrs_db_set(TRUE, NULL);
606
if((n_srs = eximsrs_reverse(&res, addr->address)) == OK)
610
debug_printf("SRS (reverse): Recipient '%s' rewritten to '%s'\n", srs_orig_recipient, srs_recipient);
620
/* No point in actually performing SRS if we are just verifying a recipient */
621
if((srs_action & 1) && !verify && (sender_address ? sender_address[0] != 0 : FALSE))
624
srs_orig_sender = sender_address;
627
eximsrs_db_set(FALSE, ob->srs_dbinsert);
628
/* Comment this out for now...
630
// eximsrs_db_set(FALSE, NULL);
633
if(ob->srs_alias != NULL ? (usedomain = expand_string(ob->srs_alias)) == NULL : 1)
634
usedomain = deliver_domain;
636
if((n_srs = eximsrs_forward(&res, sender_address, usedomain)) == OK)
638
addr_prop.srs_sender = res;
640
debug_printf("SRS (forward): Sender '%s' rewritten to '%s'\n", srs_orig_sender, res);
520
652
/* Call the function that interprets redirection data, either inline or from a
521
653
file. This is a separate function so that the system filter can use it. It will
522
654
run the function in a subprocess if necessary. If qualify_preserve_domain is
551
683
redirect.isfile = FALSE;
554
frc = rda_interpret(&redirect, options, ob->include_directory, &ugid,
555
&generated, &(addr->message), ob->skip_syntax_errors? &eblock : NULL,
686
frc = rda_interpret(&redirect, options, ob->include_directory,
687
ob->sieve_vacation_directory, ob->sieve_useraddress, ob->sieve_subaddress,
688
&ugid, &generated, &(addr->message), ob->skip_syntax_errors? &eblock : NULL,
556
689
&filtertype, string_sprintf("%s router (recipient is %s)", rblock->name,
587
720
if ((xrc = sort_errors_and_headers(rblock, addr, verify, &addr_prop)) != OK)
589
722
add_generated(rblock, addr_new, addr, generated, &addr_prop, &ugid, pw);
590
if (addr->message == NULL) addr->message = US"forced rejection";
591
else addr->user_message = addr->message;
723
if (addr->message == NULL)
724
addr->message = US"forced rejection";
727
addr->user_message = addr->message;
728
setflag(addr, af_pass_message);
594
732
/* As in the case of a system filter, a freeze does not happen after a manual