~ubuntu-branches/ubuntu/hardy/exim4/hardy-proposed

« back to all changes in this revision

Viewing changes to src/routers/redirect.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Haber
  • Date: 2005-07-02 06:08:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050702060834-qk17pd52kb9nt3bj
Tags: 4.52-1
* new upstream version 4.51. (mh)
  * adapt 70_remove_exim-users_references
  * remove 37_gnutlsparams
  * adapt 36_pcre
  * adapt 31_eximmanpage
* fix package priorities to have them in sync with override again. (mh)
* Fix error in nb (Norwegian) translation.
  Thanks to Helge Hafting. (mh). Closes: #315775
* Standards-Version: 3.6.2, no changes needed. (mh)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.13 2005/06/27 15:11:04 tom Exp $ */
 
2
 
1
3
/*************************************************
2
4
*     Exim - an Internet mail transport agent    *
3
5
*************************************************/
4
6
 
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. */
7
9
 
8
10
 
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) },
50
 
  #ifdef EXIM_PERL
51
56
  { "forbid_filter_perl", opt_bit | (RDON_PERL << 16),
52
57
      (void *)offsetof(redirect_router_options_block, bit_options) },
53
 
  #endif
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) },
 
119
#endif
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
 
156
  NULL,        /* srs */
 
157
  NULL,        /* srs_alias */
 
158
  NULL,        /* srs_condition */
 
159
  NULL,        /* srs_dbinsert */
 
160
  NULL,        /* srs_dbselect */
 
161
#endif
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 ");
162
196
 
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. */
164
201
 
165
202
if (ob->one_time)
166
203
  {
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);
172
212
  }
173
213
 
174
214
/* The defaults for check_owner and check_group depend on other settings. The
492
532
addr_prop.extra_headers = NULL;
493
533
addr_prop.remove_headers = NULL;
494
534
 
 
535
#ifdef EXPERIMENTAL_SRS
 
536
addr_prop.srs_sender = NULL;
 
537
#endif
 
538
 
495
539
/* When verifying and testing addresses, the "logwrite" command in filters
496
540
must be bypassed. */
497
541
 
517
561
  ugid.gid_set = TRUE;
518
562
  }
519
563
 
 
564
#ifdef EXPERIMENTAL_SRS
 
565
  /* Perform SRS on recipient/return-path as required  */
 
566
 
 
567
  if(ob->srs != NULL)
 
568
  {
 
569
    BOOL usesrs = TRUE;
 
570
 
 
571
    if(ob->srs_condition != NULL)
 
572
      usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL);
 
573
 
 
574
    if(usesrs)
 
575
    {
 
576
      int srs_action = 0, n_srs;
 
577
      uschar *res;
 
578
      uschar *usedomain;
 
579
 
 
580
      /* What are we doing? */
 
581
      if(Ustrcmp(ob->srs, "forward") == 0)
 
582
        srs_action = 1;
 
583
      else if(Ustrcmp(ob->srs, "reverseandforward") == 0)
 
584
      {
 
585
        srs_action = 3;
 
586
 
 
587
        if((ob->srs_dbinsert == NULL) ^ (ob->srs_dbselect == NULL))
 
588
          return DEFER;
 
589
      }
 
590
      else if(Ustrcmp(ob->srs, "reverse") == 0)
 
591
        srs_action = 2;
 
592
 
 
593
      /* Reverse SRS */
 
594
      if(srs_action & 2)
 
595
      {
 
596
        srs_orig_recipient = addr->address;
 
597
 
 
598
        eximsrs_init();
 
599
        if(ob->srs_dbselect)
 
600
          eximsrs_db_set(TRUE, ob->srs_dbselect);
 
601
/* Comment this out for now...
 
602
//        else
 
603
//          eximsrs_db_set(TRUE, NULL);
 
604
*/
 
605
 
 
606
        if((n_srs = eximsrs_reverse(&res, addr->address)) == OK)
 
607
        {
 
608
          srs_recipient = res;
 
609
          DEBUG(D_any)
 
610
            debug_printf("SRS (reverse): Recipient '%s' rewritten to '%s'\n", srs_orig_recipient, srs_recipient);
 
611
        }
 
612
 
 
613
        eximsrs_done();
 
614
 
 
615
        if(n_srs != OK)
 
616
          return n_srs;
 
617
      }
 
618
 
 
619
      /* Forward SRS */
 
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))
 
622
      {
 
623
 
 
624
        srs_orig_sender = sender_address;
 
625
        eximsrs_init();
 
626
        if(ob->srs_dbinsert)
 
627
          eximsrs_db_set(FALSE, ob->srs_dbinsert);
 
628
/* Comment this out for now...
 
629
//        else
 
630
//          eximsrs_db_set(FALSE, NULL);
 
631
*/
 
632
 
 
633
        if(ob->srs_alias != NULL ? (usedomain = expand_string(ob->srs_alias)) == NULL : 1)
 
634
          usedomain = deliver_domain;
 
635
 
 
636
        if((n_srs = eximsrs_forward(&res, sender_address, usedomain)) == OK)
 
637
        {
 
638
          addr_prop.srs_sender = res;
 
639
          DEBUG(D_any)
 
640
            debug_printf("SRS (forward): Sender '%s' rewritten to '%s'\n", srs_orig_sender, res);
 
641
        }
 
642
 
 
643
        eximsrs_done();
 
644
 
 
645
        if(n_srs != OK)
 
646
          return n_srs;
 
647
      }
 
648
    }
 
649
  }
 
650
#endif
 
651
 
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;
552
684
  }
553
685
 
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,
557
690
  addr->address));
558
691
 
587
720
  if ((xrc = sort_errors_and_headers(rblock, addr, verify, &addr_prop)) != OK)
588
721
    return xrc;
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";
 
725
  else
 
726
    {
 
727
    addr->user_message = addr->message;
 
728
    setflag(addr, af_pass_message);
 
729
    }
592
730
  return FAIL;
593
731
 
594
732
  /* As in the case of a system filter, a freeze does not happen after a manual