3 # This is a Perl script that reads an Exim run-time configuration file for
4 # Exim 3. It makes what changes it can for Exim 4, and also output commentary
5 # on what it has done, and on things it cannot do.
7 # It is assumed that the input is a valid Exim 3 configuration file.
10 # These are lists of main options which are abolished in Exim 4.
11 # The first contains options that are used to construct new options.
15 "auth_over_tls_hosts",
17 "headers_check_syntax",
18 "headers_checks_fail",
19 "headers_sender_verify",
20 "headers_sender_verify_errmsg",
22 "host_auth_accept_relay",
23 "host_reject_recipients",
25 "local_domains_include_host",
26 "local_domains_include_host_literals",
32 "log_received_sender",
33 "log_received_recipients",
35 "log_sender_on_delivery",
36 "log_smtp_confirmation",
37 "log_smtp_connections",
38 "log_smtp_syntax_errors",
40 "log_queue_run_level",
43 "rbl_reject_recipients",
45 "receiver_verify_addresses",
46 "receiver_verify_hosts",
47 "receiver_verify_senders",
48 "recipients_reject_except",
49 "recipients_reject_except_senders",
51 "relay_domains_include_local_mx",
52 "sender_address_relay",
53 "sender_address_relay_hosts",
54 "sender_reject_recipients",
56 "sender_verify_hosts_callback",
57 "sender_verify_callback_domains",
58 "sender_verify_callback_timeout",
59 "sender_verify_hosts",
63 "tls_host_accept_relay",
70 # The second contains options that are completely abolished and have
73 @abolished_options = (
79 "log_refused_recipients",
80 "message_size_limit_count_recipients",
83 "receiver_try_verify",
85 "relay_match_host_or_sender",
87 "sender_verify_batch",
88 "sender_verify_fixup",
89 "sender_verify_reject",
90 "sender_verify_max_retry_rate",
93 # This is a list of options that are not otherwise handled, but which
94 # contain domain or host lists that have to be processed so that any
95 # regular expressions are marked "not for expansion".
98 "dns_again_means_nonexist",
100 "hosts_treat_as_local",
101 "percent_hack_domains",
102 "queue_smtp_domains",
103 "helo_accept_junk_hosts",
105 "ignore_fromline_hosts",
107 "sender_unqualified_hosts",
108 "smtp_reserve_hosts",
109 "tls_advertise_hosts",
115 ##################################################
116 # Output problem rubric once #
117 ##################################################
120 return if $rubric_output;
123 "** The following comments describe problems that have been encountered\n" .
124 " while converting an Exim 3 runtime file for Exim 4. More detail can\n" .
125 " be found in the file doc/Exim4.upgrade.\n";
129 ##################################################
131 ##################################################
136 return "comment" if $line =~ /^\s*(#|$)/;
137 return "end" if $line =~ /^\s*end\s*$/i;
139 # Macros are recognized only in the first section of the file.
141 return "macro" if $prefix eq "" && $line =~ /^\s*[A-Z]/;
143 # In retry and rewrite sections, the type is always "other"
145 return "other" if $prefix eq "=retry" || $prefix eq "=rewrite";
147 # Pick out the name at the start and the rest of the line (into global
148 # variables) and return whether the start of a driver or not.
150 ($hide,$name,$rest) = $line =~ /^\s*(hide\s+|)([a-z0-9_]+)\s*(.*?)\s*$/;
152 # If $rest begins with a colon, this is a driver name
154 return "driver" if $rest =~ /^:/;
156 # If $rest begins with an = the value of the option is given explicitly;
157 # remove the = from the start. Turn "yes"/"no" into "true"/"false".
162 $rest = "true" if $rest eq "yes";
163 $rest = "false" if $rest eq "no";
166 # Otherwise we have a boolean option. Set up a "true"/"false" value.
170 if ($name =~ /^not?_/) # Recognize "no_" or "not_"
186 ##################################################
187 # Negate a list of things #
188 ##################################################
190 # Can be tricky, because there may be comment lines in the list.
191 # Also, lists may have different delimiters.
198 return $list if ! defined $list;
200 ($list) = $list =~ /^"?(.*?)"?\s*$/s; # Remove surrounding quotes
201 $list =~ s/\\\s*\n\s*//g; # Remove continuation markers
203 if ($list =~ /^(\s*<(\S)\s*)(.*)/s)
211 $list =~ s/\Q$delim$delim/>%%%%</g;
212 @split = split /\s*\Q$delim\E\s*/s, $list;
214 foreach $item (@split)
216 $item =~ s/>%%%%</$delim$delim/g;
218 if ($item =~ /^\s*#/)
220 $item =~ s/((?:^\s*#[^\n]*\n)+\s*)/$1! /mg;
221 $item =~ s/!\s*!//sg;
225 if ($item =~ /^\s*!(.*)/)
228 { $item = "! " . $item; }
232 $" = " $delim \\\n ";
233 $leadin .= " " if $leadin !~ /(^|\s)$/;
234 return "$leadin@split";
239 ##################################################
240 # Prevent regex expansion in a list of things #
241 ##################################################
243 # Can be tricky, because there may be comment lines in the list.
244 # Also, lists may have different delimiters.
246 sub no_expand_regex {
251 return $list if ! defined $list;
253 $delim = $_[1] if (defined $_[1]);
255 my($is_route_list) = $delim eq ";";
257 ($list) = $list =~ /^"?(.*?)"?\s*$/s; # Remove surrounding quotes
258 $list =~ s/\\\s*\n\s*//g; # Remove continuation markers
260 if ($list =~ /^(\s*<(\S)\s*)(.*)/s)
268 $list =~ s/\Q$delim$delim/>%%%%</g;
269 @split = split /\s*\Q$delim\E\s*/s, $list;
272 foreach $item (@split)
274 $item =~ s/>%%%%</$delim$delim/g;
277 # Fudge for route_list items
281 $item = "\\N$item"; # Only one item ...
285 $item = "\\N$item\\N";
291 "#!!# Regular expressions enclosed in \\N...\\N to avoid expansion\n"
294 $" = " $delim \\\n ";
295 $leadin .= " " if $leadin !~ /(^|\s)$/;
296 return "$leadin@split";
301 ##################################################
302 # Sort out lookups in an address list #
303 ##################################################
305 # Can be tricky, because there may be comment lines in the list.
306 # Also, lists may have different delimiters.
308 sub sort_address_list {
315 return $list if ! defined $list;
317 if ($list =~ /^"(.*?)"\s*$/s) # Remove surrounding quotes
323 $list =~ s/\\\s*\n\s*//g; # Remove continuation markers
325 if ($list =~ /^(\s*<(\S)\s*)(.*)/s)
333 $list =~ s/\Q$delim$delim/>%%%%</g;
334 @split = split /\s*\Q$delim\E\s*/s, $list;
336 foreach $item (@split)
338 $item =~ s/>%%%%</$delim$delim/g;
339 if ($item =~ /^\s*(?:partial-)?(\w+;.*)$/)
342 if ($lookup =~ /^lsearch|^dbm|^cdb|^nis[^p]/)
346 "** The Exim 3 \"$name\" option specifies an address\n" .
347 " list that includes the item\n\n" .
349 " In Exim 4 address lists, single-key lookups without a local part just\n" .
350 " look up the complete address. They don't also try the domain, as\n" .
351 " happened in Exim 3. The item has been rewritten as two items to make\n" .
352 " it behave in the same way as Exim 3, but you should check to see if\n" .
353 " this is actually what you want.\n";
355 $item = "*\@$item $delim $lookup";
360 $" = " $delim \\\n ";
361 $leadin .= " " if $leadin !~ /(^|\s)$/;
363 return $quoted? "\"$leadin@split\"" : "$leadin@split";
368 ##################################################
369 # Quote a string against expansion #
370 ##################################################
372 # Used for setting up new "domains" options
377 $s =~ s/\\(?!\s*\n)/\\\\/sg;
383 ##################################################
384 # Dequote an option string #
385 ##################################################
387 # If the original list is not quoted, do nothing.
388 # If it is quoted, just get rid of the quotes.
392 $s =~ s/^"(.*)"$/$1/s;
397 ##################################################
398 # Quote/dequote an option string #
399 ##################################################
401 # If the original list is not quoted, quote it against expansion.
402 # If it is quoted, just get rid of the quotes. Also, indent any
407 $s = ($s =~ /^"(.*)"$/s)? $1 : &expquote($s);
409 $s =~ s/\n\s{11,}/\n /g;
414 ##################################################
415 # Handle abolished driver options #
416 ##################################################
419 my($hash) = shift @_;
420 my($name) = shift @_;
423 if (defined $$hash{$abolished})
427 "** $name used the \"$abolished\" option, which no\n".
428 " longer exists. The option has been removed.\n";
429 print STDOUT "#!!# $abolished option removed\n";
430 delete $$hash{$abolished};
437 ##################################################
438 # Handle renamed driver options #
439 ##################################################
442 my($hash,$old,$new) = @_;
443 if (defined $$hash{$old})
445 print STDOUT "#!!# $old renamed $new\n";
446 $$hash{$new} = $$hash{$old};
453 ##################################################
454 # Comment on user names in require_files #
455 ##################################################
458 my($string, $name) = @_;
460 $string =~ s/::/[[[]]]/g;
461 my(@list) = split /:/, $string;
466 if ($item =~ /^\s*[\w,]+\s*$/)
472 "** A setting of require_files in the $name contains\n" .
473 " what appears to be a user name ('$item'). The ability to check files\n" .
474 " as a specific user is done differently in Exim 4. In fact, because the\n" .
475 " routers run as root, you may not need this at all.\n"
481 ##################################################
482 # Handle current and home directory #
483 ##################################################
485 sub handle_current_and_home_directory {
486 my($hash,$driver,$name) = @_;
488 for ("current_directory", "home_directory")
490 if (defined $$hash{$_} && $$hash{$_} eq "check_local_user")
492 my($article) = (substr($driver, 0, 1) eq "a")? "an" : "a";
495 "** The Exim 3 configuration contains $article '$driver' director called\n" .
496 " '$name', which set '$_' to the special value\n" .
497 " 'check_local_user'. This facility has been abolished in Exim 4 because\n" .
498 " it is no longer necessary. The setting has therefore been omitted. See\n" .
504 &renamed($hash, $_, "transport_$_");
511 ##################################################
512 # Handle batch/bsmtp for appendfile/pipe #
513 ##################################################
515 sub handle_batch_and_bsmtp{
518 if (defined $$hash{"bsmtp"})
520 if ($$hash{"bsmtp"} ne "none")
522 $$hash{"use_bsmtp"} = "true";
523 $$hash{"message_prefix"} = "\"HELO \$primary_host_name\\n\""
524 if defined $$hash{"bsmtp_helo"} && $$hash{"bsmtp_helo"} eq "true";
527 if ($$hash{"bsmtp"} eq "one")
529 delete $$hash{"batch"};
533 $$hash{"batch"} = $$hash{"bsmtp"};
536 delete $$hash{"bsmtp"};
537 delete $$hash{"bsmtp_helo"};
540 if (defined $$hash{"batch"} && $$hash{"batch"} ne "none")
542 $$hash{"batch_max"} = "100" if !defined $$hash{"batch_max"};
543 $$hash{"batch_id"} = "\$domain" if $$hash{"batch"} eq "domain";
547 $$hash{"batch_max"} = "1" if defined $$hash{"batch_max"};
549 delete $$hash{"batch"};
554 ##################################################
555 # Output one option #
556 ##################################################
559 my($hash, $key, $no_expand) = @_;
560 my($data) = $$hash{$key};
562 print STDOUT "hide " if defined $$hash{"$key-hide"};
564 # Output booleans in the form that doesn't use "="
568 print STDOUT "$key\n";
570 elsif ($data eq "false")
572 print STDOUT "no_$key\n";
578 printf STDOUT ("$key = %s\n", &no_expand_regex($data));
582 print STDOUT "$key = $data\n";
589 ##################################################
590 # Output the options for one driver #
591 ##################################################
593 # Put the "driver" option first
597 print STDOUT " driver = $$hash{'driver'}\n";
598 foreach $key (sort keys %$hash)
600 next if $key eq "driver" || $key =~ /-hide$/;
602 &outopt($hash, $key, 0);
608 ##################################################
609 # Output a rewrite or a retry line #
610 ##################################################
612 # These lines start with patterns which are now always expanded. If the
613 # pattern is a regex, arrange for it not to expand.
615 sub print_no_expand {
623 "** You have a retry or rewrite pattern that is a regular expression. Because\n" .
624 " these patterns are now always expanded, you need to be sure that the\n" .
625 " special characters in the regex are not interpreted by the expander.\n" .
626 " \\N has been inserted at the start of the regex to prevent the rest of\n" .
627 " it from being expanded.\n";
637 ##################################################
638 # Test a boolean main option #
639 ##################################################
641 # This just saves a lot of typing
644 return defined $main{$_[0]} && $main{$_[0]} eq "true";
649 ##################################################
651 ##################################################
653 print STDERR "Runtime configuration file converter for Exim release 4.\n";
655 $transport_start = $director_start = $router_start = $retry_start
656 = $rewrite_start = $auth_start = 999999;
665 $add_caseful_local_part = 0;
666 $done_dns_check_names = 0;
668 $queue_only_load_was_present = 0;
669 $deliver_queue_load_max_was_present = 0;
671 # Read the entire file into an array
676 # Remove the standard comment that appears at the end of the default
678 if ($clen > 0 && $c[$clen-1] =~ /^#\s*End of Exim configuration file\s*/i)
684 # The first pass over the input fishes out all the options settings in the
685 # main, transport, director, and router sections, and places their values in
686 # associative arrays. It also notes the starting position of all the sections.
692 for ($i = 0; $i < $clen; $i++)
694 # Change references to +allow_unknown and +warn_unknown into +include_unknown
696 if ($c[$i] =~ /\+(?:allow|warn)_unknown/)
702 "** You have used '+allow_unknown' or '+warn_unknown' in a configuration\n" .
703 " option. This has been converted to '+include_unknown', but the action\n" .
704 " is different in Exim 4, so you should review all the relevant options.\n";
707 $c[$i] =~ s/\+(?:allow|warn)_unknown/+include_unknown/g;
710 # Any reference to $errmsg_recipient is changed to $bounce_recipient
712 if ($c[$i] =~ /\$errmsg_recipient/)
718 "** References to \$errmsg_recipient have been changed to \$bounce_recipient\n";
721 $c[$i] =~ s/\$errmsg_recipient/\$bounce_recipient/g;
725 # Analyse the type of line
727 $type = &checkline($c[$i]);
728 next if $type eq "comment";
730 # Output a warning if $key is used
732 if ($c[$i] =~ /\$key/ && !$key_output)
736 "** You have used '\$key' in a configuration option. This variable does not\n" .
737 " exist in Exim 4. Instead, the value you need for your lookup will be\n" .
738 " in one of the other variables such as '\$domain' or '\$host'. You will\n" .
739 " need to edit the new configuration to sort this out.\n";
743 # Save macro definitions so we can output them first; must handle
746 if ($type eq "macro")
748 $macro_output .= "$c[$i++]\n" while $c[$i] =~ /\\\s*$|^\s*#/;
749 $macro_output .= "$c[$i]\n";
752 # Handle end of section
754 elsif ($type eq "end")
756 if ($prefix eq "=rewrite")
759 $auth_start = $i + 1;
762 elsif ($prefix eq "=retry")
764 $prefix = "=rewrite";
765 $rewrite_start = $i + 1;
767 elsif ($prefix eq "r.")
770 $retry_start = $i + 1;
772 elsif ($prefix eq "d.")
775 $router_start = $i + 1;
777 elsif ($prefix eq "t.")
780 $director_start = $i + 1;
782 elsif ($prefix eq "")
785 $transport_start = $i + 1;
789 # Handle start of a new director, router or transport driver
791 elsif ($type eq "driver" && $prefix !~ /^=/)
794 if (defined $driverlist{"$prefix$name"})
796 die "*** There are two drivers with the name \"$name\"\n";
798 $driverlist{"$prefix$name"} = $hash;
799 $first_director = $name if !defined $first_director && $prefix eq "d.";
802 # Handle definition of an option; we must pull in any continuation
803 # strings, and save the value in the current hash. Note if the option
806 elsif ($type eq "option")
810 while ($i < $clen - 1 && ($rest =~ /\\\s*$/s || $nextline =~ /^\s*#/))
812 $nextline = $c[++$i];
813 $rest .= "\n$nextline";
816 $$hash{$name} = $rest;
817 $$hash{"$name-hide"} = 1 if $hide ne "";
822 # Generate the new configuration. Start with a warning rubric.
824 print STDOUT "#!!# This file is output from the convert4r4 script, which tries\n";
825 print STDOUT "#!!# to convert Exim 3 configurations into Exim 4 configurations.\n";
826 print STDOUT "#!!# However, it is not perfect, especially with non-simple\n";
827 print STDOUT "#!!# configurations. You must check it before running it.\n";
830 # Output the macro definitions
832 if ($macro_output ne "")
834 print STDOUT "#!!# All macro definitions have been gathered here to ensure\n";
835 print STDOUT "#!!# they precede any references to them.\n\n";
836 print STDOUT "$macro_output\n";
839 # Output some default pointers to ACLs for RCPT and DATA time. If no Exim 3
840 # options that apply are set, non-restricting ACLs are generated.
842 print STDOUT "#!!# These options specify the Access Control Lists (ACLs) that\n";
843 print STDOUT "#!!# are used for incoming SMTP messages - after the RCPT and DATA\n";
844 print STDOUT "#!!# commands, respectively.\n\n";
846 print STDOUT "acl_smtp_rcpt = check_recipient\n";
847 print STDOUT "acl_smtp_data = check_message\n\n";
849 if (defined $main{"auth_over_tls_hosts"})
851 print STDOUT "#!!# This option specifies the Access Control List (ACL) that\n";
852 print STDOUT "#!!# is used after an AUTH command.\n\n";
853 print STDOUT "acl_smtp_auth = check_auth\n\n";
856 if (&bool("smtp_verify") ||
857 defined $main{"smtp_etrn_hosts"} ||
858 defined $main{"smtp_expn_hosts"})
860 print STDOUT "#!!# These options specify the Access Control Lists (ACLs) that\n";
861 print STDOUT "#!!# are used to control the ETRN, EXPN, and VRFY commands.\n";
862 print STDOUT "#!!# Where no ACL is defined, the command is locked out.\n\n";
864 print STDOUT "acl_smtp_etrn = check_etrn\n" if defined $main{"smtp_etrn_hosts"};
865 print STDOUT "acl_smtp_expn = check_expn\n" if defined $main{"smtp_expn_hosts"};
866 print STDOUT "acl_smtp_vrfy = check_vrfy\n" if &bool("smtp_verify");
870 # If local_domains was set, get its value; otherwise set to "@". Add into it
871 # appropriate magic for local_domains_include_host[_literals].
873 $local_domains = (defined $main{"local_domains"})? $main{"local_domains"} : "@";
876 if ($local_domains =~ /^\s*<(.)\s*(.*)/s)
882 $local_domains = "\@[] $ldsep " . $local_domains
883 if defined $main{"local_domains_include_host_literals"} &&
884 $main{"local_domains_include_host_literals"} eq "true";
886 $local_domains = "\@ $ldsep " . $local_domains
887 if defined $main{"local_domains_include_host"} &&
888 $main{"local_domains_include_host"} eq "true";
890 $local_domains = "<$ldsep " . $local_domains if $ldsep ne ":";
892 # Output a domain list setting for these domains, provided something is defined
894 if ($local_domains !~ /^\s*$/)
896 print STDOUT "#!!# This setting defines a named domain list called\n";
897 print STDOUT "#!!# local_domains, created from the old options that\n";
898 print STDOUT "#!!# referred to local domains. It will be referenced\n";
899 print STDOUT "#!!# later on by the syntax \"+local_domains\".\n";
900 print STDOUT "#!!# Other domain and host lists may follow.\n\n";
902 printf STDOUT ("domainlist local_domains = %s\n\n",
903 &no_expand_regex($local_domains));
906 $relay_domains = (defined $main{"relay_domains"})? $main{"relay_domains"} : "";
909 if ($relay_domains =~ /^\s*<(.)\s*(.*)/s)
914 if (defined $main{"relay_domains_include_local_mx"})
916 $relay_domains .= ($relay_domains =~ /^\s*$/)? "\@mx_any" :
920 printf STDOUT ("domainlist relay_domains = %s\n",
921 &no_expand_regex($relay_domains))
922 if $relay_domains !~ /^\s*$/;
925 # If ignore_errmsg_errors is set, we are going to force 0s as the value
926 # for ignore_errmsg_errors_after, so arrange to skip any other value.
928 push @skipped_options, "ignore_errmsg_errors_after"
929 if &bool("ignore_errmsg_errors");
932 # If rbl_domains is set, split it up and generate six lists:
933 # rbl_warn_domains, rbl_warn_domains_skiprelay
934 # rbl_reject_domains, rbl_reject_domains_skiprelay
935 # rbl_accept_domains, rbl_accept_domains_skiprelay
937 if (defined $main{"rbl_domains"})
939 my($s) = &unquote($main{"rbl_domains"});
940 $s =~ s/\s*\\\s*\n\s*/ /g;
941 my(@list) = split /\s*:\s*/, $s;
945 my(@sublist) = split /\//, $d;
946 my($name) = shift @sublist;
948 if (defined $main{"rbl_reject_recipients"})
950 $warn = $main{"rbl_reject_recipients"} ne "true";
953 foreach $o (@sublist)
955 $warn = 1 if $o eq "warn";
956 $warn = 0 if $o eq "reject";
957 $warn = 2 if $o eq "accept";
958 $skiprelay = 1 if $o eq "skiprelay";
965 $rbl_reject_skiprelay .= ((defined $rbl_reject_skiprelay)? ":":"").$name;
969 $rbl_warn_skiprelay .= ((defined $rbl_warn_skiprelay)? ":":"").$name;
973 $rbl_accept_skiprelay .= ((defined $rbl_accept_skiprelay)? ":":"").$name;
980 $rbl_reject_domains .= ((defined $rbl_reject_domains)? ":":"").$name;
984 $rbl_warn_domains .= ((defined $rbl_warn_domains)? ":":"").$name;
988 $rbl_accept_domains .= ((defined $rbl_accept_domains)? ":":"").$name;
995 # Output host list settings
997 printf STDOUT ("hostlist auth_hosts = %s\n",
998 &no_expand_regex($main{"auth_hosts"}))
999 if defined $main{"auth_hosts"};
1000 printf STDOUT ("hostlist rbl_hosts = %s\n",
1001 &no_expand_regex($main{"rbl_hosts"}))
1002 if defined $main{"rbl_hosts"};
1003 printf STDOUT ("hostlist relay_hosts = %s\n",
1004 &no_expand_regex($main{"host_accept_relay"}))
1005 if defined $main{"host_accept_relay"};
1006 printf STDOUT ("hostlist auth_relay_hosts = %s\n",
1007 &no_expand_regex($main{"host_auth_accept_relay"}))
1008 if defined $main{"host_auth_accept_relay"};
1010 printf STDOUT ("hostlist auth_over_tls_hosts = %s\n",
1011 &no_expand_regex($main{"auth_over_tls_hosts"}))
1012 if defined $main{"auth_over_tls_hosts"};
1013 printf STDOUT ("hostlist tls_hosts = %s\n",
1014 &no_expand_regex($main{"tls_hosts"}))
1015 if defined $main{"tls_hosts"};
1016 printf STDOUT ("hostlist tls_relay_hosts = %s\n",
1017 &no_expand_regex($main{"tls_host_accept_relay"}))
1018 if defined $main{"tls_host_accept_relay"};
1023 # Convert various logging options
1028 if (defined $main{"log_level"})
1030 my($level) = $main{"log_level"};
1031 $log_selector .= "$sep -retry_defer$sep -skip_delivery" if $level < 5;
1032 $log_selector .= "$sep -lost_incoming_connection$sep -smtp_syntax_error" .
1033 "$sep -delay_delivery" if $level < 4;
1034 $log_selector .= "$sep -size_reject" if $level < 2;
1037 $log_selector .= "$sep -queue_run"
1038 if defined $main{"log_queue_run_level"} &&
1039 defined $main{"log_level"} &&
1040 $main{"log_queue_run_level"} > $main{"log_level"};
1042 $log_selector .= "$sep +address_rewrite" if &bool("log_rewrites");
1043 $log_selector .= "$sep +all_parents" if &bool("log_all_parents");
1044 $log_selector .= "$sep +arguments" if &bool("log_arguments");
1045 $log_selector .= "$sep +incoming_port" if &bool("log_incoming_port");
1046 $log_selector .= "$sep +incoming_interface" if &bool("log_interface");
1047 $log_selector .= "$sep +received_sender" if &bool("log_received_sender");
1048 $log_selector .= "$sep +received_recipients" if &bool("log_received_recipients");
1049 $log_selector .= "$sep +sender_on_delivery" if &bool("log_sender_on_delivery");
1050 $log_selector .= "$sep +smtp_confirmation" if &bool("log_smtp_confirmation");
1051 $log_selector .= "$sep +smtp_connection" if &bool("log_smtp_connections");
1052 $log_selector .= "$sep +smtp_syntax_error" if &bool("log_smtp_syntax_errors");
1053 $log_selector .= "$sep +subject" if &bool("log_subject");
1054 $log_selector .= "$sep +tls_cipher" if &bool("tls_log_cipher");
1055 $log_selector .= "$sep +tls_peerdn" if &bool("tls_log_peerdn");
1058 if ($log_selector ne "")
1060 print STDOUT "#!!# All previous logging options are combined into a single\n"
1061 . "#!!# option in Exim 4. This setting is an approximation to\n"
1062 . "#!!# the previous state - some logging has changed.\n\n";
1063 print STDOUT "log_selector = $log_selector\n\n";
1066 # If deliver_load_max is set, replace it with queue_only_load (taking the
1067 # lower value if both set) and also set deliver_queue_load_max if it is
1068 # not already set. When scanning for output, deliver_load_max is skipped.
1070 if (defined $main{"deliver_load_max"})
1074 "** deliver_load_max is abolished in Exim 4.\n";
1076 if (defined $main{"queue_only_load"})
1078 $queue_only_load_was_present = 1;
1079 if ($main{"queue_only_load"} < $main{"deliver_load_max"})
1082 " As queue_only_load was set lower, deliver_load_max is just removed.\n";
1087 " As queue_only_load was set higher, it's value has been replaced by\n" .
1088 " the value of deliver_load_max.\n";
1089 $main{"queue_only_load"} = $main{"deliver_load_max"};
1095 " queue_only_load has been set to the load value.\n";
1096 $main{"queue_only_load"} = $main{"deliver_load_max"};
1099 if (!defined $main{"deliver_queue_load_max"})
1102 " deliver_queue_load_max has been set to the value of queue_only_load.\n";
1103 $main{"deliver_queue_load_max"} = $main{"queue_only_load"};
1107 $deliver_queue_load_max_was_present = 1;
1112 # Now we scan through the various parts of the file again, making changes
1115 # -------- The main configuration --------
1118 MainLine: for ($i = 0; $i < $clen; $i++)
1121 $type = &checkline($c[$i]);
1122 last if $type eq "end";
1124 if ($type eq "macro")
1126 $i++ while $c[$i] =~ /\\\s*$|^\s*#/;
1130 if ($type eq "comment") { print STDOUT "$c[$i]\n"; next; }
1132 # Collect any continuation lines for an option setting
1134 while ($rest =~ /\\\s*$/s || $nextline =~ /^\s*#/)
1136 $nextline = $c[++$i];
1137 $rest .= "\n$nextline";
1142 # Deal with main options that are skipped (they are used in other
1143 # options in other places).
1145 for $skipped (@skipped_options)
1147 next MainLine if $name eq $skipped;
1150 # Deal with main options that are totally abolished
1152 for $abolished (@abolished_options)
1154 if ($name eq $abolished)
1158 "** The $name option no longer exists, and has no equivalent\n" .
1164 # There is a special case for rbl_warn_header
1166 if ($name eq "rbl_warn_header")
1170 "** The $name option no longer exists. In Exim 4 you can achieve the\n" .
1171 " effect by adding a suitable \"message\" statement in the ACL.\n";
1174 # There is a special case for sender_reject and host_reject
1176 elsif ($name eq "sender_reject" || $name eq "host_reject")
1180 "** The $name option no longer exists. Its data has been used in\n" .
1181 " an Access Control List as if it were in ${name}_recipients.\n";
1184 # And a special message for prohibition_message
1186 elsif ($name eq "prohibition_message")
1190 "** The prohibition_message option no longer exists. The facility is\n" .
1191 " provided in a different way in Exim 4, via the \"message\" keyword\n" .
1192 " in Access Control Lists. It isn't possible to do an automatic conversion,\n" .
1193 " so the value of prohibition_message has been ignored. You will have to\n" .
1194 " modify the ACLs if you want to reinstate the feature.\n";
1197 # auth_always_advertise gets converted to auth_advertise_hosts
1199 elsif ($name eq "auth_always_advertise")
1201 print STDOUT "#!!# auth_always_advertise converted to auth_advertise_hosts\n";
1202 if (&bool("auth_always_advertise"))
1204 print STDOUT "auth_advertise_hosts = *\n";
1209 print STDOUT "auth_advertise_hosts =";
1210 if (defined $main{"auth_hosts"})
1212 print STDOUT "$sep +auth_hosts";
1215 if (defined $main{"host_accept_relay"})
1217 print STDOUT "$sep !+relay_hosts";
1220 if (defined $main{"host_auth_accept_relay"})
1222 print STDOUT "$sep +auth_relay_hosts";
1228 # Deal with main options that have to be rewritten
1230 elsif ($name eq "accept_timeout")
1232 print STDOUT "#!!# accept_timeout renamed receive_timeout\n";
1233 print STDOUT "receive_timeout = $rest\n";
1236 elsif ($name eq "collapse_source_routes")
1238 print STDOUT "#!!# collapse_source_routes removed\n";
1239 print STDOUT "#!!# It has been a no-op since 3.10.\n";
1242 elsif ($name eq "daemon_smtp_service")
1244 print STDOUT "#!!# daemon_smtp_service renamed daemon_smtp_port\n";
1245 print STDOUT "daemon_smtp_port = $rest\n";
1248 elsif ($name eq "dns_check_names" || $name eq "dns_check_names_pattern")
1250 if (!$done_dns_check_names)
1252 if (&bool("dns_check_names"))
1254 if (defined $main{"dns_check_names_pattern"})
1256 &outopt(\%main, "dns_check_names_pattern", 0);
1262 print STDOUT "#!!# dns_check_names has been abolished\n";
1263 print STDOUT "#!!# setting dns_check_pattern empty to turn off check\n";
1264 print STDOUT "dns_check_names_pattern =\n";
1267 $done_dns_check_names = 1;
1271 elsif ($name eq "deliver_load_max")
1273 print STDOUT "deliver_queue_load_max = $main{'deliver_queue_load_max'}\n"
1274 if !$deliver_queue_load_max_was_present;
1275 print STDOUT "queue_only_load = $main{'queue_only_load'}\n"
1276 if !$queue_only_load_was_present;
1279 elsif ($name eq "errmsg_file")
1281 print STDOUT "#!!# errmsg_file renamed bounce_message_file\n";
1282 print STDOUT "bounce_message_file = $rest\n";
1285 elsif ($name eq "errmsg_text")
1287 print STDOUT "#!!# errmsg_text renamed bounce_message_text\n";
1288 print STDOUT "bounce_message_text = $rest\n";
1291 elsif ($name eq "forbid_domain_literals")
1293 print STDOUT "#!!# forbid_domain_literals replaced by allow_domain_literals\n";
1294 print STDOUT "allow_domain_literals = ",
1295 &bool("forbid_domain_literals")? "false" : "true", "\n";
1298 elsif ($name eq "freeze_tell_mailmaster")
1300 print STDOUT "#!!# freeze_tell_mailmaster replaced by freeze_tell\n";
1301 if (&bool("freeze_tell_mailmaster"))
1303 print STDOUT "freeze_tell = ",
1304 ((defined $main{"errors_address"})?
1305 $main{"errors_address"} : "postmaster"), "\n";
1309 print STDOUT "#!!# freeze_tell is unset by default\n";
1313 elsif ($name eq "helo_verify")
1315 print STDOUT "#!!# helo_verify renamed helo_verify_hosts\n";
1316 printf STDOUT ("helo_verify_hosts = %s\n", &no_expand_regex($rest));
1319 elsif ($name eq "ignore_errmsg_errors")
1321 print STDOUT "ignore_bounce_errors_after = 0s\n";
1324 elsif ($name eq "ignore_errmsg_errors_after")
1326 print STDOUT "#!!# ignore_errmsg_errors_after renamed ignore_bounce_errors_after\n";
1327 print STDOUT "ignore_bounce_errors_after = $rest\n";
1330 elsif ($name eq "ipv4_address_lookup" || $name eq "dns_ipv4_lookup")
1332 print STDOUT "#!!# $name changed to dns_ipv4_lookup\n"
1333 if $name eq "ipv4_address_lookup";
1334 print STDOUT "#!!# dns_ipv4_lookup is now a domain list\n";
1337 print STDOUT "dns_ipv4_lookup = *\n";
1341 print STDOUT "#!!# default for dns_ipv4_lookup is unset\n";
1345 elsif ($name eq "locally_caseless")
1347 print STDOUT "#!!# locally_caseless removed\n";
1348 print STDOUT "#!!# caseful_local_part will be added to ex-directors\n";
1349 $add_caseful_local_part = 1;
1352 elsif ($name eq "message_filter_directory2_transport")
1354 print STDOUT "#!!# message_filter_directory2_transport removed\n";
1357 elsif ($name =~ /^message_filter(.*)/)
1359 print STDOUT "#!!# $name renamed system_filter$1\n";
1360 print STDOUT "system_filter$1 = $rest\n";
1363 elsif ($name eq "queue_remote_domains")
1365 print STDOUT "#!!# queue_remote_domains renamed queue_domains\n";
1366 printf STDOUT ("queue_domains = %s\n", &no_expand_regex($rest));
1369 elsif ($name eq "receiver_unqualified_hosts")
1371 print STDOUT "#!!# receiver_unqualified_hosts renamed recipient_unqualified_hosts\n";
1372 printf STDOUT ("recipient_unqualified_hosts = %s\n",
1373 &no_expand_regex($rest));
1376 elsif ($name eq "remote_sort")
1378 print STDOUT "#!!# remote_sort renamed remote_sort_domains\n";
1379 printf STDOUT ("remote_sort_domains = %s\n", &no_expand_regex($rest));
1382 elsif ($name eq "security")
1384 if ($rest eq "unprivileged")
1386 print STDOUT "#!!# security=unprivileged changed to deliver_drop_privilege\n";
1387 print STDOUT "deliver_drop_privilege\n";
1393 "** The 'security' option no longer exists.\n";
1397 elsif ($name eq "timestamps_utc")
1399 print STDOUT "#!!# timestamps_utc changed to use timezone\n";
1400 print STDOUT "timezone = utc\n";
1403 elsif ($name eq "untrusted_set_sender")
1405 print STDOUT "#!!# untrusted_set_sender is now a list of what can be set\n";
1406 print STDOUT "#!!# The default is an empty list.\n";
1407 if (&bool("untrusted_set_sender"))
1409 print STDOUT "untrusted_set_sender = *\n";
1413 elsif ($name eq "warnmsg_file")
1415 print STDOUT "#!!# warnmsg_file renamed warn_message_file\n";
1416 print STDOUT "warn_message_file = $rest\n";
1419 # Remaining options just get copied unless they are one of those that's
1420 # a list where any regular expressions have to be escaped.
1425 foreach $o (@list_options)
1433 &outopt(\%main, $name, $no_expand);
1438 # -------- The ACL configuration --------
1441 print STDOUT "#!!#######################################################!!#\n";
1442 print STDOUT "#!!# This new section of the configuration contains ACLs #!!#\n";
1443 print STDOUT "#!!# (Access Control Lists) derived from the Exim 3 #!!#\n";
1444 print STDOUT "#!!# policy control options. #!!#\n";
1445 print STDOUT "#!!#######################################################!!#\n";
1448 print STDOUT "#!!# These ACLs are crudely constructed from Exim 3 options.\n";
1449 print STDOUT "#!!# They are almost certainly not optimal. You should study\n";
1450 print STDOUT "#!!# them and rewrite as necessary.\n";
1452 print STDOUT "\nbegin acl\n\n";
1455 # Output an ACL for use after the RCPT command. This combines all the previous
1456 # policy checking options.
1458 print STDOUT "#!!# ACL that is used after the RCPT command\n";
1459 print STDOUT "check_recipient:\n";
1461 print STDOUT " # Exim 3 had no checking on -bs messages, so for compatibility\n";
1462 print STDOUT " # we accept if the source is local SMTP (i.e. not over TCP/IP).\n";
1463 print STDOUT " # We do this by testing for an empty sending host field.\n";
1464 print STDOUT " accept hosts = :\n";
1466 if (defined $main{"tls_verify_ciphers"})
1468 print STDOUT " deny ";
1469 print STDOUT "hosts = $main{'tls_verify_hosts'}\n "
1470 if defined $main{"tls_verify_hosts"};
1471 print STDOUT " encrypted = *\n ";
1472 print STDOUT "!encrypted = $main{'tls_verify_ciphers'}\n";
1475 print STDOUT " deny hosts = +auth_hosts\n" .
1476 " message = authentication required\n" .
1477 " !authenticated = *\n"
1478 if defined $main{"auth_hosts"};
1480 print STDOUT " deny hosts = +tls_hosts\n" .
1481 " message = encryption required\n" .
1483 if defined $main{"tls_hosts"};
1485 printf STDOUT (" accept recipients = %s\n",
1486 &acl_quote(&sort_address_list($main{"recipients_reject_except"},
1487 "recipients_reject_except")))
1488 if defined $main{"recipients_reject_except"};
1490 printf STDOUT (" accept senders = %s\n",
1491 &acl_quote(&sort_address_list($main{"recipients_reject_except_senders"},
1492 "recipients_reject_except_senders")))
1493 if defined $main{"recipients_reject_except_senders"};
1495 printf STDOUT (" deny hosts = %s\n", &acl_quote($main{"host_reject"}))
1496 if defined $main{"host_reject"};
1498 printf STDOUT (" deny hosts = %s\n",
1499 &acl_quote($main{"host_reject_recipients"}))
1500 if defined $main{"host_reject_recipients"};
1502 if (defined $main{"rbl_domains"})
1504 my($msg) = "message = host is listed in \$dnslist_domain\n ";
1505 my($hlist) = (defined $main{"rbl_hosts"})?
1506 "hosts = +rbl_hosts\n " : "";
1508 print STDOUT " accept ${hlist}dnslists = $rbl_accept_domains\n"
1509 if defined $rbl_accept_domains;
1510 print STDOUT " deny ${hlist}${msg}dnslists = $rbl_reject_domains\n"
1511 if defined $rbl_reject_domains;
1512 print STDOUT " warn ${hlist}" .
1513 "message = X-Warning: \$sender_host_address is listed at \$dnslist_domain\n" .
1514 " dnslists = $rbl_warn_domains\n"
1515 if defined $rbl_warn_domains;
1517 if (defined $main{"host_accept_relay"})
1519 $hlist .= "hosts = !+relay_hosts\n ";
1520 print STDOUT " accept ${hlist}dnslists = $rbl_accept_skiprelay\n"
1521 if defined $rbl_accept_skiprelay;
1522 print STDOUT " deny ${hlist}${msg}dnslists = $rbl_reject_skiprelay\n"
1523 if defined $rbl_reject_skiprelay;
1524 print STDOUT " warn ${hlist}" .
1525 "message = X-Warning: \$sender_host_address is listed at \$dnslist_domain\n" .
1526 " dnslists = $rbl_warn_skiprelay\n"
1527 if defined $rbl_warn_skiprelay;
1531 printf STDOUT (" deny senders = %s\n",
1532 &acl_quote(&sort_address_list($main{"sender_reject"}, "sender_reject")))
1533 if defined $main{"sender_reject"};
1535 printf STDOUT (" deny senders = %s\n",
1536 &acl_quote(&sort_address_list($main{"sender_reject_recipients"},
1537 "sender_reject_recipients")))
1538 if defined $main{"sender_reject_recipients"};
1540 if (&bool("sender_verify"))
1542 if (defined $main{"sender_verify_hosts_callback"} &&
1543 defined $main{"sender_verify_callback_domains"})
1545 printf STDOUT (" deny hosts = %s\n",
1546 &acl_quote($main{"sender_verify_hosts_callback"}));
1547 printf STDOUT (" sender_domains = %s\n",
1548 &acl_quote($main{"sender_verify_callback_domains"}));
1549 print STDOUT " !verify = sender/callout";
1550 print STDOUT "=$main{\"sender_verify_callback_timeout\"}"
1551 if defined $main{"sender_verify_callback_timeout"};
1555 if (defined $main{"sender_verify_hosts"})
1557 printf STDOUT (" deny hosts = %s\n",
1558 &acl_quote($main{"sender_verify_hosts"}));
1559 print STDOUT " !verify = sender\n";
1563 print STDOUT " require verify = sender\n";
1567 if (&bool("receiver_verify"))
1569 print STDOUT " deny message = unrouteable address\n";
1570 printf STDOUT (" recipients = %s\n",
1571 &acl_quote(&sort_address_list($main{"receiver_verify_addresses"},
1572 "receiver_verify_addresses")))
1573 if defined $main{"receiver_verify_addresses"};
1574 printf STDOUT (" hosts = %s\n",
1575 &acl_quote($main{"receiver_verify_hosts"}))
1576 if defined $main{"receiver_verify_hosts"};
1577 printf STDOUT (" senders = %s\n",
1578 &acl_quote(&sort_address_list($main{"receiver_verify_senders"},
1579 "receiver_verify_senders")))
1580 if defined $main{"receiver_verify_senders"};
1581 print STDOUT " !verify = recipient\n";
1584 print STDOUT " accept domains = +local_domains\n"
1585 if $local_domains !~ /^\s*$/;
1587 print STDOUT " accept domains = +relay_domains\n"
1588 if $relay_domains !~ /^\s*$/;
1590 if (defined $main{"host_accept_relay"})
1592 if (defined $main{"sender_address_relay"})
1594 if (defined $main{"sender_address_relay_hosts"})
1596 printf STDOUT (" accept hosts = %s\n",
1597 &acl_quote($main{"sender_address_relay_hosts"}));
1598 print STDOUT " endpass\n";
1599 print STDOUT " message = invalid sender\n";
1600 printf STDOUT (" senders = %s\n",
1601 &acl_quote(&sort_address_list($main{"sender_address_relay"},
1602 "sender_address_relay")));
1603 print STDOUT " accept hosts = +relay_hosts\n";
1607 print STDOUT " accept hosts = +relay_hosts\n";
1608 print STDOUT " endpass\n";
1609 print STDOUT " message = invalid sender\n";
1610 printf STDOUT (" senders = %s\n",
1611 &acl_quote(&sort_address_list($main{"sender_address_relay"},
1612 "sender_address_relay")));
1617 print STDOUT " accept hosts = +relay_hosts\n";
1621 print STDOUT " accept hosts = +auth_relay_hosts\n" .
1623 " message = authentication required\n" .
1624 " authenticated = *\n"
1625 if defined $main{"host_auth_accept_relay"};
1627 print STDOUT " accept hosts = +tls_relay_hosts\n" .
1629 " message = encryption required\n" .
1631 if defined $main{"tls_host_accept_relay"};
1633 print STDOUT " deny message = relay not permitted\n\n";
1636 # Output an ACL for use after the DATA command. This is concerned with
1639 print STDOUT "#!!# ACL that is used after the DATA command\n";
1640 print STDOUT "check_message:\n";
1642 # Default for headers_checks_fail is true
1644 if (!defined $main{"headers_checks_fail"} ||
1645 $main{"headers_checks_fail"} eq "true")
1647 print STDOUT " require verify = header_syntax\n"
1648 if &bool("headers_check_syntax");
1649 print STDOUT " require verify = header_sender\n"
1650 if &bool("headers_sender_verify");
1651 print STDOUT " accept senders = !:\n require verify = header_sender\n"
1652 if &bool("headers_sender_verify_errmsg");
1656 print STDOUT " warn !verify = header_syntax\n"
1657 if &bool("headers_check_syntax");
1658 print STDOUT " warn !verify = header_sender\n"
1659 if &bool("headers_sender_verify");
1660 print STDOUT " accept senders = !:\n warn !verify = header_sender\n"
1661 if &bool("headers_sender_verify_errmsg");
1664 print STDOUT " accept\n\n";
1667 # Output an ACL for AUTH if required
1669 if (defined $main{"auth_over_tls_hosts"})
1671 print STDOUT "#!!# ACL that is used after the AUTH command\n" .
1673 " accept hosts = +auth_over_tls_hosts\n" .
1675 " message = STARTTLS required before AUTH\n" .
1676 " encrypted = *\n" .
1681 # Output ACLs for ETRN, EXPN, and VRFY if required
1683 if (defined $main{"smtp_etrn_hosts"})
1685 print STDOUT "#!!# ACL that is used after the ETRN command\n" .
1687 print STDOUT " deny hosts = +auth_hosts\n" .
1688 " message = authentication required\n" .
1689 " !authenticated = *\n"
1690 if defined $main{"auth_hosts"};
1691 print STDOUT " accept hosts = $main{\"smtp_etrn_hosts\"}\n\n";
1694 if (defined $main{"smtp_expn_hosts"})
1696 print STDOUT "#!!# ACL that is used after the EXPN command\n" .
1698 print STDOUT " deny hosts = +auth_hosts\n" .
1699 " message = authentication required\n" .
1700 " !authenticated = *\n"
1701 if defined $main{"auth_hosts"};
1702 print STDOUT " accept hosts = $main{\"smtp_expn_hosts\"}\n\n";
1705 if (&bool("smtp_verify"))
1707 print STDOUT "#!!# ACL that is used after the VRFY command\n" .
1709 print STDOUT " deny hosts = +auth_hosts\n" .
1710 " message = authentication required\n" .
1711 " !authenticated = *\n"
1712 if defined $main{"auth_hosts"};
1713 print STDOUT " accept\n\n";
1716 # -------- The authenticators --------
1719 for ($i = $auth_start; $i < $clen; $i++)
1723 if ($c[$i] !~ /^\s*(#|$)/)
1725 print STDOUT "\nbegin authenticators\n\n";
1729 print STDOUT "$c[$i]\n";
1733 # -------- Rewrite section --------
1736 for ($i = $rewrite_start; $i < $clen && $i < $auth_start - 1; $i++)
1740 if ($c[$i] !~ /^\s*(#|$)/)
1742 print STDOUT "\nbegin rewrite\n\n";
1746 &print_no_expand($c[$i]);
1750 # -------- The routers configuration --------
1752 # The new routers configuration is created out of the old directors and routers
1753 # configuration. We put the old routers first, adding a "domains" option to
1754 # any that don't have one, to make them select the domains that do not match
1755 # the original local_domains. The routers get modified as necessary, and the
1756 # final one has "no_more" set, unless it has conditions. In that case we have
1757 # to add an extra router to be sure of failing all non-local addresses that
1758 # fall through. We do this also if there are no routers at all. The old
1759 # directors follow, modified as required.
1765 print STDOUT "#!!#######################################################!!#\n";
1766 print STDOUT "#!!# Here follow routers created from the old routers, #!!#\n";
1767 print STDOUT "#!!# for handling non-local domains. #!!#\n";
1768 print STDOUT "#!!#######################################################!!#\n";
1770 print STDOUT "\nbegin routers\n\n";
1772 for ($i = $router_start; $i < $clen; $i++)
1774 $type = &checkline($c[$i]);
1775 last if $type eq "end";
1777 if ($type eq "comment") { push(@comments, "$c[$i]\n"); next; }
1779 # When we hit the start of a driver, modify its options as necessary,
1780 # and then output it from the stored option settings, having first output
1781 # and previous comments.
1783 if ($type eq "driver")
1785 print STDOUT shift @comments while scalar(@comments) > 0;
1787 $hash = $driverlist{"$prefix$name"};
1788 $driver = $$hash{"driver"};
1789 print STDOUT "$name:\n";
1792 ! defined $$hash{"domains"} &&
1793 ! defined $$hash{"local_parts"} &&
1794 ! defined $$hash{"senders"} &&
1795 ! defined $$hash{"condition"} &&
1796 ! defined $$hash{"require_files"} &&
1797 (!defined $$hash{"verify_only"} || $$hash{"verify_only"} eq "false") &&
1798 (!defined $$hash{"verify"} || $$hash{"verify"} eq "true");
1800 # Create a "domains" setting if there isn't one, unless local domains
1801 # was explicitly empty.
1803 $$hash{"domains"} = "! +local_domains"
1804 if !defined $$hash{"domains"} && $local_domains !~ /^\s*$/;
1806 # If the router had a local_parts setting, add caseful_local_part
1808 $$hash{"caseful_local_part"} = "true" if defined $$hash{"local_parts"};
1810 # If the router has "self=local" set, change it to "self=pass", and
1811 # set pass_router to the router that was the first director. Change the
1812 # obsolete self settings of "fail_hard" and "fail_soft" to "fail" and
1815 if (defined $$hash{"self"})
1817 if ($$hash{"self"} eq "local")
1819 $$hash{"self"} = "pass";
1820 $$hash{"pass_router"} = $first_director;
1822 elsif ($$hash{"self"} eq "fail_hard")
1824 $$hash{"self"} = "fail";
1826 elsif ($$hash{"self"} eq "fail_soft")
1828 $$hash{"self"} = "pass";
1832 # If the router had a require_files setting, check it for user names
1833 # and colons that are part of expansion items
1835 if (defined $$hash{"require_files"})
1837 &check_require($$hash{"require_files"}, "'$name' router");
1838 if (($$hash{"require_files"} =~ s/(\$\{\w+):/$1::/g) > 0 ||
1839 ($$hash{"require_files"} =~ s/ldap:/ldap::/g) > 0)
1843 "*** A setting of require_files in the $name router contains\n" .
1844 " a colon in what appears to be an expansion item. In Exim 3, the\n" .
1845 " whole string was expanded before splitting the list, but in Exim 4\n" .
1846 " each item is expanded separately, so colons that are not list\n" .
1847 " item separators have to be doubled. One or more such colons in this\n" .
1848 " list have been doubled as a precaution. Please check the result.\n";
1852 # If the router had a "senders" setting, munge the address list
1854 $$hash{"senders"} = &sort_address_list($$hash{"senders"}, "senders")
1855 if defined $$hash{"senders"};
1857 # ---- Changes to domainlist router ----
1859 if ($driver eq "domainlist")
1861 &abolished($hash, "A domainlist router",
1862 "modemask", "owners", "owngroups",
1863 "qualify_single", "search_parents");
1865 # The name has changed
1867 $$hash{"driver"} = "manualroute";
1869 # Turn "route_file", "route_query" and "route_queries" into lookups for
1872 if (defined $$hash{"route_file"})
1874 $$hash{"route_data"} = "\${lookup\{\$domain\}$$hash{'search_type'}" .
1875 "\{$$hash{'route_file'}\}\}";
1877 elsif (defined $$hash{"route_query"})
1879 $$hash{"route_data"} = "\${lookup $$hash{'search_type'}" .
1880 "\{" . &unquote($$hash{'route_query'}) . "\}\}";
1882 elsif (defined $$hash{"route_queries"})
1885 $$hash{"route_data"} = "";
1886 $route_queries = $$hash{'route_queries'};
1887 $route_queries =~ s/^"(.*)"$/$1/s;
1888 $route_queries =~ s/::/++colons++/g;
1889 @qq = split(/:/, $route_queries);
1893 $q =~ s/\+\+colons\+\+/:/g;
1898 $$hash{"route_data"} .= "\\\n {";
1901 $$hash{"route_data"} .= "\${lookup $$hash{'search_type'} \{$q\}\{\$value\}";
1905 $$hash{"route_data"} .= "}" x $endkets;
1908 delete $$hash{"route_file"};
1909 delete $$hash{"route_query"};
1910 delete $$hash{"route_queries"};
1911 delete $$hash{"search_type"};
1913 # But we can't allow both route_data and route_list
1915 if (defined $$hash{"route_data"} && defined $$hash{"route_list"})
1919 "** An Exim 3 'domainlist' router called '$name' contained a 'route_list'\n" .
1920 " option as well as a setting of 'route_file', 'route_query', or\n" .
1921 " 'route_queries'. The latter has been turned into a 'route_data' setting,\n".
1922 " but in Exim 4 you can't have both 'route_data' and 'route_list'. You'll\n" .
1923 " have to rewrite this router; in the meantime, 'route_list' has been\n" .
1925 print STDOUT "#!!# route_list option removed\n";
1926 delete $$hash{"route_list"};
1929 # Change bydns_a into bydns in a route_list; also bydns_mx, but that
1930 # works differently.
1932 if (defined $$hash{"route_list"})
1934 $$hash{"route_list"} =~ s/bydns_a/bydns/g;
1935 if ($$hash{"route_list"} =~ /bydns_mx/)
1937 $$hash{"route_list"} =~ s/bydns_mx/bydns/g;
1940 "*** An Exim 3 'domainlist' router called '$name' contained a 'route_list'\n" .
1941 " option which used 'bydns_mx'. This feature no longer exists in Exim 4.\n" .
1942 " It has been changed to 'bydns', but it won't have the same effect,\n" .
1943 " because it will look for A rather than MX records. Use the 'dnslookup'\n" .
1944 " router to do MX lookups - if you want to override the hosts found from\n" .
1945 " MX records, you should route to a special 'smtp' transport which has\n" .
1946 " both 'hosts' and 'hosts_override' set.\n";
1950 # Arrange to not expand regex
1952 $$hash{"route_list"} = &no_expand_regex($$hash{"route_list"}, ";")
1953 if (defined $$hash{"route_list"})
1957 # ---- Changes to iplookup router ----
1959 elsif ($driver eq "iplookup")
1961 &renamed($hash, "service", "port");
1965 # ---- Changes to lookuphost router ----
1967 elsif ($driver eq "lookuphost")
1969 $$hash{"driver"} = "dnslookup";
1971 if (defined $$hash{"gethostbyname"})
1975 "** An Exim 3 'lookuphost' router called '$name' used the 'gethostbyname'\n" .
1976 " option, which no longer exists. You will have to rewrite it.\n";
1977 print STDOUT "#!!# gethostbyname option removed\n";
1978 delete $$hash{"gethostbyname"};
1981 $$hash{"mx_domains"} = &no_expand_regex($$hash{"mx_domains"})
1982 if defined $$hash{"mx_domains"};
1986 # ---- Changes to the queryprogram router ----
1988 elsif ($driver eq "queryprogram")
1992 "** The configuration contains a 'queryprogram' router. Please note that\n" .
1993 " the specification for the text that is returned by the program run\n" .
1994 " by this router has changed in Exim 4. You will need to modify your\n" .
1997 if (!defined $$hash{'command_user'})
2001 "** The 'queryprogram' router called '$name' does not have a setting for\n" .
2002 " the 'command_user' option. This is mandatory in Exim 4. A setting of\n" .
2003 " 'nobody' has been created.\n";
2004 $$hash{"command_user"} = "nobody";
2009 # -------------------------------------
2011 # Output the router's option settings
2017 # Skip past any continuation lines for an option setting
2018 while ($c[$i] =~ /\\\s*$/s && $i < $clen - 1)
2021 $i++ while ($c[$i] =~ /^\s*#/);
2025 # Add "no_more" to the final driver from the old routers, provided it had no
2026 # conditions. Otherwise, or if there were no routers, make up one to fail all
2027 # non-local domains.
2031 print STDOUT " no_more\n";
2032 print STDOUT shift @comments while scalar(@comments) > 0;
2036 print STDOUT shift @comments while scalar(@comments) > 0;
2037 print STDOUT "\n#!!# This new router is put here to fail all domains that\n";
2038 print STDOUT "#!!# were not in local_domains in the Exim 3 configuration.\n\n";
2039 print STDOUT "fail_remote_domains:\n";
2040 print STDOUT " driver = redirect\n";
2041 print STDOUT " domains = ! +local_domains\n";
2042 print STDOUT " allow_fail\n";
2043 print STDOUT " data = :fail: unrouteable mail domain \"\$domain\"\n\n";
2046 # Now copy the directors, making appropriate changes
2049 print STDOUT "#!!#######################################################!!#\n";
2050 print STDOUT "#!!# Here follow routers created from the old directors, #!!#\n";
2051 print STDOUT "#!!# for handling local domains. #!!#\n";
2052 print STDOUT "#!!#######################################################!!#\n";
2055 for ($i = $director_start; $i < $clen; $i++)
2057 $type = &checkline($c[$i]);
2058 last if $type eq "end";
2060 if ($type eq "comment") { print STDOUT "$c[$i]\n"; next; }
2062 undef $second_router;
2064 if ($type eq "driver")
2066 $hash = $driverlist{"$prefix$name"};
2067 $driver = $$hash{"driver"};
2068 print STDOUT "$name:\n";
2070 $$hash{"caseful_local_part"} = "true" if $add_caseful_local_part;
2072 if (defined $$hash{"local_parts"} &&
2073 (defined $$hash{"prefix"} || defined $hash{"suffix"}))
2077 "** The Exim 3 configuration contains a director called '$name' which has\n" .
2078 " 'local_parts' set, together with either or both of 'prefix' and 'suffix'\n".
2079 " This combination has a different effect in Exim 4, where the affix\n" .
2080 " is removed *before* 'local_parts' is tested. You will probably need\n" .
2081 " to make changes to this driver.\n";
2084 &renamed($hash, "prefix", "local_part_prefix");
2085 &renamed($hash, "prefix_optional", "local_part_prefix_optional");
2086 &renamed($hash, "suffix", "local_part_suffix");
2087 &renamed($hash, "suffix_optional", "local_part_suffix_optional");
2088 &renamed($hash, "new_director", "redirect_router");
2090 &handle_current_and_home_directory($hash, $driver, $name);
2092 # If the director had a require_files setting, check it for user names
2093 # and colons that are part of expansion items
2095 if (defined $$hash{"require_files"})
2097 &check_require($$hash{"require_files"}, "'$name' director");
2098 if (($$hash{"require_files"} =~ s/(\$\{\w+):/$1::/g) > 0 ||
2099 ($$hash{"require_files"} =~ s/ldap:/ldap::/g) > 0)
2103 "*** A setting of require_files in the $name director contains\n" .
2104 " a colon in what appears to be an expansion item. In Exim 3, the\n" .
2105 " whole string was expanded before splitting the list, but in Exim 4\n" .
2106 " each item is expanded separately, so colons that are not list\n" .
2107 " item separators have to be doubled. One or more such colons in this\n" .
2108 " list have been doubled as a precaution. Please check the result.\n";
2112 # If the director had a "senders" setting, munge the address list
2114 $$hash{"senders"} = &sort_address_list($$hash{"senders"}, "senders")
2115 if defined $$hash{"senders"};
2117 # ---- Changes to aliasfile director ----
2119 if ($driver eq "aliasfile")
2121 &abolished($hash, "An aliasfile director",
2122 "directory2_transport", "freeze_missing_include",
2123 "modemask", "owners", "owngroups");
2125 $$hash{"driver"} = "redirect";
2127 $key = "\$local_part";
2128 $key = "\$local_part\@\$domain"
2129 if defined $$hash{"include_domain"} &&
2130 $$hash{"include_domain"} eq "true";
2131 delete $$hash{"include_domain"};
2133 if (defined $$hash{"forbid_special"} && $$hash{"forbid_special"} eq "true")
2135 $$hash{"forbid_blackhole"} = "true";
2139 $$hash{"allow_defer"} = "true";
2140 $$hash{"allow_fail"} = "true";
2142 delete $$hash{"forbid_special"};
2144 # Deal with "file", "query", or "queries"
2146 if (defined $$hash{"file"})
2149 "\$\{lookup\{$key\}$$hash{'search_type'}\{$$hash{'file'}\}\}";
2150 if (defined $$hash{"optional"} && $$hash{"optional"} eq "true")
2153 "\$\{if exists\{$$hash{'file'}\}\{$$hash{'data'}\}\}";
2155 delete $$hash{"optional"};
2157 elsif (defined $$hash{"query"})
2159 &abolished($hash, "An aliasfile director", "optional");
2160 $$hash{"data"} = "\${lookup $$hash{'search_type'} " .
2161 "\{" . &unquote($$hash{'query'}) . "\}\}";
2163 else # Must be queries
2165 &abolished($hash, "An aliasfile director", "optional");
2167 $$hash{"data"} = "";
2168 $queries = $$hash{'queries'};
2169 $queries =~ s/^"(.*)"$/$1/s;
2170 $queries =~ s/::/++colons++/g;
2171 @qq = split(/:/, $queries);
2175 $q =~ s/\+\+colons\+\+/:/g;
2180 $$hash{"data"} .= "\\\n {";
2183 $$hash{"data"} .= "\${lookup $$hash{'search_type'} \{$q\}\{\$value\}";
2187 $$hash{"data"} .= "}" x $endkets;
2190 $$hash{"data"} = "\${expand:$$hash{'data'}\}"
2191 if (defined $$hash{"expand"} && $$hash{"expand"} eq "true");
2193 delete $$hash{"expand"};
2194 delete $$hash{"file"};
2195 delete $$hash{"query"};
2196 delete $$hash{"queries"};
2197 delete $$hash{"search_type"};
2199 # Turn aliasfile + transport into accept + condition
2201 if (defined $$hash{'transport'})
2204 if (!defined $$hash{'condition'})
2207 "** The Exim 3 configuration contains an aliasfile director called '$name',\n".
2208 " which has 'transport' set. This has been turned into an 'accept' router\n".
2209 " with a 'condition' setting, but should be carefully checked.\n";
2210 $$hash{'driver'} = "accept";
2211 $$hash{'condition'} =
2212 "\$\{if eq \{\}\{$$hash{'data'}\}\{no\}\{yes\}\}";
2213 delete $$hash{'data'};
2214 delete $$hash{'allow_defer'};
2215 delete $$hash{'allow_fail'};
2220 "** The Exim 3 configuration contains an aliasfile director called '$name',\n".
2221 " which has 'transport' set. This cannot be turned into an 'accept' router\n".
2222 " with a 'condition' setting, because there is already a 'condition'\n" .
2223 " setting. It has been left as 'redirect' with a transport, which is\n" .
2224 " invalid - you must sort this one out.\n";
2230 # ---- Changes to forwardfile director ----
2232 elsif ($driver eq "forwardfile")
2234 &abolished($hash, "A forwardfile director",
2235 "check_group", "directory2_transport",
2236 "freeze_missing_include", "match_directory",
2239 &renamed($hash, "filter", "allow_filter");
2241 $$hash{"driver"} = "redirect";
2242 $$hash{"check_local_user"} = "true"
2243 if !defined $$hash{"check_local_user"};
2245 if (defined $$hash{"forbid_pipe"} && $$hash{"forbid_pipe"} eq "true")
2247 print STDOUT "#!!# forbid_filter_run added because forbid_pipe is set\n";
2248 $$hash{"forbid_filter_run"} = "true";
2251 if (defined $$hash{'allow_system_actions'} &&
2252 $$hash{'allow_system_actions'} eq 'true')
2254 $$hash{'allow_freeze'} = "true";
2256 delete $$hash{'allow_system_actions'};
2258 # If file_directory is defined, use it to qualify relative paths; if not,
2259 # and check_local_user is defined, use $home. Remove file_directory from
2263 if (defined $$hash{"file_directory"})
2265 $dir = $$hash{"file_directory"} . "/";
2266 delete $$hash{"file_directory"};
2268 elsif ($$hash{"check_local_user"} eq "true")
2273 # If it begins with an upper case letter, guess that this is really
2276 if (defined $$hash{"file"} && $$hash{"file"} !~ /^[\/A-Z]/)
2278 $$hash{"file"} = $dir . $$hash{"file"};
2283 # ---- Changes to localuser director ----
2285 elsif ($driver eq "localuser")
2287 &abolished($hash, "A localuser director", "match_directory");
2288 $$hash{"driver"} = "accept";
2289 $$hash{"check_local_user"} = "true";
2293 # ---- Changes to smartuser director ----
2295 elsif ($driver eq "smartuser")
2297 &abolished($hash, "A smartuser director", "panic_expansion_fail");
2299 $transport = $$hash{"transport"};
2300 $new_address = $$hash{"new_address"};
2302 if (defined $transport && defined $new_address)
2306 "** The Exim 3 configuration contains a smartuser director called '$name',\n".
2307 " which has both 'transport' and 'new_address' set. This has been turned\n".
2308 " into two routers for Exim 4. However, if the new address contains a\n" .
2309 " reference to \$local_part, this won't work correctly. In any case, you\n".
2310 " may be able to make it tidier by rewriting.\n";
2311 $$hash{"driver"} = "redirect";
2312 $$hash{"data"} = $new_address;
2313 $$hash{"redirect_router"} = "${name}_part2";
2315 $second_router = "\n".
2316 "#!!# This router is invented to go with the previous one because\n".
2317 "#!!# in Exim 4 you can't have a change of address and a transport\n".
2318 "#!!# setting in the same router as you could in Exim 3.\n\n" .
2320 " driver = accept\n".
2321 " condition = \$\{if eq\{\$local_part@\$domain\}" .
2322 "\{$new_address\}\{yes\}\{no\}\}\n".
2323 " transport = $$hash{'transport'}\n";
2325 delete $$hash{"new_address"};
2326 delete $$hash{"transport"};
2328 elsif (defined $new_address)
2330 $$hash{"driver"} = "redirect";
2331 $$hash{"data"} = $new_address;
2332 $$hash{"allow_defer"} = "true";
2333 $$hash{"allow_fail"} = "true";
2334 delete $$hash{"new_address"};
2336 else # Includes the case of neither set (verify_only)
2338 $$hash{"driver"} = "accept";
2339 if (defined $$hash{"rewrite"})
2343 "** The Exim 3 configuration contains a setting of the 'rewrite' option on\n".
2344 " a smartuser director called '$name', but this director does not have\n".
2345 " a setting of 'new_address', so 'rewrite' has no effect. The director\n".
2346 " has been turned into an 'accept' router, and 'rewrite' has been discarded.";
2347 delete $$hash{"rewrite"};
2353 # -------------------------------------
2355 # For ex-directors that don't have check_local_user set, add
2356 # retry_use_local_part to imitate what Exim 3 would have done.
2358 $$hash{"retry_use_local_part"} = "true"
2359 if (!defined $$hash{"check_local_user"} ||
2360 $$hash{"check_local_user"} eq "false") ;
2362 # Output the router's option settings
2366 # Output an auxiliary router if one is needed
2368 print STDOUT $second_router if defined $second_router;
2373 # Skip past any continuation lines for an option setting
2374 while ($c[$i] =~ /\\\s*$/s)
2377 $i++ while ($c[$i] =~ /^\s*#/);
2383 # -------- The transports configuration --------
2387 for ($i = $transport_start; $i < $clen; $i++)
2389 $type = &checkline($c[$i]);
2390 last if $type eq "end";
2392 if ($type eq "comment") { print STDOUT "$c[$i]\n"; next; }
2396 print STDOUT "begin transports\n\n";
2400 if ($type eq "driver")
2402 $hash = $driverlist{"$prefix$name"};
2403 $driver = $$hash{"driver"};
2404 print STDOUT "$name:\n";
2406 # ---- Changes to the appendfile transport ----
2408 if ($driver eq "appendfile")
2410 &renamed($hash, "prefix", "message_prefix");
2411 &renamed($hash, "suffix", "message_suffix");
2412 &abolished($hash, "An appendfile transport",
2413 "require_lockfile");
2414 &handle_batch_and_bsmtp($hash);
2415 if (defined $$hash{"from_hack"} && $$hash{"from_hack"} eq "false")
2417 print STDOUT "#!!# no_from_hack replaced by check_string\n";
2418 $$hash{"check_string"} = "";
2420 delete $$hash{"from_hack"};
2423 # ---- Changes to the lmtp transport ----
2425 elsif ($driver eq "lmtp")
2427 if (defined $$hash{"batch"} && $$hash{"batch"} ne "none")
2429 $$hash{"batch_max"} = "100" if !defined $$hash{"batch_max"};
2430 $$hash{"batch_id"} = "\$domain" if $$hash{"batch"} eq "domain";
2434 $$hash{"batch_max"} = "1" if defined $$hash{"batch_max"};
2436 delete $$hash{"batch"};
2439 # ---- Changes to the pipe transport ----
2441 elsif ($driver eq "pipe")
2443 &renamed($hash, "prefix", "message_prefix");
2444 &renamed($hash, "suffix", "message_suffix");
2445 &handle_batch_and_bsmtp($hash);
2446 if (defined $$hash{"from_hack"} && $$hash{"from_hack"} eq "false")
2448 print STDOUT "#!!# no_from_hack replaced by check_string\n";
2449 $$hash{"check_string"} = "";
2451 delete $$hash{"from_hack"};
2454 # ---- Changes to the smtp transport ----
2456 elsif ($driver eq "smtp")
2458 &abolished($hash, "An smtp transport", "mx_domains");
2459 &renamed($hash, "service", "port");
2460 &renamed($hash, "tls_verify_ciphers", "tls_require_ciphers");
2461 &renamed($hash, "authenticate_hosts", "hosts_try_auth");
2463 if (defined $$hash{"batch_max"})
2465 print STDOUT "#!!# batch_max renamed connection_max_messages\n";
2466 $$hash{"connection_max_messages"} = $$hash{"batch_max"};
2467 delete $$hash{"batch_max"};
2470 foreach $o ("hosts_try_auth", "hosts_avoid_tls", "hosts_require_tls",
2471 "mx_domains", "serialize_hosts")
2473 $$hash{$o} = &no_expand_regex($$hash{$o}) if defined $$hash{$o};
2477 &outdriver($driverlist{"$prefix$name"});
2481 # Skip past any continuation lines for an option setting
2482 while ($c[$i] =~ /\\\s*$/s)
2485 $i++ while ($c[$i] =~ /^\s*#/);
2490 # -------- The retry configuration --------
2493 for ($i = $retry_start; $i < $clen && $i < $rewrite_start - 1; $i++)
2497 if ($c[$i] !~ /^\s*(#|$)/)
2499 print STDOUT "\nbegin retry\n\n";
2503 &print_no_expand($c[$i]);
2506 print STDOUT "\n# End of Exim 4 configuration\n";
2508 print STDERR "\n*******************************************************\n";
2509 print STDERR "***** Please review the generated file carefully. *****\n";
2510 print STDERR "*******************************************************\n\n";