Mailing List Archive

svn commit: r1901533 - /spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
Author: hege
Date: Thu Jun 2 05:32:04 2022
New Revision: 1901533

URL: http://svn.apache.org/viewvc?rev=1901533&view=rev
Log:
Use find_executable_in_env_path for better Windows support, clean up code

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm?rev=1901533&r1=1901532&r2=1901533&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm Thu Jun 2 05:32:04 2022
@@ -34,6 +34,8 @@ use warnings;
use re 'taint';
use version 0.77;

+use Mail::SpamAssassin::Util;
+
our ( $EXIT_STATUS, $WARNINGS );

our @MODULES = (
@@ -452,51 +454,20 @@ sub try_binary {
my $required_version = $bindef->{version};
my $recommended_version = $bindef->{recommended_min_version};
my $errtype;
- my ($command, $output);
-
-
- # only viable on unix based systems, so exclude windows, etc. here
- if ($^O =~ /^(mswin|dos|os2)/i) {
- $$summref .= "Warning: Unable to test on this platform for the optional \"$bindef->{'binary'}\" binary\n";
- $errtype = 'is unknown for this platform';
- } else {
- $command = "which $bindef->{'binary'} 2>&1";
- #print "DEBUG: running $command\n";
- $output = `$command`;
-
- if (!defined $output || $output eq '') {
- $installed = 0;
- } elsif ($output =~ /which: no \Q$bindef->{'binary'}\E in/i) {
- $installed = 0;
- } else {
- #COMMAND APPEARS TO EXIST
- $command = $output;
- chomp ($command);
-
- $installed = 1;
- }
- #print "DEBUG: $command completed and output parsed\n";
- }
-
-
- if ($installed) {
- #SANITIZE THE RETURNED COMMAND JUST IN CASE
- $command =~ s/[^a-z0-9\/]//ig;

+ my $command = Mail::SpamAssassin::Util::find_executable_in_env_path($bindef->{'binary'});
+ if (defined $command) {
#GET THE VERSION
- $command .= " ";
if (defined $bindef->{'version_check_params'}) {
- $command .= $bindef->{'version_check_params'};
+ $command .= " ".$bindef->{'version_check_params'};
}
- $command .= " 2>&1";

#print "DEBUG: running $command to check the version\n";
- $output = `$command`;
+ my $output = `$command 2>&1`;

- if (!defined $output) {
- $installed = 0;
+ if (defined $output && $output ne '') {
+ $installed = 1;

- } else {
if (defined $bindef->{'version_check_regex'}) {
$output =~ m/$bindef->{'version_check_regex'}/;
$binary_version = $1;