diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 12:06:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 12:06:34 +0000 |
commit | 5e61585d76ae77fd5e9e96ebabb57afa4d74880d (patch) | |
tree | 2b467823aaeebc7ef8bc9e3cabe8074eaef1666d /mantools/xpostdef | |
parent | Initial commit. (diff) | |
download | postfix-5e61585d76ae77fd5e9e96ebabb57afa4d74880d.tar.xz postfix-5e61585d76ae77fd5e9e96ebabb57afa4d74880d.zip |
Adding upstream version 3.5.24.upstream/3.5.24upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mantools/xpostdef')
-rwxr-xr-x | mantools/xpostdef | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/mantools/xpostdef b/mantools/xpostdef new file mode 100755 index 0000000..6c8873f --- /dev/null +++ b/mantools/xpostdef @@ -0,0 +1,121 @@ +#!/usr/bin/perl + +# Usage: xpostdef postconf.proto >postconf.proto.new + +# Update parameter default values in postconf prototype file. + +$POSTCONF="postconf"; + +# Read all the default parameter values. This also provides us with +# a list of all the parameters that postconf knows about. + +open(POSTCONF, "$POSTCONF -d|") || die "cannot run $POSTCONF -d: !$\n"; +while(<POSTCONF>) { + chop; + if (($name, $defval) = split(/\s+=\s+/, $_, 2)) { + $defval =~ s/&/\&/g; + $defval =~ s/</\</g; + $defval =~ s/>/\>/g; + $defval =~ s/\s+$//; + $defaults{$name} = $defval; + } else { + die "unexpected $POSTCONF output: $_\n"; + } +} +close(POSTCONF) || die "$POSTCONF failed: $!\n"; + +# Censor out default values that are system or version dependent, or +# that don't display well. + +$censored = <<EOF; +alias_database +alias_maps +command_directory +command_expansion_filter +config_directory +daemon_directory +default_database_type +default_rbl_reply +execution_directory_expansion_filter +export_environment +forward_expansion_filter +forward_path +html_directory +import_environment +mail_release_date +mail_spool_directory +mail_version +mailbox_delivery_lock +mailq_path +manpage_directory +mydomain +myhostname +mynetworks +newaliases_path +parent_domain_matches_subdomains +proxy_read_maps +queue_directory +readme_directory +sendmail_path +smtpd_expansion_filter +tls_random_source +virtual_mailbox_lock +milter_connect_macros +milter_helo_macros +milter_mail_macros +milter_rcpt_macros +milter_data_macros +milter_unknown_command_macros +milter_end_of_data_macros +EOF + +for $name (split(/\s+/, $censored)) { + $defaults{$name} = "see \"postconf -d\" output"; +} + +# Process the postconf prototype file, and update default values +# with output from the postconf command. Leave alone any defaults +# that postconf didn't know about. This can happen when conditional +# features have been compile time disabled. + +$name = $defval = $text = $line = ""; + +while(<>) { + if (/^%PARAM/) { + + # Print the updated parameter text. Keep the old default if + # postconf doesn't have a suitable one. + + if ($name) { + $defval = $defaults{$name} if (defined($defaults{$name})); + print "%PARAM $name $defval\n"; + } + print $text; + + # Reset the parameter name, default, and accumulated text. + + $name = $defval = $text = $line = ""; + + # Accumulate the parameter name and default value. + + do { + $_ =~ s/\s+$//; + $line .= " " . $_; + } while(($_ = <POSTCONF>) && /^../); + ($junk, $class, $name, $defval) = split(/\s+/, $line, 4); + } else { + + # Accumulate the text in the parameter definition. + + $_ =~ s/\s+$/\n/; + $text .= $_; + + } +} + +# Fix the last parameter. + +if ($name && $text) { + $defval = $defaults{$name} if (defined($defaults{$name})); + print "%PARAM $name $defval\n$text"; +} |