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