New configs for Xenial (16.04)
[sysconfig/postfix.git] / postfix-script
index 86b59c6b8628a36327ac52385b4e2255628a8d67..e4016a6ac74b874a4d5fdaf50a10a7d1a7115c15 100755 (executable)
@@ -71,6 +71,17 @@ cd $config_directory || {
        $FATAL no Postfix configuration directory $config_directory!
        exit 1
 }
+case $shlib_directory in
+no) ;;
+ *) cd $shlib_directory || {
+       $FATAL no Postfix shared-library directory $shlib_directory!
+        exit 1
+    }
+esac
+cd $meta_directory || {
+       $FATAL no Postfix meta directory $meta_directory!
+       exit 1
+}
 cd $queue_directory || {
        $FATAL no Postfix queue directory $queue_directory!
        exit 1
@@ -268,43 +279,55 @@ check-fatal)
 check-warn)
        # This command is NOT part of the public interface.
 
-       todo="$config_directory $queue_directory $queue_directory/pid"
-       test -n "$check_shared_files" && todo="$daemon_directory $todo"
+       # Check Postfix root-owned directory owner/permissions.
 
-       for dir in $todo
-       do
-               ls -lLd $dir | (grep " root " >/dev/null ||
-                   $WARN not owned by root: $dir)
-       done
+       find $queue_directory/. $queue_directory/pid \
+           -prune ! -user root \
+           -exec $WARN not owned by root: {} \;
+
+       find $queue_directory/. $queue_directory/pid \
+           -prune \( -perm -020 -o -perm -002 \) \
+           -exec $WARN group or other writable: {} \;
 
-       # Some people break Postfix's security model.
-       ls -lLd $queue_directory | egrep '^.....(w|...w)' >/dev/null && \
-               $WARN group or other writable: $queue_directory
+       # Check Postfix root-owned directory tree owner/permissions.
 
-       todo="$config_directory/*"
-       test -n "$check_shared_files" && todo="$daemon_directory/* $todo"
+       todo="$config_directory/."
+       test -n "$check_shared_files" && {
+               todo="$daemon_directory/. $meta_directory/. $todo"
+               test "$shlib_directory" = "no" || 
+                   todo="$shlib_directory/. $todo"
+       }
+       todo=`echo "$todo" | tr ' ' '\12' | sort -u`
 
        find $todo ! -user root \
-               -exec $WARN not owned by root: {} \;
+           -exec $WARN not owned by root: {} \;
 
-       todo="$config_directory/."
-       test -n "$check_shared_files" && todo="$daemon_directory/. $todo"
+       find $todo \( -perm -020 -o -perm -002 \) \
+           -exec $WARN group or other writable: {} \;
 
-       find $todo \
-               \( -perm -020 -o -perm -002 \) -type f \
-               -exec $WARN group or other writable: {} \;
+       # Check Postfix mail_owner-owned directory tree owner/permissions.
 
        find $data_directory/. ! -user $mail_owner \
            -exec $WARN not owned by $mail_owner: {} \;
 
-       ls -lLd $data_directory | egrep '^.....(w|...w)' >/dev/null && \
-               $WARN group or other writable: $data_directory
+       find $data_directory/. \( -perm -020 -o -perm -002 \) \
+           -exec $WARN group or other writable: {} \;
+
+       # Check Postfix mail_owner-owned directory tree owner.
 
        find `ls -d $queue_directory/* | \
            egrep '/(saved|incoming|active|defer|deferred|bounce|hold|trace|corrupt|public|private|flush)$'` \
            ! \( -type p -o -type s \) ! -user $mail_owner \
                -exec $WARN not owned by $mail_owner: {} \;
 
+       # WARNING: this should not descend into the maildrop directory.
+       # maildrop is the least trusted Postfix directory.
+
+       find $queue_directory/maildrop -prune ! -user $mail_owner \
+           -exec $WARN not owned by $mail_owner: $queue_directory/maildrop \;
+
+       # Check Postfix setgid_group-owned directory and file group/permissions.
+
        todo="$queue_directory/public $queue_directory/maildrop"
        test -n "$check_shared_files" && 
           todo="$command_directory/postqueue $command_directory/postdrop $todo"
@@ -318,33 +341,27 @@ check-warn)
            -prune ! -perm -02111 \
            -exec $WARN not set-gid or not owner+group+world executable: {} \;
 
-       for name in `ls -d $queue_directory/* | \
-           egrep '/(bin|etc|lib|usr)$'` ; \
-       do \
-           find $name ! -user root \
-               -exec $WARN not owned by root: {} \; ; \
-       done
-
-       # WARNING: this should not descend into the maildrop directory.
-       # maildrop is the least trusted Postfix directory.
-
-       find $queue_directory/maildrop/. -prune ! -user $mail_owner \
-           -exec $WARN not owned by $mail_owner: $queue_directory/maildrop \;
+       # Check non-Postfix root-owned directory tree owner/content.
 
        for dir in bin etc lib sbin usr
        do
-               test -d $dir && find $dir -type f -print | while read path
+           test -d $dir && {
+               find $dir ! -user root \
+                   -exec $WARN not owned by root: $queue_directory/{} \;
+
+               find $dir -type f -print | while read path
                do
-                       test -f /$path && {
-                           cmp -s $path /$path || 
-                               $WARN $queue_directory/$path and /$path differ
-                       }
+                   test -f /$path && {
+                       cmp -s $path /$path || 
+                           $WARN $queue_directory/$path and /$path differ
+                   }
                done
+           }
        done
 
        find corrupt -type f -exec $WARN damaged message: {} \;
 
-       # XXX also: look for weird stuff, weird permissions, etc.
+       # Check for non-Postfix MTA remnants.
 
        test -n "$check_shared_files" -a -f /usr/sbin/sendmail -a \
                -f /usr/lib/sendmail && {
@@ -366,6 +383,11 @@ post-install)
        $daemon_directory/post-install "$@"
        ;;
 
+tls)
+       shift
+       $daemon_directory/postfix-tls-script "$@"
+       ;;
+
 /*)
        # Currently not part of the public interface.
        "$@"