Fix call of antivirus must be done using utils->executeCLI
This commit is contained in:
parent
ec45afb05f
commit
779a134022
@ -81,63 +81,37 @@ class AntiVir
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fullcommand = $this->getCliCommand($file);
|
$fullcommand = $this->getCliCommand($file);
|
||||||
|
//$fullcommand="/usr/bin/clamdscan --fdpass '/tmp/phpuxoAEo'"
|
||||||
//$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"';
|
//$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"';
|
||||||
$fullcommand .= ' 2>&1'; // This is to get error output
|
|
||||||
|
|
||||||
$output = array();
|
|
||||||
$return_var = 0;
|
$return_var = 0;
|
||||||
$safemode = ini_get("safe_mode");
|
$safemode = ini_get("safe_mode");
|
||||||
// Create a clean fullcommand
|
// Create a clean fullcommand
|
||||||
dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off"));
|
dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off"));
|
||||||
// Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL%
|
// Run CLI command.
|
||||||
$lastline = exec($fullcommand, $output, $return_var);
|
include_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||||
|
$utils = new Utils($this->db);
|
||||||
|
$outputfile = $conf->user->dir_temp.'/antivir.tmp';
|
||||||
|
$result = $utils->executeCLI($fullcommand, $outputfile);
|
||||||
|
|
||||||
|
$return_var = $result['result'];
|
||||||
|
$output = $result['output'];
|
||||||
|
$errorstring = $result['error'];
|
||||||
|
|
||||||
if (is_null($output)) {
|
if (is_null($output)) {
|
||||||
$output = array();
|
$output = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
//print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit;
|
dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".$output);
|
||||||
|
|
||||||
/*
|
|
||||||
$outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id();
|
|
||||||
$handle = fopen($outputfile, 'w');
|
|
||||||
if ($handle)
|
|
||||||
{
|
|
||||||
$handlein = popen($fullcommand, 'r');
|
|
||||||
while (!feof($handlein))
|
|
||||||
{
|
|
||||||
$read = fgets($handlein);
|
|
||||||
fwrite($handle,$read);
|
|
||||||
}
|
|
||||||
pclose($handlein);
|
|
||||||
|
|
||||||
$errormsg = fgets($handle,2048);
|
|
||||||
$this->output=$errormsg;
|
|
||||||
|
|
||||||
fclose($handle);
|
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_UMASK))
|
|
||||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
|
|
||||||
$this->error="ErrorFailedToWriteInDir";
|
|
||||||
$return=-1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',', $output));
|
|
||||||
|
|
||||||
$returncodevirus = 1;
|
$returncodevirus = 1;
|
||||||
if ($return_var == $returncodevirus) { // Virus found
|
if ($return_var == $returncodevirus) { // Virus found
|
||||||
$this->errors = $output;
|
$this->errors = array($errorstring, $output);
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return_var > 0) { // If other error
|
if ($return_var > 0) { // If other error
|
||||||
$this->errors = $output;
|
$this->errors = array($errorstring, $output);
|
||||||
return -98;
|
return -98;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +152,7 @@ class AntiVir
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match("/\s/", $command)) {
|
if (preg_match("/\s/", $command)) {
|
||||||
$command = escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails.
|
$command = escapeshellarg($command); // Force use of quotes on command. Using escapeshellcmd fails.
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $command.' '.$param;
|
$ret = $command.' '.$param;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user