Hello,

Does module support ClamVA running as Unix (local) socket?

Thank you!

Comments

manarth’s picture

Right now it won't be possible.

The syntax for connecting to a unix socket would be:

$sock = fsockopen('unix:///full/path/to/my/socket.sock', NULL);

Clam AV's daemon mode currently uses this connection code (in clamav.inc):

function _clamav_scan_via_daemon($filepath, $filename) {
  $host = variable_get('clamav_daemon_host', CLAMAV_DEFAULT_HOST);
  $port = variable_get('clamav_daemon_port', CLAMAV_DEFAULT_PORT);

  // try to open a socket to clamav
  $handler = ($host && $port) ? @fsockopen($host, $port) : FALSE;

The way the UI is set up at the moment, you could configure the hostname correctly, but you can't set the port to be NULL, and even if you could, the code checks that both $host and $port have a value, before it'll try to connect.

It's a useful feature so we'll probably refactor the code at some point to allow local socket connection, but patches are welcome if you manage to get this working.

manarth’s picture

Issue summary: View changes
Status: Active » Patch (to be ported)

Fixed in D8 - there's an option in the admin area to use Unix-sockets.

We should probably back-port this to D7.

manarth’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new18.1 KB

Apologies, this is somewhat of a mega-patch.

This patch backports the ability to use unix-socket mode for connecting to ClamAV.

It also refactors the configuration form UI, to improve the usability of the form, matching the UI and wording that's provided in 8.x-1.x.

  • manarth committed 1c0ff7a on 7.x-1.x
    Issue #1744416 by manarth: Unix (local) socket support?
    
manarth’s picture

Status: Needs review » Fixed

Committed to 7.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mohammed76’s picture

how do I configure the local socket instead of ip and port? I still see ip and port in the configuration screen and I can't see any mention of a local socket.

mcdruid’s picture

@mohammed76 what version/release of clamav are you running?

The stable release for D7 was made some time ago now:

$ drush rl clamav-7.x
 Project  Release      Date         Status                 
 clamav   7.x-1.x-dev  2018-Feb-28  Development            
 clamav   7.x-1.0      2016-Sep-27  Supported, Recommended

...perhaps it's time we rolled 7.x-1.1 ... in the meantime, try the dev version.