public function initScanner() { parent::initScanner(); // using 2>&1 to grab the full command-line output. $cmd = $this->avPath . " " . $this->appConfig->getCmdline() . " - 2>&1"; $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w")); $this->process = proc_open($cmd, $descriptorSpec, $this->pipes); if (!is_resource($this->process)) { throw new \RuntimeException('Error starting process'); } }
protected function initScanner() { parent::initScanner(); if ($this->useSocket) { $avSocket = $this->appConfig->getAvSocket(); $this->writeHandle = stream_socket_client('unix://' . $avSocket, $errno, $errstr, 5); if (!$this->writeHandle) { throw new \RuntimeException('Cannot connect to "' . $avSocket . '": ' . $errstr . ' (code ' . $errno . ')'); } } else { $avHost = $this->appConfig->getAvHost(); $avPort = $this->appConfig->getAvPort(); $this->writeHandle = $avHost && $avPort ? @fsockopen($avHost, $avPort) : false; if (!$this->writeHandle) { throw new \RuntimeException('The clamav module is not configured for daemon mode.'); } } // request scan from the daemon fwrite($this->writeHandle, "nINSTREAM\n"); }