#!/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 # Jorge Gordoy # $Revision: 1.29 $ # # 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. version_number=1.29 # don't use rcs version here version="version: ${version_number}" BACKUP_IFS=$IFS usage="postfinger ${version}: 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] --defaultsinmain Show main.cf defined values which are identical to defaults --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 --version print the version of postfinger being used and exit Mail bug reports and suggestions to ". system=1; package=1; locking=; tables=; main=1; master=1; permissions=; libraries=;warn=1;defaultsinmain= for arg do case $arg in --version) echo "postfinger ${version}"; exit 0;; --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;; --defaultsinmain) defaultsinmain=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 ${version} 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 | grep -v "documentation" | awk '{print $3}'` echo "looks like this postfix comes from 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 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 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 -o "${defaultsinmain}" = 1 ] && { 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 | tr -s [:blank:] | sort > postfinger.$$.d ${POSTCONF} -n | tr -s [:blank:] | sort > postfinger.$$.n [ "$main" = 1 ] && { echo "--main.cf non-default parameters--" comm -13 postfinger.$$.d postfinger.$$.n echo "" } [ "${defaultsinmain}" = 1 ] && { echo "--main.cf parameters defined as per defaults--" comm -12 postfinger.$$.d postfinger.$$.n echo "" } rm -f postfinger.$$.d postfinger.$$.n } [ "${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 --"