#!/usr/local/bin/perl # postfinger.cgi # check postfix configuration require './postfix-lib.pl'; &ReadParse(); $System=$in{'system'}||1; $Package=$in{'package'}||1; $Locking=$in{'locking'}||0; $Tables=$in{'tables'}||0; $Main=$in{'main'}||1; $Master=$in{'master'}||1; $Permissions=$in{'permissions'}||0; $Libraries=$in{'libraries'}||0; $Warn=$in{'warn'}||1; $Defaultsinmain=$in{'defaultsinmain'}||1; $access{'postfinger'} || &error($text{'postfinger_ecannot'}); &header($text{'postfinger_title'}, ""); if ( !$in{'go'} ) { print "
\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Display Options:
System \n"; printf " %s\n", $System eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $System eq 1 ? '' : 'checked', $text{'no'}, join(" ", $System),"
Package \n"; printf " %s\n", $Package eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Package eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Package),"
Main \n"; printf " %s\n", $Main eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Main eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Main),"
Defaults in Main \n"; printf " %s\n", $Defaultsinmain eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Defaultsinmain eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Defaultsinmain),"
Master \n"; printf " %s\n", $Master eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Master eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Master),"
Locking \n"; printf " %s\n", $Locking eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Locking eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Locking),"
Tables \n"; printf " %s\n", $Tables eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Tables eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Tables),"
Permissions \n"; printf " %s\n", $Permissions eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Permissions eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Permissions),"
Libraries \n"; printf " %s\n", $Libraries eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Libraries eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Libraries),"
Warn \n"; printf " %s\n", $Warn eq 1 ? 'checked' : '', $text{'yes'}; printf " %s\n", $Warn eq 1 ? '' : 'checked', $text{'no'}, join(" ", $Warn),"
"; &footer("index.cgi", $text{'index_title'}); } else { &head; if (! -x $config{'postfix_config_command'} && ! -r $config{'postfix_config_file'} ) { print "Can not find postconf"; exit; } # Verify that current configuration is valid if ($config{'index_check'} && ($err = &check_postfix())) { print "

",&text('check_error'),"

\n"; print "

$err
\n"; &footer("/", $text{'index'}); exit; } if ($System eq 1 ) { # print '
--System Parameters--
'; if (&has_command($config{'postfix_config_command'})) { print "

Postfix Version: $postfix_version

"; print ""; print "
"; print ""; open(MAILQ, "/bin/hostname 2>/dev/null |"); while (my $hostname = ) { print ""; } close(MAILQ); open(MAILQ, "/bin/uname -a 2>/dev/null |"); while (my $uname = ) { print ""; } close(MAILQ); } print "
Hostname $hostname
System $uname

"; } if ($Locking eq 1 ) { print '

Mailbox locking methods

'; print ''; open(MAILQ, "$config{'postfix_config_command'} -l 2>/dev/null |"); while (my $locking_methods = ) { print ""; } close(MAILQ); print "
$locking_methods

"; } if ($Tables eq 1 ) { print '

Supported Lookup Tables

'; print ''; # print '
--Supported Lookup tables--

'; open(MAILQ, "$config{'postfix_config_command'} -m 2>/dev/null |"); while (my $lookup_tables = ) { print ""; } close(MAILQ); print "
$lookup_tables

"; } if (($Main eq 1 || $Defaultsinmain eq 1 ) && ("x`find . -prune \( -perm 020 -o -perm 002 \) -print`" != "x")){ print "
Do not run this in a public- or group-writable directory

"; exit; } else { system ("rm postfinger.*.d postfinger.*.n"); # unlink "postfinger.*.d, postfinger.*.n"; `$config{'postfix_config_command'} -d | tr -s [:blank:] | sort > postfinger.$$.d`; `$config{'postfix_config_command'} -n | tr -s [:blank:] | sort > postfinger.$$.n`; if ($Main eq 1 ) { print '

main.cf


non-default parameters

'; print ''; # print '
--main.cf non-default parameters--

'; open(MAILQ, "/usr/bin/comm -13 postfinger.$$.d postfinger.$$.n 2>/dev/null |"); while (my $postfinger = ) { ($postf1,$postf2)=split(/=/,$postfinger,2); print ""; print ""; } close(MAILQ); print "
$postf1$postf2

"; } if ($Defaultsinmain eq 1 ) { print '

main.cf


parameters defined as per defaults

'; print ''; # print '
--main.cf parameters defined as per defaults--

'; open(MAILQ, "/usr/bin/comm -12 postfinger.$$.d postfinger.$$.n 2>/dev/null |"); while (my $postfinger = ) { ($postf1,$postf2)=split(/=/,$postfinger,2); print ""; print ""; } close(MAILQ); print "
$postf1$postf2

"; } unlink "postfinger.*.d, postfinger.*.n"; } if ($Master eq 1 ) { print '

master.cf


'; print ''; print "", "", "", ""; open(MAILQ, "/bin/cat `$config{'postfix_config_command'} -h config_directory`/master.cf 2>/dev/null |"); while (my $postfinger = ) { ($postf1,$postf2,$postf3,$postf4,$postf5,$postf6,$postf7,$postf8)=split(/\s+/,$postfinger,8); if ( grep(/\-\o/,$postfinger)){ print "", "", "", "" if ( !grep(/^#|^\[ \]*$/,$postfinger)); } elsif ( grep(/user=/,$postfinger)){ print "", "", "", "" if ( !grep(/^#|^\[ \]*$/,$postfinger)); } else { print "", "", "", "" if ( !grep(/^#|^\[ \]*$/,$postfinger)); } } close(MAILQ); print "
servicetypeprivateunprivchrootwakeupmaxproccommand + args
$postf2
$postf1
$postf1
$postf2
$postf3
$postf4
$postf5
$postf6
$postf7
$postf8

"; } if ($Permissions eq 1 ) { print '

Specific file and directory permissions


'; print ''; print ""; open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/maildrop 2>/dev/null |"); while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/public 2>/dev/null |"); while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; if (! open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h queue_directory`/public 2>/dev/null |")) { print '
WARNING: No access to $queue_directory/public
Try running postfinger as user root or postfix

'; } else { while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; } open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/private 2>/dev/null |"); while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; if (! open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h queue_directory`/private 2>/dev/null |")) { print '
WARNING: No access to $queue_directory/private
Try running postfinger as user root or postfix

'; } else { while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; } open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h command_directory`/postdrop 2>/dev/null |"); while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print ""; open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h command_directory`/postqueue 2>/dev/null |"); while (my $postfinger = ) { print "" if ( !grep(/total|^#|^\[ \]*$/,$postfinger)); } close(MAILQ); print "
Permission Deep Owner Group Size Date Directory/File
$postfinger
$postfinger
$postfinger
$postfinger
$postfinger
$postfinger
$postfinger

"; } if ($Libraries eq 1 ) { print '

Library dependencies

'; print ''; if (! open(MAILQ, "/usr/bin/ldd `$config{'postfix_config_command'} -h daemon_directory`/smtpd 2>/dev/null |")) { print '
WARNING: Can not find ldd. Check you have it installed and in your path

'; } else { while (my $postfinger = ) { ($postf1,$postf2)=split(/=/,$postfinger,2); print ""; print ""; } close(MAILQ); print "
$postf1=$postf2

"; } } print " "; &footer("index.cgi", $text{'index_title'}); } sub head { print ""; #print "Postfinger"; #print "
"; print ""; print "
"; return; }