original_string: public function scan_file_execute_unixsocket($file) {
          $socket = stream_socket_client('unix://' . $this->get_config('pathtounixsocket'),
                  $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT);
          if (!$socket) {
              // Can't open socket for some reason, notify admins.
              $notice = get_string('errorcantopensocket', 'antivirus_clamav', "$errstr ($errno)");
              $this->set_scanning_notice($notice);
              return self::SCAN_RESULT_ERROR;
          } else {
              // Execute scanning. We are running SCAN command and passing file as an argument,
              // it is the fastest option, but clamav user need to be able to access it, so
              // we give group read permissions first and assume 'clamav' user is in web server
              // group (in Debian the default webserver group is 'www-data').
              // Using 'n' as command prefix is forcing clamav to only treat \n as newline delimeter,
              // this is to avoid unexpected newline characters on different systems.
              $perms = fileperms($file);
              chmod($file, 0640);
              fwrite($socket, "nSCAN ".$file."\n");
              $output = stream_get_line($socket, 4096);
              fclose($socket);
              // After scanning we revert permissions to initial ones.
              chmod($file, $perms);
              // Parse the output.
              return $this->parse_unixsocket_response($output);
          }
      }
code: public function scan_file_execute_unixsocket($file) {
          $socket = stream_socket_client('unix://' . $this->get_config('pathtounixsocket'),
                  $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT);
          if (!$socket) {
              // Can't open socket for some reason, notify admins.
              $notice = get_string('errorcantopensocket', 'antivirus_clamav', "$errstr ($errno)");
              $this->set_scanning_notice($notice);
              return self::SCAN_RESULT_ERROR;
          } else {
              // Execute scanning. We are running SCAN command and passing file as an argument,
              // it is the fastest option, but clamav user need to be able to access it, so
              // we give group read permissions first and assume 'clamav' user is in web server
              // group (in Debian the default webserver group is 'www-data').
              // Using 'n' as command prefix is forcing clamav to only treat \n as newline delimeter,
              // this is to avoid unexpected newline characters on different systems.
              $perms = fileperms($file);
              chmod($file, 0640);
              fwrite($socket, "nSCAN ".$file."\n");
              $output = stream_get_line($socket, 4096);
              fclose($socket);
              // After scanning we revert permissions to initial ones.
              chmod($file, $perms);
              // Parse the output.
              return $this->parse_unixsocket_response($output);
          }
      }
code_tokens: public function scan_file_execute_unixsocket ( $ file ) { $ socket = stream_socket_client ( 'unix://' . $ this -> get_config ( 'pathtounixsocket' ) , $ errno , $ errstr , ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT ) ; if ( ! $ socket ) { // Can't open socket for some reason, notify admins. $ notice = get_string ( 'errorcantopensocket' , 'antivirus_clamav' , "$errstr ($errno)" ) ; $ this -> set_scanning_notice ( $ notice ) ; return self :: SCAN_RESULT_ERROR ; } else { // Execute scanning. We are running SCAN command and passing file as an argument, // it is the fastest option, but clamav user need to be able to access it, so // we give group read permissions first and assume 'clamav' user is in web server // group (in Debian the default webserver group is 'www-data'). // Using 'n' as command prefix is forcing clamav to only treat \n as newline delimeter, // this is to avoid unexpected newline characters on different systems. $ perms = fileperms ( $ file ) ; chmod ( $ file , 0640 ) ; fwrite ( $ socket , "nSCAN " . $ file . "\n" ) ; $ output = stream_get_line ( $ socket , 4096 ) ; fclose ( $ socket ) ; // After scanning we revert permissions to initial ones. chmod ( $ file , $ perms ) ; // Parse the output. return $ this -> parse_unixsocket_response ( $ output ) ; } }
docstring: Scan file using Unix domain sockets.
  
  @param string $file Full path to the file.
  @return int Scanning result constant.
docstring_tokens: Scan file using Unix domain sockets .