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