#!/bin/sh # postfinger - captures Postfix configuration for reporting errors # # Inspired by comments on the postfix-users mailing list. # Copyright (C) 2003 Simon J. Mudd (sjmudd@pobox.com) # With help from: # Matthias Andree # Victor Duchovni # Sasa Babic # Iņaki Arenaza # $Revision: 1.24 $ # # License: # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You may have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # # An on-line copy of the GNU General Public License can be found # http://www.fsf.org/copyleft/gpl.html. BACKUP_IFS=$IFS USAGE="Postfinger $Revision: 1.24 $: a Postfix configuration extraction utility Usage: postfinger [options] Options can be any of: --all Show all configuration information --system Show basic system environment (os/kernel/...) [default] --package Show packaging information [default] --locking Show mailbox locking methods --tables Show supported lookup tables --main Show main.cf non-default configuration values [default] --master Show master.cf configuration [default] --permissions Show some of the spool_directory permissions --libraries Show the Postfix libraries dependencies --nosystem Do not show basic system environment (os/kernel/...) --nomain Do not show main.cf non-default configuration values --nomaster Do not show master.cf configuration --nowarn Do not warn about private information being leaked to outsiders Mail bug reports and suggestions to ". system=1; package=1; locking=; tables=; main=1; master=1; permissions=; libraries=;warn=1 for arg do case $arg in --all) system=1; package=1; locking=1; tables=1; main=1; master=1; permissions=1; libraries=1; warn=1;; --system) system=1;; --package) package=1;; --locking) locking=1;; --tables) tables=1;; --main) main=1;; --master) master=1;; --permissions) permissions=1;; --libraries) libraries=1;; --nosystem) system=;; --nomain) main=;; --nomaster) master=;; --nowarn) warn=;; --help) echo "$USAGE"; exit 0;; *) echo "Error: $USAGE" 1>&2; exit 1;; esac shift done echo "Postfinger - Postfix Configuration on `LANG=C date`" echo '$Revision: 1.24 $' echo '' [ "$warn" = 1 ] && { cat </dev/null 2>/dev/null && { PACKAGE=`$DPKG -S $SMTPD | awk -F: '{print $1}' | head -n 1` PACKAGE_VER=`COLUMNS=132 $DPKG -l $PACKAGE | grep ii | awk '{print $3}'` echo "looks like this postfix comes from a deb package: $PACKAGE-$PACKAGE_VER" } } RPM= [ -x /bin/rpm ] && RPM=/bin/rpm [ -z "$RPM" ] && [ -x /usr/local/bin/rpm ] && RPM=/usr/local/bin/rpm [ -n "$RPM" ] && { $RPM -qf $SMTPD >/dev/null 2>/dev/null && \ echo "looks like this postfix comes from a RPM package: `$RPM -qf $SMTPD`" } BSDPKG= [ -x /usr/sbin/pkg_info ] && BSDPKG=/usr/sbin/pkg_info [ -n "$BSDPKG" ] && { $BSDPKG -q -W $SMTPD >/dev/null 2>/dev/null && \ echo "looks like this postfix comes from a BSD package: `$BSDPKG -q -W $SMTPD`" } echo "" } IFS=" " [ "$locking" = 1 ] && { echo "--Mailbox locking methods--" locking_methods=`$POSTCONF -l` echo $locking_methods echo "" } [ "$tables" = 1 ] && { echo "--Supported Lookup tables--" lookup_tables=`$POSTCONF -m` echo $lookup_tables echo "" } [ "$main" = 1 ] && { echo "--main.cf non-default parameters--" if [ "x`find . -prune \( -perm 020 -o -perm 002 \) -print`" != "x" ] then echo 2>&2 "do not run this in a public- or group-writable directory" exit 1 fi rm -f postfinger.$$.d postfinger.$$.n $POSTCONF -d | sort > postfinger.$$.d $POSTCONF -n | sort > postfinger.$$.n comm -13 postfinger.$$.d postfinger.$$.n rm -f postfinger.$$.d postfinger.$$.n echo "" } [ "$master" = 1 ] && { echo "--master.cf--" # Remove blank and commented lines to reduce the output # Note: the second grep contains a space followed by a tab character cat `$POSTCONF -h config_directory`/master.cf | \ grep -v '^#' | \ grep -v '^[ ]*$' echo "" } [ "$permissions" = 1 ] && { echo "--Specific file and directory permissions--" ls -ld `$POSTCONF -h queue_directory`/maildrop ls -ld `$POSTCONF -h queue_directory`/public ls -l `$POSTCONF -h queue_directory`/public 2>/dev/null || { echo 'WARNING: No access to $queue_directory/public' echo ' Try running postfinger as user root or postfix' } ls -ld `$POSTCONF -h queue_directory`/private ls -l `$POSTCONF -h queue_directory`/private 2>/dev/null || { echo 'WARNING: No access to $queue_directory/private' echo ' Try running postfinger as user root or postfix' } ls -l `$POSTCONF -h command_directory`/postdrop ls -l `$POSTCONF -h command_directory`/postqueue echo "" } [ "$libraries" = 1 ] && { echo "--Library dependencies--" echo "$SMTPD:" ldd $SMTPD || echo "WARNING: Can not find ldd. Check you have it installed and in your path" } echo "-- end of Postfinger output --"