From d08667a27125748dc773dde3dfcfbd69b654ab84 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Mon, 22 Feb 2016 11:46:59 +0000 Subject: [PATCH] MDL-50887 antivirus_clamav: Access config properties using getter. --- lib/antivirus/clamav/classes/scanner.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/antivirus/clamav/classes/scanner.php b/lib/antivirus/clamav/classes/scanner.php index 81045c7bcf3..e8e58e36dab 100644 --- a/lib/antivirus/clamav/classes/scanner.php +++ b/lib/antivirus/clamav/classes/scanner.php @@ -38,7 +38,7 @@ class scanner extends \core\antivirus\scanner { * @return bool True if all necessary config settings been entered */ public function is_configured() { - return !empty($this->config->pathtoclam); + return (bool)$this->get_config('pathtoclam'); } /** * Scan file, throws exception in case of infected file. @@ -73,7 +73,7 @@ class scanner extends \core\antivirus\scanner { } else { // Unknown problem. $this->message_admins($notice); - if ($this->config->clamfailureonupload === 'actlikevirus') { + if ($this->get_config('clamfailureonupload') === 'actlikevirus') { if ($deleteinfected) { unlink($file); } @@ -125,11 +125,11 @@ class scanner extends \core\antivirus\scanner { * @return array ($return, $notice) Execution return code and notification text. */ public function scan_file_execute_commandline($file) { - $this->config->pathtoclam = trim($this->config->pathtoclam); + $pathtoclam = trim($this->get_config('pathtoclam')); - if (!file_exists($this->config->pathtoclam) or !is_executable($this->config->pathtoclam)) { + if (!file_exists($pathtoclam) or !is_executable($pathtoclam)) { // Misconfigured clam, notify admins. - $notice = get_string('invalidpathtoclam', 'antivirus_clamav', $this->config->pathtoclam); + $notice = get_string('invalidpathtoclam', 'antivirus_clamav', $pathtoclam); return array(-1, $notice); } @@ -139,11 +139,11 @@ class scanner extends \core\antivirus\scanner { // To make clamdscan work, we use --fdpass parameter that passes the file // descriptor permissions to clamd, which allows it to scan given file // irrespective of directory and file permissions. - if (basename($this->config->pathtoclam) == 'clamdscan') { + if (basename($pathtoclam) == 'clamdscan') { $clamparam .= '--fdpass '; } // Execute scan. - $cmd = escapeshellcmd($this->config->pathtoclam).$clamparam.escapeshellarg($file); + $cmd = escapeshellcmd($pathtoclam).$clamparam.escapeshellarg($file); exec($cmd, $output, $return); $notice = ''; if ($return > 1) {