1#!/bin/sh 2# $NetBSD: post-install,v 1.1.1.6 2014/07/06 19:27:40 tron Exp $ 3# 4 5# To view the formatted manual page of this file, type: 6# POSTFIXSOURCE/mantools/srctoman - post-install | nroff -man 7 8#++ 9# NAME 10# post-install 11# SUMMARY 12# Postfix post-installation script 13# SYNOPSIS 14# postfix post-install [name=value] command ... 15# DESCRIPTION 16# The post-install script performs the finishing touch of a Postfix 17# installation, after the executable programs and configuration 18# files are installed. Usage is one of the following: 19# .IP o 20# While installing Postfix from source code on the local machine, the 21# script is run by the postfix-install script to update selected file 22# or directory permissions and to update Postfix configuration files. 23# .IP o 24# While installing Postfix from a pre-built package, the script is run 25# by the package management procedure to set all file or directory 26# permissions and to update Postfix configuration files. 27# .IP o 28# The script can be used to change installation parameter settings such 29# as mail_owner or setgid_group after Postfix is already installed. 30# .IP o 31# The script can be used to upgrade configuration files and to upgrade 32# file/directory permissions of a secondary Postfix instance. 33# .IP o 34# At Postfix start-up time, the script is run from "postfix check" to 35# create missing queue directories. 36# .PP 37# The post-install script is controlled by installation parameters. 38# Specific parameters are described at the end of this document. 39# All installation parameters must be specified ahead of time via 40# one of the methods described below. 41# 42# Arguments 43# .IP create-missing 44# Create missing queue directories with ownerships and permissions 45# according to the contents of $daemon_directory/postfix-files 46# and optionally in $daemon_directory/postfix-files.d/*, using 47# the mail_owner and setgid_group parameter settings from the 48# command line, process environment or from the installed 49# main.cf file. 50# 51# This is required at Postfix start-up time. 52# .IP set-permissions 53# Set all file/directory ownerships and permissions according to the 54# contents of $daemon_directory/postfix-files and optionally 55# in $daemon_directory/postfix-files.d/*, using the mail_owner 56# and setgid_group parameter settings from the command line, 57# process environment or from the installed main.cf file. 58# Implies create-missing. 59# 60# This is required when installing Postfix from a pre-built package, 61# or when changing the mail_owner or setgid_group installation parameter 62# settings after Postfix is already installed. 63# .IP upgrade-permissions 64# Update ownership and permission of existing files/directories as 65# specified in $daemon_directory/postfix-files and optionally 66# in $daemon_directory/postfix-files.d/*, using the mail_owner 67# and setgid_group parameter settings from the command line, 68# process environment or from the installed main.cf file. 69# Implies create-missing. 70# 71# This is required when upgrading an existing Postfix instance. 72# .IP upgrade-configuration 73# Edit the installed main.cf and master.cf files, in order to account 74# for missing services and to fix deprecated parameter settings. 75# 76# This is required when upgrading an existing Postfix instance. 77# .IP upgrade-source 78# Short-hand for: upgrade-permissions upgrade-configuration. 79# 80# This is recommended when upgrading Postfix from source code. 81# .IP upgrade-package 82# Short-hand for: set-permissions upgrade-configuration. 83# 84# This is recommended when upgrading Postfix from a pre-built package. 85# .IP first-install-reminder 86# Remind the user that they still need to configure main.cf and the 87# aliases file, and that newaliases still needs to be run. 88# 89# This is recommended when Postfix is installed for the first time. 90# MULTIPLE POSTFIX INSTANCES 91# .ad 92# .fi 93# Multiple Postfix instances on the same machine can share command and 94# daemon program files but must have separate configuration and queue 95# directories. 96# 97# To create a secondary Postfix installation on the same machine, 98# copy the configuration files from the primary Postfix instance to 99# a secondary configuration directory and execute: 100# 101# postfix post-install config_directory=secondary-config-directory \e 102# .in +4 103# queue_directory=secondary-queue-directory \e 104# .br 105# create-missing 106# .PP 107# This creates secondary Postfix queue directories, sets their access 108# permissions, and saves the specified installation parameters to the 109# secondary main.cf file. 110# 111# Be sure to list the secondary configuration directory in the 112# alternate_config_directories parameter in the primary main.cf file. 113# 114# To upgrade a secondary Postfix installation on the same machine, 115# execute: 116# 117# postfix post-install config_directory=secondary-config-directory \e 118# .in +4 119# upgrade-permissions upgrade-configuration 120# INSTALLATION PARAMETER INPUT METHODS 121# .ad 122# .fi 123# Parameter settings can be specified through a variety of 124# mechanisms. In order of decreasing precedence these are: 125# .IP "command line" 126# Parameter settings can be given as name=value arguments on 127# the post-install command line. These have the highest precedence. 128# Settings that override the installed main.cf file are saved. 129# .IP "process environment" 130# Parameter settings can be given as name=value environment 131# variables. 132# Settings that override the installed main.cf file are saved. 133# .IP "installed configuration files" 134# If a parameter is not specified via the command line or via the 135# process environment, post-install will attempt to extract its 136# value from the already installed Postfix main.cf configuration file. 137# These settings have the lowest precedence. 138# INSTALLATION PARAMETER DESCRIPTION 139# .ad 140# .fi 141# The description of installation parameters is as follows: 142# .IP config_directory 143# The directory for Postfix configuration files. 144# .IP daemon_directory 145# The directory for Postfix daemon programs. This directory 146# should not be in the command search path of any users. 147# .IP command_directory 148# The directory for Postfix administrative commands. This 149# directory should be in the command search path of adminstrative users. 150# .IP queue_directory 151# The directory for Postfix queues. 152# .IP data_directory 153# The directory for Postfix writable data files (caches, etc.). 154# .IP sendmail_path 155# The full pathname for the Postfix sendmail command. 156# This is the Sendmail-compatible mail posting interface. 157# .IP newaliases_path 158# The full pathname for the Postfix newaliases command. 159# This is the Sendmail-compatible command to build alias databases 160# for the Postfix local delivery agent. 161# .IP mailq_path 162# The full pathname for the Postfix mailq command. 163# This is the Sendmail-compatible command to list the mail queue. 164# .IP mail_owner 165# The owner of the Postfix queue. Its numerical user ID and group ID 166# must not be used by any other accounts on the system. 167# .IP setgid_group 168# The group for mail submission and for queue management commands. 169# Its numerical group ID must not be used by any other accounts on the 170# system, not even by the mail_owner account. 171# .IP html_directory 172# The directory for the Postfix HTML files. 173# .IP manpage_directory 174# The directory for the Postfix on-line manual pages. 175# .IP sample_directory 176# The directory for the Postfix sample configuration files. 177# This feature is obsolete as of Postfix 2.1. 178# .IP readme_directory 179# The directory for the Postfix README files. 180# SEE ALSO 181# postfix-install(1) Postfix primary installation script. 182# FILES 183# $config_directory/main.cf, Postfix installation parameters. 184# $daemon_directory/postfix-files, installation control file. 185# $daemon_directory/postfix-files.d/*, optional control files. 186# $config_directory/install.cf, obsolete configuration file. 187# LICENSE 188# .ad 189# .fi 190# The Secure Mailer license must be distributed with this software. 191# AUTHOR(S) 192# Wietse Venema 193# IBM T.J. Watson Research 194# P.O. Box 704 195# Yorktown Heights, NY 10598, USA 196#-- 197 198umask 022 199 200PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd 201SHELL=/bin/sh 202IFS=" 203" 204BACKUP_IFS="$IFS" 205debug=: 206#debug=echo 207MOST_PARAMETERS="command_directory daemon_directory data_directory 208 html_directory mail_owner mailq_path manpage_directory 209 newaliases_path queue_directory readme_directory sample_directory 210 sendmail_path setgid_group" 211NON_SHARED="config_directory queue_directory data_directory" 212 213USAGE="Usage: $0 [name=value] command 214 create-missing Create missing queue directories. 215 upgrade-source When installing or upgrading from source code. 216 upgrade-package When installing or upgrading from pre-built package. 217 first-install-reminder Remind of mandatory first-time configuration steps. 218 name=value Specify an installation parameter". 219 220# Process command-line options and parameter settings. Work around 221# brain damaged shells. "IFS=value command" should not make the 222# IFS=value setting permanent. But some broken standard allows it. 223 224create=; set_perms=; upgrade_perms=; upgrade_conf=; first_install_reminder= 225obsolete=; keep_list=; 226 227for arg 228do 229 case $arg in 230 *=*) IFS= eval $arg; IFS="$BACKUP_IFS";; 231 create-missing) create=1;; 232 set-perm*) create=1; set_perms=1;; 233 upgrade-perm*) create=1; upgrade_perms=1;; 234 upgrade-conf*) upgrade_conf=1;; 235 upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;; 236 upgrade-package) create=1; upgrade_conf=1; set_perms=1;; 237 first-install*) first_install_reminder=1;; 238 *) echo "$0: Error: $USAGE" 1>&2; exit 1;; 239 esac 240 shift 241done 242 243# Sanity checks. 244 245test -n "$create$upgrade_conf$first_install_reminder" || { 246 echo "$0: Error: $USAGE" 1>&2 247 exit 1 248} 249 250# Bootstrapping problem. 251 252if [ -n "$command_directory" ] 253then 254 POSTCONF="$command_directory/postconf" 255else 256 POSTCONF="postconf" 257fi 258 259$POSTCONF -d mail_version >/dev/null 2>/dev/null || { 260 echo $0: Error: no $POSTCONF command found. 1>&2 261 echo Re-run this command as $0 command_directory=/some/where. 1>&2 262 exit 1 263} 264 265# Also used to require license etc. files only in the default instance. 266 267def_config_directory=`$POSTCONF -d -h config_directory` || exit 1 268test -n "$config_directory" || 269 config_directory="$def_config_directory" 270 271test -d "$config_directory" || { 272 echo $0: Error: $config_directory is not a directory. 1>&2 273 exit 1 274} 275 276# If this is a secondary instance, don't touch shared files. 277# XXX Solaris does not have "test -e". 278 279instances=`test ! -f $def_config_directory/main.cf || 280 $POSTCONF -c $def_config_directory -h multi_instance_directories | 281 sed 's/,/ /'` || exit 1 282 283update_shared_files=1 284for name in $instances 285do 286 case "$name" in 287 "$def_config_directory") ;; 288 "$config_directory") update_shared_files=; break;; 289 esac 290done 291 292test -f $daemon_directory/postfix-files || { 293 echo $0: Error: $daemon_directory/postfix-files is not a file. 1>&2 294 exit 1 295} 296 297# SunOS5 fmt(1) truncates lines > 1000 characters. 298 299fake_fmt() { 300 sed ' 301 :top 302 /^\( *\)\([^ ][^ ]*\) */{ 303 s//\1\2\ 304\1/ 305 P 306 D 307 b top 308 } 309 ' | fmt 310} 311 312case `uname -s` in 313HP-UX*) FMT=cat;; 314SunOS*) FMT=fake_fmt;; 315 *) FMT=fmt;; 316esac 317 318# If a parameter is not set via the command line or environment, 319# try to use settings from installed configuration files. 320 321# Extract parameter settings from the obsolete install.cf file, as 322# a transitional aid. 323 324grep setgid_group $config_directory/main.cf >/dev/null 2>&1 || { 325 test -f $config_directory/install.cf && { 326 for name in sendmail_path newaliases_path mailq_path setgid manpages 327 do 328 eval junk=\$$name 329 case "$junk" in 330 "") eval unset $name;; 331 esac 332 eval : \${$name="\`. $config_directory/install.cf; echo \$$name\`"} \ 333 || exit 1 334 done 335 : ${setgid_group=$setgid} 336 : ${manpage_directory=$manpages} 337 } 338} 339 340# Extract parameter settings from the installed main.cf file. 341 342test -f $config_directory/main.cf && { 343 for name in $MOST_PARAMETERS 344 do 345 eval junk=\$$name 346 case "$junk" in 347 "") eval unset $name;; 348 esac 349 eval : \${$name=\`$POSTCONF -c $config_directory -h $name\`} || exit 1 350 done 351} 352 353# Sanity checks 354 355case $manpage_directory in 356 no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2 357 echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;; 358esac 359 360case $setgid_group in 361 no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2 362 echo Try again with \"$0 setgid_group=groupname ...\" 1>&2; exit 1;; 363esac 364 365for path in "$daemon_directory" "$command_directory" "$queue_directory" \ 366 "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" 367do 368 case "$path" in 369 /*) ;; 370 *) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;; 371 esac 372done 373 374for path in "$html_directory" "$readme_directory" 375do 376 case "$path" in 377 /*) ;; 378 no) ;; 379 *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2; exit 1;; 380 esac 381done 382 383# Find out what parameters were not specified via command line, 384# via environment, or via installed configuration files. 385 386missing= 387for name in $MOST_PARAMETERS 388do 389 eval test -n \"\$$name\" || missing="$missing $name" 390done 391 392# All parameters must be specified at this point. 393 394test -n "$non_interactive" -a -n "$missing" && { 395 cat <<EOF | ${FMT} 1>&2 396$0: Error: some required installation parameters are not defined. 397 398- Either the parameters need to be given in the $config_directory/main.cf 399file from a recent Postfix installation, 400 401- Or the parameters need to be specified through the process 402environment. 403 404- Or the parameters need to be specified as name=value arguments 405on the $0 command line, 406 407The following parameters were missing: 408 409 $missing 410 411EOF 412 exit 1 413} 414 415POSTCONF="$command_directory/postconf" 416 417# Save settings, allowing command line/environment override. 418 419override= 420for name in $MOST_PARAMETERS 421do 422 eval test \"\$$name\" = \"`$POSTCONF -c $config_directory -h $name`\" || { 423 override=1 424 break 425 } 426done 427 428test -n "$override" && { 429 $POSTCONF -c $config_directory -e \ 430 "daemon_directory = $daemon_directory" \ 431 "command_directory = $command_directory" \ 432 "queue_directory = $queue_directory" \ 433 "data_directory = $data_directory" \ 434 "mail_owner = $mail_owner" \ 435 "setgid_group = $setgid_group" \ 436 "sendmail_path = $sendmail_path" \ 437 "mailq_path = $mailq_path" \ 438 "newaliases_path = $newaliases_path" \ 439 "html_directory = $html_directory" \ 440 "manpage_directory = $manpage_directory" \ 441 "sample_directory = $sample_directory" \ 442 "readme_directory = $readme_directory" \ 443 || exit 1 444} 445 446# Use file/directory status information in $daemon_directory/postfix-files. 447 448test -n "$create" && { 449 postfix_files_d=$daemon_directory/postfix-files.d 450 for postfix_file in $daemon_directory/postfix-files \ 451 `test -d $postfix_files_d && { find $postfix_files_d -type f | sort; }` 452 do 453 exec <$postfix_file || exit 1 454 while IFS=: read path type owner group mode flags junk 455 do 456 IFS="$BACKUP_IFS" 457 set_permission= 458 # Skip comments. Skip shared files, if updating a secondary instance. 459 case $path in 460 [$]*) case "$update_shared_files" in 461 1) $debug keep non-shared or shared $path;; 462 *) non_shared= 463 for name in $NON_SHARED 464 do 465 case $path in 466 "\$$name"*) non_shared=1; break;; 467 esac 468 done 469 case "$non_shared" in 470 1) $debug keep non-shared $path;; 471 *) $debug skip shared $path; continue;; 472 esac;; 473 esac;; 474 *) continue;; 475 esac 476 # Skip hard links and symbolic links. 477 case $type in 478 [hl]) continue;; 479 [df]) ;; 480 *) echo unknown type $type for $path in $postfix_file 1>&2; exit 1;; 481 esac 482 # Expand $name, and canonicalize null fields. 483 for name in path owner group flags 484 do 485 eval junk=\${$name} 486 case $junk in 487 [$]*) eval $name=$junk;; 488 -) eval $name=;; 489 *) ;; 490 esac 491 done 492 # Skip uninstalled files. 493 case $path in 494 no|no/*) continue;; 495 esac 496 # Pick up the flags. 497 case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac 498 case $flags in *c*) create_flag=1;; *) create_flag=;; esac 499 case $flags in *r*) recursive="-R";; *) recursive=;; esac 500 case $flags in *o*) obsolete_flag=1;; *) obsolete_flag=;; esac 501 case $flags in *[1i]*) test ! -r "$path" -a "$config_directory" != \ 502 "$def_config_directory" && continue;; esac 503 # Flag obsolete objects. XXX Solaris 2..9 does not have "test -e". 504 if [ -n "$obsolete_flag" ] 505 then 506 test -r $path -a "$type" != "d" && obsolete="$obsolete $path" 507 continue; 508 else 509 keep_list="$keep_list $path" 510 fi 511 # Create missing directories with proper owner/group/mode settings. 512 if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ] 513 then 514 mkdir $path || exit 1 515 set_permission=1 516 # Update all owner/group/mode settings. 517 elif [ -n "$set_perms" ] 518 then 519 set_permission=1 520 # Update obsolete owner/group/mode settings. 521 elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ] 522 then 523 set_permission=1 524 fi 525 test -n "$set_permission" && { 526 chown $recursive $owner $path || exit 1 527 test -z "$group" || chgrp $recursive $group $path || exit 1 528 # Don't "chmod -R"; queue file status is encoded in mode bits. 529 if [ "$type" = "d" -a -n "$recursive" ] 530 then 531 find $path -type d -exec chmod $mode "{}" ";" 532 else 533 chmod $mode $path 534 fi || exit 1 535 } 536 done 537 IFS="$BACKUP_IFS" 538 done 539} 540 541# Upgrade existing Postfix configuration files if necessary. 542 543test -n "$upgrade_conf" && { 544 545 # Postfix 2.0. 546 # Add missing relay service to master.cf. 547 548 grep '^relay' $config_directory/master.cf >/dev/null || { 549 echo Editing $config_directory/master.cf, adding missing entry for relay service 550 cat >>$config_directory/master.cf <<EOF || exit 1 551relay unix - - n - - smtp 552EOF 553 } 554 555 # Postfix 1.1. 556 # Add missing flush service to master.cf. 557 558 grep '^flush.*flush' $config_directory/master.cf >/dev/null || { 559 echo Editing $config_directory/master.cf, adding missing entry for flush service 560 cat >>$config_directory/master.cf <<EOF || exit 1 561flush unix - - n 1000? 0 flush 562EOF 563 } 564 565 # Postfix 2.1. 566 # Add missing trace service to master.cf. 567 568 grep 'trace.*bounce' $config_directory/master.cf >/dev/null || { 569 echo Editing $config_directory/master.cf, adding missing entry for trace service 570 cat >>$config_directory/master.cf <<EOF || exit 1 571trace unix - - n - 0 bounce 572EOF 573 } 574 575 # Postfix 2.1. 576 # Add missing verify service to master.cf. 577 578 grep '^verify.*verify' $config_directory/master.cf >/dev/null || { 579 echo Editing $config_directory/master.cf, adding missing entry for verify service 580 cat >>$config_directory/master.cf <<EOF || exit 1 581verify unix - - n - 1 verify 582EOF 583 } 584 585 # Postfix 2.1. 586 # Fix verify service process limit. 587 588 grep '^verify.*[ ]0[ ]*verify' \ 589 $config_directory/master.cf >/dev/null && { 590 echo Editing $config_directory/master.cf, setting verify process limit to 1 591 ed $config_directory/master.cf <<EOF || exit 1 592/^verify.*[ ]0[ ]*verify/ 593s/\([ ]\)0\([ ]\)/\11\2/ 594p 595w 596q 597EOF 598 } 599 600 # Postfix 1.1. 601 # Change privileged pickup service into unprivileged. 602 603 grep "^pickup[ ]*fifo[ ]*n[ ]*n" \ 604 $config_directory/master.cf >/dev/null && { 605 echo Editing $config_directory/master.cf, making the pickup service unprivileged 606 ed $config_directory/master.cf <<EOF || exit 1 607/^pickup[ ]*fifo[ ]*n[ ]*n/ 608s/\(n[ ]*\)n/\1-/ 609p 610w 611q 612EOF 613 } 614 615 # Postfix 1.1. 616 # Change private cleanup and flush services into public. 617 618 for name in cleanup flush 619 do 620 grep "^$name[ ]*unix[ ]*[-y]" \ 621 $config_directory/master.cf >/dev/null && { 622 echo Editing $config_directory/master.cf, making the $name service public 623 ed $config_directory/master.cf <<EOF || exit 1 624/^$name[ ]*unix[ ]*[-y]/ 625s/[-y]/n/ 626p 627w 628q 629EOF 630 } 631 done 632 633 # Postfix 2.2. 634 # File systems have improved since Postfix came out, and all we 635 # require now is that defer and deferred are hashed because those 636 # can contain lots of files. 637 638 found=`$POSTCONF -c $config_directory -h hash_queue_names` 639 missing= 640 (echo "$found" | grep defer >/dev/null) || missing="$missing defer" 641 (echo "$found" | grep deferred>/dev/null)|| missing="$missing deferred" 642 test -n "$missing" && { 643 echo fixing main.cf hash_queue_names for missing $missing 644 $POSTCONF -c $config_directory -e hash_queue_names="$found$missing" || 645 exit 1 646 } 647 648 # Turn on safety nets for new features that could bounce mail that 649 # would be accepted by a previous Postfix version. 650 651 # [The "unknown_local_recipient_reject_code = 450" safety net, 652 # introduced with Postfix 2.0 and deleted after Postfix 2.3.] 653 654 # Postfix 2.0. 655 # Add missing proxymap service to master.cf. 656 657 grep '^proxymap.*proxymap' $config_directory/master.cf >/dev/null || { 658 echo Editing $config_directory/master.cf, adding missing entry for proxymap service 659 cat >>$config_directory/master.cf <<EOF || exit 1 660proxymap unix - - n - - proxymap 661EOF 662 } 663 664 # Postfix 2.1. 665 # Add missing anvil service to master.cf. 666 667 grep '^anvil.*anvil' $config_directory/master.cf >/dev/null || { 668 echo Editing $config_directory/master.cf, adding missing entry for anvil service 669 cat >>$config_directory/master.cf <<EOF || exit 1 670anvil unix - - n - 1 anvil 671EOF 672 } 673 674 # Postfix 2.2. 675 # Add missing scache service to master.cf. 676 677 grep '^scache.*scache' $config_directory/master.cf >/dev/null || { 678 echo Editing $config_directory/master.cf, adding missing entry for scache service 679 cat >>$config_directory/master.cf <<EOF || exit 1 680scache unix - - n - 1 scache 681EOF 682 } 683 684 # Postfix 2.2. 685 # Add missing discard service to master.cf. 686 687 grep '^discard.*discard' $config_directory/master.cf >/dev/null || { 688 echo Editing $config_directory/master.cf, adding missing entry for discard service 689 cat >>$config_directory/master.cf <<EOF || exit 1 690discard unix - - n - - discard 691EOF 692 } 693 694 # Postfix 2.2. 695 # Update the tlsmgr fifo->unix service. 696 697 grep "^tlsmgr[ ]*fifo[ ]" \ 698 $config_directory/master.cf >/dev/null && { 699 echo Editing $config_directory/master.cf, updating the tlsmgr from fifo to unix service 700 ed $config_directory/master.cf <<EOF || exit 1 701/^tlsmgr[ ]*fifo[ ]/ 702s/fifo/unix/ 703s/[0-9][0-9]*/&?/ 704p 705w 706q 707EOF 708 } 709 710 # Postfix 2.2. 711 # Add missing tlsmgr service to master.cf. 712 713 grep '^tlsmgr.*tlsmgr' $config_directory/master.cf >/dev/null || { 714 echo Editing $config_directory/master.cf, adding missing entry for tlsmgr service 715 cat >>$config_directory/master.cf <<EOF || exit 1 716tlsmgr unix - - n 1000? 1 tlsmgr 717EOF 718 } 719 720 # Postfix 2.2. 721 # Add missing retry service to master.cf. 722 723 grep '^retry.*error' $config_directory/master.cf >/dev/null || { 724 echo Editing $config_directory/master.cf, adding missing entry for retry service 725 cat >>$config_directory/master.cf <<EOF || exit 1 726retry unix - - n - - error 727EOF 728 } 729 730 # Postfix 2.5. 731 # Add missing proxywrite service to master.cf. 732 733 grep '^proxywrite.*proxymap' $config_directory/master.cf >/dev/null || { 734 echo Editing $config_directory/master.cf, adding missing entry for proxywrite service 735 cat >>$config_directory/master.cf <<EOF || exit 1 736proxywrite unix - - n - 1 proxymap 737EOF 738 } 739 740 # Postfix 2.5. 741 # Fix a typo in the default master.cf proxywrite entry. 742 743 grep '^proxywrite.*-[ ]*proxymap' $config_directory/master.cf >/dev/null && { 744 echo Editing $config_directory/master.cf, setting proxywrite process limit to 1 745 ed $config_directory/master.cf <<EOF || exit 1 746/^proxywrite.*-[ ]*proxymap/ 747s/-\([ ]*proxymap\)/1\1/ 748p 749w 750q 751EOF 752 } 753 754 # Postfix 2.8. 755 # Add missing postscreen service to master.cf. 756 757 grep '^#*smtp.*postscreen' $config_directory/master.cf >/dev/null || { 758 echo Editing $config_directory/master.cf, adding missing entry for postscreen TCP service 759 cat >>$config_directory/master.cf <<EOF || exit 1 760#smtp inet n - n - 1 postscreen 761EOF 762 } 763 764 # Postfix 2.8. 765 # Add missing smtpd (unix-domain) service to master.cf. 766 767 grep '^#*smtpd.*smtpd' $config_directory/master.cf >/dev/null || { 768 echo Editing $config_directory/master.cf, adding missing entry for smtpd unix-domain service 769 cat >>$config_directory/master.cf <<EOF || exit 1 770#smtpd pass - - n - - smtpd 771EOF 772 } 773 774 # Postfix 2.8. 775 # Add temporary dnsblog (unix-domain) service to master.cf. 776 777 grep '^#*dnsblog.*dnsblog' $config_directory/master.cf >/dev/null || { 778 echo Editing $config_directory/master.cf, adding missing entry for dnsblog unix-domain service 779 cat >>$config_directory/master.cf <<EOF || exit 1 780#dnsblog unix - - n - 0 dnsblog 781EOF 782 } 783 784 # Postfix 2.8. 785 # Add tlsproxy (unix-domain) service to master.cf. 786 787 grep '^#*tlsproxy.*tlsproxy' $config_directory/master.cf >/dev/null || { 788 echo Editing $config_directory/master.cf, adding missing entry for tlsproxy unix-domain service 789 cat >>$config_directory/master.cf <<EOF || exit 1 790#tlsproxy unix - - n - 0 tlsproxy 791EOF 792 } 793 794 # Report (but do not remove) obsolete files. 795 796 test -n "$obsolete" && { 797 cat <<EOF | ${FMT} 798 799 Note: the following files or directories still exist but are 800 no longer part of Postfix: 801 802 $obsolete 803 804EOF 805 } 806 807 # Postfix 2.9. 808 # Safety net for incompatible changes in IPv6 defaults. 809 # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO AVOID AN 810 # UNEXPECTED DROP IN PERFORMANCE AFTER UPGRADING FROM POSTFIX 811 # BEFORE 2.9. 812 # This code assumes that the default is "inet_protocols = ipv4" 813 # when IPv6 support is not compiled in. See util/sys_defs.h. 814 815 test "`$POSTCONF -dh inet_protocols`" = "ipv4" || 816 test -n "`$POSTCONF -c $config_directory -n inet_protocols`" || { 817 cat <<EOF | ${FMT} 818 COMPATIBILITY: editing $config_directory/main.cf, setting 819 inet_protocols=ipv4. Specify inet_protocols explicitly if you 820 want to enable IPv6. 821 In a future release IPv6 will be enabled by default. 822EOF 823 $POSTCONF -c $config_directory inet_protocols=ipv4 || exit 1 824 } 825 826# Disabled because unhelpful down-stream maintainers disable the safety net. 827# # Postfix 2.10. 828# # Safety net for incompatible changes due to the introduction 829# # of the smtpd_relay_restrictions feature to separate the 830# # mail relay policy from the spam blocking policy. 831# # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO PREVENT 832# # INBOUND MAIL FROM UNEXPECTEDLY BOUNCING AFTER UPGRADING FROM 833# # POSTFIX BEFORE 2.10. 834# test -n "`$POSTCONF -c $config_directory -n smtpd_relay_restrictions`" || { 835# cat <<EOF | ${FMT} 836# COMPATIBILITY: editing $config_directory/main.cf, overriding 837# smtpd_relay_restrictions to prevent inbound mail from 838# unexpectedly bouncing. 839# Specify an empty smtpd_relay_restrictions value to keep using 840# smtpd_recipient_restrictions as before. 841#EOF 842# $POSTCONF -c $config_directory "smtpd_relay_restrictions = \ 843# permit_mynetworks permit_sasl_authenticated \ 844# defer_unauth_destination" || exit 1 845# } 846} 847 848# A reminder if this is the first time Postfix is being installed. 849 850test -n "$first_install_reminder" && { 851 852 ALIASES=`$POSTCONF -c $config_directory -h alias_database | sed 's/^[^:]*://'` 853 NEWALIASES_PATH=`$POSTCONF -c $config_directory -h newaliases_path` 854 cat <<EOF | ${FMT} 855 856 Warning: you still need to edit myorigin/mydestination/mynetworks 857 parameter settings in $config_directory/main.cf. 858 859 See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html 860 for information about dialup sites or about sites inside a 861 firewalled network. 862 863 BTW: Check your $ALIASES file and be sure to set up aliases 864 that send mail for root and postmaster to a real person, then 865 run $NEWALIASES_PATH. 866 867EOF 868 869} 870 871exit 0 872