- try harder to guess the binary and the config file
authorheiko
Thu, 02 Nov 2006 21:40:09 +0000
changeset 21 2dbba4511409
parent 20 bfb67e3281ca
child 22 e73bf6df70f0
- try harder to guess the binary and the config file - do not pass any options to exim
exiacl.pl
--- a/exiacl.pl	Wed Jul 26 09:47:09 2006 +0000
+++ b/exiacl.pl	Thu Nov 02 21:40:09 2006 +0000
@@ -48,7 +48,10 @@
 sub write_exim($@);
 sub addr(@);
 sub hostname() { chomp (my $h = `hostname -f`); return $h;  }
-sub findExim() { $_ = `which exim` || `which exim4`; chomp; $_ }
+
+sub which($) { (map { -x "$_/$_[0]" && "$_/$_[0]" || () } split /:/, $ENV{PATH})[0] }
+sub findExim() { which("exim") || which("exim4") }
+sub guessConfig($) { qx/$_[0] "-bV"/ =~ /^Configuration.*\sis\s+(\S+)/mi and return $1 }
 
 use constant ME => basename $0;
 use constant HOSTNAME => hostname;
@@ -69,7 +72,7 @@
     dst	    => { ARGS => "=s"  },		    # exim primary_hostname
 
     exim    => { ARGS => "=s", DEFAULT => $ENV{EXIM} || findExim },
-    config  => { ARGS => "=s", DEFAULT => $ENV{EXIM_CONF} || "/etc/exim/exim.conf.t" , 
+    config  => { ARGS => "=s", DEFAULT => $ENV{EXIM_CONF} || guessConfig(findExim()),
 		 ALIAS => "C" },
 
     callout =>	{ ARGS => "!", DEFAULT => 1 },
@@ -83,7 +86,8 @@
 $Cf = new AppConfig CONFIG or die;
     $Cf->exim				    or die "No exim binary found\n";
     $Cf->dst(addr(exim_option("primary_hostname")));
-    $Cf->getopt(qw(pass_through no_ignore_case)) or die $@;
+    #$Cf->getopt(qw(pass_through no_ignore_case)) or die $@;
+    $Cf->getopt(qw(no_ignore_case)) or die $@;
 
     $Cf->From($Cf->from)		    unless $Cf->From;
     $Cf->To($Cf->to)			    unless $Cf->To;