Changes from Bionic (Ubuntu 18.04)
[sysconfig/postfix.git] / postfix-script
index e4016a6ac74b874a4d5fdaf50a10a7d1a7115c15..dc8b83fa6b5643e0aac14a2f7d768b08dd3cfe39 100755 (executable)
 #      IBM T.J. Watson Research
 #      P.O. Box 704
 #      Yorktown Heights, NY 10598, USA
+#
+#      Wietse Venema
+#      Google, Inc.
+#      111 8th Avenue
+#      New York, NY 10011, USA
 #--
 
 # Avoid POSIX death due to SIGHUP when some parent process exits.
@@ -126,19 +131,19 @@ stop_msg)
 
 quick-start)
 
-       $daemon_directory/master -t 2>/dev/null || {
-               $FATAL the Postfix mail system is already running
-               exit 1
-       }
-       $daemon_directory/postfix-script quick-check || {
-               $FATAL Postfix integrity check failed!
-               exit 1
-       }
-       $INFO starting the Postfix mail system
-       $daemon_directory/master &
-       ;;
+       $daemon_directory/master -t 2>/dev/null || {
+               $FATAL the Postfix mail system is already running
+               exit 1
+       }
+       $daemon_directory/postfix-script quick-check || {
+               $FATAL Postfix integrity check failed!
+               exit 1
+       }
+       $INFO starting the Postfix mail system
+       $daemon_directory/master &
+       ;;
 
-start)
+start|start-fg)
 
        $daemon_directory/master -t 2>/dev/null || {
                $FATAL the Postfix mail system is already running
@@ -156,11 +161,28 @@ start)
                $daemon_directory/postfix-script check-warn
        fi
        $INFO starting the Postfix mail system
-       # NOTE: wait in foreground process to get the initialization status.
-       $daemon_directory/master -w || {
-           $FATAL "mail system startup failed"
-           exit 1
-       }
+       case $1 in
+       start)
+           # NOTE: wait in foreground process to get the initialization status.
+           $daemon_directory/master -w || {
+               $FATAL "mail system startup failed"
+               exit 1
+           }
+           ;;
+       start-fg)
+           # Foreground start-up is incompatible with multi-instance mode.
+           # We can't use "exec $daemon_directory/master" here: that would
+           # break process group management, and "postfix stop" would kill
+           # too many processes.
+           case $instances in
+           "") $daemon_directory/master
+               ;;
+            *) $FATAL "start-fg does not support multi_instance_directories"
+               exit 1
+               ;;
+           esac
+           ;;
+       esac
        ;;
 
 drain)
@@ -302,9 +324,14 @@ check-warn)
        find $todo ! -user root \
            -exec $WARN not owned by root: {} \;
 
-       find $todo \( -perm -020 -o -perm -002 \) \
+       # Handle symlinks separately
+       find -L $todo \( -perm -020 -o -perm -002 \) \
            -exec $WARN group or other writable: {} \;
 
+       find $todo -type l | while read f; do \
+           readlink "$f" | grep -q / && $WARN symlink leaves directory: "$f"; \
+       done; \
+
        # Check Postfix mail_owner-owned directory tree owner/permissions.
 
        find $data_directory/. ! -user $mail_owner \
@@ -394,8 +421,7 @@ tls)
        ;;
 
 *)
-       $ERROR "unknown command: '$1'"
-       $FATAL "usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration)"
+       $FATAL "unknown command: '$1'. Usage: postfix start (or stop, reload, abort, flush, check, status, set-permissions, upgrade-configuration)"
        exit 1
        ;;