diff --git a/postfix/postfinger.cgi b/postfix/postfinger.cgi index b70a40757..4718756b5 100755 --- a/postfix/postfinger.cgi +++ b/postfix/postfinger.cgi @@ -6,298 +6,217 @@ 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; +$System=1; +$Package=1; +$Locking=1; +$Tables=1; +$Main=1; +$Master=1; +$Permissions=1; +$Libraries=1; +$Warn=1; +$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),"
"; - &ui_print_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; - } +&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"; - &ui_print_footer("/", $text{'index'}); - exit; - } - if ($System eq 1 ) { +if ($config{'index_check'} && ($err = &check_postfix())) { + print "

",&text('check_error'),"

\n"; + print "

$err
\n"; + &ui_print_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); - } + if (&has_command($config{'postfix_config_command'})) { + print "

Postfix Version: $postfix_version

"; + print ""; 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 ""; } + print "
$locking_methods
"; + 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

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

Supported Lookup Tables

'; - print ''; +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

"; - } + open(MAILQ, "$config{'postfix_config_command'} -m 2>/dev/null |"); + while (my $lookup_tables = ) { + print "
$lookup_tables
"; } + close(MAILQ); + print "
"; +} - 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"); +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`; +`$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 ''; +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

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

main.cf


parameters defined as per defaults

'; - print ''; +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 |"); + 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 ($postfinger =~ /\-o/) { + print "", + "", + "", + "" + if ( !grep(/^#|^\[ \]*$/,$postfinger)); + } elsif ($postfinger =~ /user=/) { + 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

"; - } - 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 ($postfinger =~ /\-o/) { - print "", - "", - "", - "" - if ( !grep(/^#|^\[ \]*$/,$postfinger)); - } elsif ($postfinger =~ /user=/) { - print "", - "", - "", - "" - if ( !grep(/^#|^\[ \]*$/,$postfinger)); - } else { - print "", - "", - "", - "" - if ( !grep(/^#|^\[ \]*$/,$postfinger)); - } + print ""; } close(MAILQ); print "
servicetypeprivateunprivchrootwakeupmaxproccommand + args
$postf2
$postf1
$postf1
$postf2
$postf3
$postf4
$postf5
$postf6
$postf7
$postf8
=$postf2

"; } - - 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 ""; &ui_print_footer("index.cgi", $text{'index_title'}); -} sub head { print "