From e32299eb10722d6b5d232335903061c060b086ed Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Tue, 18 Nov 2014 17:57:06 -0200 Subject: Postfix - Improve package instalation folder checks --- config/postfix/adexport.pl | 40 +++++++++++++++++----------------- config/postfix/postfix.inc | 15 ++++++++----- config/postfix/postfix_queue.php | 15 ++++++++----- config/postfix/postfix_view_config.php | 14 +++++++----- 4 files changed, 47 insertions(+), 37 deletions(-) (limited to 'config') diff --git a/config/postfix/adexport.pl b/config/postfix/adexport.pl index 185848f1..25a8a267 100755 --- a/config/postfix/adexport.pl +++ b/config/postfix/adexport.pl @@ -1,9 +1,9 @@ -#!/usr/bin/perl -w +#!/usr/local/bin/perl -w ############################################################################## # # Script to export a list of all email addresses from Active Directory # Brian Landers -# +# # This code is in the public domain. Your use of this code is at your own # risk, and no warranty is implied. The author accepts no liability for any # damages or risks incurred by its use. @@ -42,7 +42,7 @@ use Net::LDAP; use Net::LDAP::Control::Paged; use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED ); -#our ($cn,$passwd,$base); +#our ($cn,$passwd,$base); #($cn,$passwd,$base)=@_ARGV; #print "$cn \n $passwd \n $base"; #exit; @@ -74,10 +74,10 @@ foreach( @servers ) { # 1000 records by default. We have to use paging to get the full list. my $page = Net::LDAP::Control::Paged->new( size => 100 ); - + # Try to bind (login) to the server now that we're connected -my $msg = $ldap->bind( dn => $bind, - password => $passwd +my $msg = $ldap->bind( dn => $bind, + password => $passwd ); # If we can't bind, we can't continue @@ -122,7 +122,7 @@ if( $cookie ) { } # Finally, unbind from the server -$ldap->unbind; +$ldap->unbind; # ------------------------------------------------------------------------ # Callback function that gets called for each record we get from the server @@ -131,16 +131,16 @@ $ldap->unbind; # sub handle_object { - + my $msg = shift; # Net::LDAP::Message object my $data = shift; # May be Net::LDAP::Entry or Net::LDAP::Reference - + # Only process if we actually got data return unless $data; - + return handle_entry( $msg, $data ) if $data->isa("Net::LDAP::Entry"); return handle_reference( $msg, $data ) if $data->isa("Net::LDAP::Reference"); - + # If we get here, it was something we're not prepared to handle, # so just return silently. @@ -153,35 +153,35 @@ sub handle_object { # ones we haven't seen before. sub handle_entry { - + my $msg = shift; my $data = shift; - + # Extract the email addressess, selecting only the SMTP ones, and # filter them so that we only get unique addresses - my @mails = grep { /^smtp:/i && !$gSeen{$_}++ } + my @mails = grep { /^smtp:/i && !$gSeen{$_}++ } $data->get_value( "proxyAddresses" ); - - # If we found any, strip off the SMTP: identifier and print them out + + # If we found any, strip off the SMTP: identifier and print them out if( @mails ) { print map { s/^smtp:(.+)$/\L$1\n/i; $_ } @mails; } } # ------------------------------------------------------------------------ -# Handler for a Net::LDAP::Reference object. This is a 'redirect' to +# Handler for a Net::LDAP::Reference object. This is a 'redirect' to # another portion of the directory. We simply extract the references # from the object and resubmit them to the handle_object function for # processing. sub handle_reference { - + my $msg = shift; my $data = shift; - + foreach my $obj( $data->references() ) { - + # Oooh, recursion! Might be a reference to another reference, after all return handle_object( $msg, $obj ); } diff --git a/config/postfix/postfix.inc b/config/postfix/postfix.inc index 8f27680d..99af671b 100755 --- a/config/postfix/postfix.inc +++ b/config/postfix/postfix.inc @@ -35,12 +35,15 @@ require_once("functions.inc"); require_once("pkg-utils.inc"); require_once("globals.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) - define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); -else - define('POSTFIX_LOCALBASE','/usr/local'); - +$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); +if (is_dir('/usr/pbi/postfix-' . php_uname("m"))) { + if ($pfs_version == 2.2) + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")."/local"); + else + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); +} else { + define('POSTFIX_LOCALBASE','/usr/local'); +} $uname=posix_uname(); if ($uname['machine']=='amd64') diff --git a/config/postfix/postfix_queue.php b/config/postfix/postfix_queue.php index 4f072eba..6f8a7e19 100755 --- a/config/postfix/postfix_queue.php +++ b/config/postfix/postfix_queue.php @@ -34,12 +34,15 @@ $uname=posix_uname(); if ($uname['machine']=='amd64') ini_set('memory_limit', '250M'); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) - define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); -else - define('POSTFIX_LOCALBASE','/usr/local'); - +$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); +if (is_dir('/usr/pbi/postfix-' . php_uname("m"))) { + if ($pfs_version == 2.2) + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")."/local"); + else + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); +} else { + define('POSTFIX_LOCALBASE','/usr/local'); +} function get_cmd(){ if ($_REQUEST['cmd'] =='mailq'){ #exec("/usr/local/bin/mailq" . escapeshellarg('^'.$m.$j." ".$hour.".*".$grep)." /var/log/maillog", $lists); diff --git a/config/postfix/postfix_view_config.php b/config/postfix/postfix_view_config.php index f82c9371..f50ae991 100644 --- a/config/postfix/postfix_view_config.php +++ b/config/postfix/postfix_view_config.php @@ -29,11 +29,15 @@ */ $shortcut_section = "postfix"; require("guiconfig.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) - define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); -else - define('POSTFIX_LOCALBASE','/usr/local'); +$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); +if (is_dir('/usr/pbi/postfix-' . php_uname("m"))) { + if ($pfs_version == 2.2) + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")."/local"); + else + define('POSTFIX_LOCALBASE', '/usr/pbi/postfix-' . php_uname("m")); +} else { + define('POSTFIX_LOCALBASE','/usr/local'); +} function get_file($file){ $files['main']=POSTFIX_LOCALBASE."/etc/postfix/main.cf"; -- cgit v1.2.3