Home | History | Annotate | Line # | Download | only in mantools
      1 #!/usr/bin/perl
      2 
      3 # Outputs missing mail_params.h lines for the proxy_read_maps default
      4 # value.
      5 
      6 # First, get the proxy_read_maps default value from postconf command
      7 # output. This gives us a list of parameter names that are already
      8 # present in the proxy_read_maps default value.
      9 
     10 $command = "bin/postconf -dh proxy_read_maps | tr ' ' '\12'";
     11 open(PROXY_READ_MAPS, "$command|")
     12 	|| die "can't execute $command: !$\n";
     13 while (<PROXY_READ_MAPS>) {
     14     chomp;
     15     next unless /^\$(.+)$/;
     16     $proxy_read_maps{$1} = 1;
     17 }
     18 close(PROXY_READ_MAPS) || die "close $command: $!\n";
     19 
     20 # Parse mail_params.h, to determine the VAR_XXX name for each main.cf
     21 # parameter. Ignore parameter names composed from multiple strings,
     22 # unless the parameter name is known to be of interest. The code
     23 # block after this one will discover if we ignored too much.
     24 
     25 $mail_params_h = "src/global/mail_params.h";
     26 open(MAIL_PARAMS, "<$mail_params_h")
     27     || die "Open $mail_params_h";
     28 while ($line = <MAIL_PARAMS>) {
     29     chomp;
     30     if ($line =~ /^#define\s+(VAR\S+)\s+"(\S+)"\s*(\/\*.*\*\/)?$/) {
     31 	$mail_params{$2} = $1;
     32     } elsif ($line =~/^#define\s+(VAR\S+)\s+"address_verify_"\s+VAR_SND_DEF_XPORT_MAPS/) {
     33 	$mail_params{"address_verify_sender_dependent_default_transport_maps"} = $1;
     34     } elsif ($line =~/^#define\s+(VAR\S+)\s+"sender_dependent_"\s+VAR_DEF_TRANSPORT\s+"_maps"/) {
     35 	$mail_params{"sender_dependent_default_transport_maps"} = $1;
     36     }
     37 }
     38 close(MAIL_PARAMS) || die "close $mail_params_h: !$\n";
     39 
     40 # Produce mail_params.h lines for all parameters that have names
     41 # ending in _maps and that are not listed in proxy_read_maps. We get
     42 # the full parameter name list from postconf command output. Abort
     43 # if we discover that our mail_params.h parser missed something.
     44 
     45 $command = "bin/postconf -H";
     46 open(ALL_PARAM_NAMES, "$command|")
     47          || die "can't execute $command: !$\n";  
     48 while ($param_name = <ALL_PARAM_NAMES>) { 
     49     chomp($param_name);
     50     next unless ($param_name =~ /_(checks|delivery_status_filter|reply_filter|command_filter|maps)$/);
     51     next if ($param_name =~ /^(proxy_read|proxy_write)_maps$/);
     52     next if defined($proxy_read_maps{$param_name});
     53     die "unknown parameter: $param_name\n"
     54 	unless defined($mail_params{$param_name});
     55     print "\t\t\t\t\" \$\" $mail_params{$param_name} \\\n";
     56 }
     57