1ClamAV::Client(3)     User Contributed Perl Documentation    ClamAV::Client(3)
2
3
4

NAME

6       ClamAV::Client - A client class for the ClamAV "clamd" virus scanner
7       daemon
8

VERSION

10       0.11
11

SYNOPSIS

13   Creating a scanner client
14           use ClamAV::Client;
15
16           # Try using socket options from clamd.conf, or use default socket:
17           my $scanner = ClamAV::Client->new();
18
19           # Use a local Unix domain socket:
20           my $scanner = ClamAV::Client->new(
21               socket_name     => '/var/run/clamav/clamd.ctl'
22           );
23
24           # Use a TCP socket:
25           my $scanner = ClamAV::Client->new(
26               socket_host     => '127.0.0.1',
27               socket_port     => 3310
28           );
29
30           die("ClamAV daemon not alive")
31               if not defined($scanner) or not $scanner->ping();
32
33   Daemon maintenance
34           my $version = $scanner->version;
35                                   # Retrieve the ClamAV version string.
36
37           $scanner->reload();     # Reload the malware pattern database.
38
39           $scanner->quit();       # Terminates the ClamAV daemon.
40           $scanner->shutdown();   # Likewise.
41
42   Path scanning (lazy)
43           # Scan a single file or a whole directory structure,
44           # and stop at the first infected file:
45           my ($path, $result) = $scanner->scan_path($path);
46           my ($path, $result) = $scanner->scan_path(
47               $path, ClamAV::Client::SCAN_MODE_NORMAL );
48           my ($path, $result) = $scanner->scan_path(
49               $path, ClamAV::Client::SCAN_MODE_RAW );
50
51   Path scanning (complete)
52           # Scan a single file or a whole directory structure,
53           # and scan all files without stopping at the first infected one:
54           my %results = $scanner->scan_path_complete($path);
55           while (my ($path, $result) = each %results) { ... }
56
57   Other scanning methods
58           # Scan a stream, i.e. read from an I/O handle:
59           my $result = $scanner->scan_stream($handle);
60
61           # Scan a scalar value:
62           my $result = $scanner->scan_scalar(\$value);
63

DESCRIPTION

65       ClamAV::Client is a class acting as a client for a ClamAV "clamd" virus
66       scanner daemon.  The daemon may run locally or on a remote system as
67       ClamAV::Client can use both Unix domain sockets and TCP/IP sockets.
68       The full functionality of the "clamd" client/server protocol is
69       supported.
70
71   Constructor
72       The following constructor is provided:
73
74       new(%options): RETURNS ClamAV::Client
75           Creates a new "ClamAV::Client" object.  If no socket options are
76           specified, first the socket options from the local "clamd.conf"
77           configuration file are tried, then the Unix domain socket
78           "/var/run/clamav/clamd.ctl" is tried, then finally the TCP/IP
79           socket at 127.0.0.1 on port 3310 is tried.  If either Unix domain
80           or TCP/IP socket options are explicitly specified, only these are
81           used.
82
83           %options is a list of key/value pairs representing any of the
84           following options:
85
86           socket_name
87               A scalar containing the absolute name of the local Unix domain
88               socket.  Defaults to '/var/run/clamav/clamd.ctl'.
89
90           socket_host
91               A scalar containing the name or IP address of the TCP/IP
92               socket.  Defaults to '127.0.0.1'.
93
94           socket_port
95               A scalar containing the port number of the TCP/IP socket.
96               Defaults to 3310.
97
98   Instance methods
99       The following instance methods are provided:
100
101       Daemon maintenance
102
103       ping: RETURNS SCALAR; THROWS ClamAV::Client::Error
104           Returns true ('PONG') if the ClamAV daemon is alive.  Throws a
105           ClamAV::Client::Error exception otherwise.
106
107       version: RETURNS SCALAR; THROWS ClamAV::Client::Error
108           Returns the version string of the ClamAV daemon.
109
110       reload: RETURNS SCALAR; THROWS ClamAV::Client::Error
111           Instructs the ClamAV daemon to reload its malware database.
112           Returns true if the reloading succeeds, or throws a
113           ClamAV::Client::Error exception otherwise.
114
115       quit: RETURNS SCALAR; THROWS ClamAV::Client::Error
116       shutdown: RETURNS SCALAR; THROWS ClamAV::Client::Error
117           Terminates the ClamAV daemon.  Returns true if the termination
118           succeeds, or throws a ClamAV::Client::Error exception otherwise.
119
120       scan_path($path): RETURNS SCALAR, SCALAR; THROWS ClamAV::Client::Error
121       scan_path($path, $scan_mode): RETURNS SCALAR, SCALAR; THROWS
122       ClamAV::Client::Error
123           Scans a single file or a whole directory structure, and stops at
124           the first infected file found.  The specified path must be
125           absolute.  A scan mode may be specified: a mode of
126           ClamAV::Client::SCAN_MODE_NORMAL (which is the default) causes a
127           normal scan ("SCAN") with archive support enabled, a mode of
128           ClamAV::Client::SCAN_MODE_RAW causes a raw scan with archive
129           support disabled.
130
131           If an infected file is found, returns a list consisting of the path
132           of the file and the name of the malware signature that matched the
133           file.  Otherwise, returns the originally specified path and undef.
134
135       scan_path_complete($path): RETURNS HASH; THROWS ClamAV::Client::Error
136           Scans a single file or a whole directory structure completely, not
137           stopping at the first infected file found.  The specified path must
138           be absolute.  Only the normal, non-raw mode is supported for
139           complete scans by ClamAV.
140
141           Returns a hash with a list of infected files found, with the file
142           paths as the keys and the matched malware signature names as the
143           values.
144
145       scan_stream($handle): RETURNS SCALAR; THROWS ClamAV::Client::Error
146           Scans a stream, that is, reads from an I/O handle.  If the stream
147           is found to be infected, returns the name of the matching malware
148           signature, undef otherwise.
149
150       scan_scalar(\$value): RETURNS SCALAR; THROWS ClamAV::Client::Error
151           Scans the value referenced by the given scalarref.  If the value is
152           found to be infected, returns the name of the matching malware
153           signature, undef otherwise.
154

SEE ALSO

156       The clamd and clamav man-pages.
157

AVAILABILITY and SUPPORT

159       The latest version of ClamAV::Client is available on CPAN and at
160       <http://www.mehnle.net/software/clamav-client>.
161
162       Support is usually (but not guaranteed to be) given by the author,
163       Julian Mehnle <julian@mehnle.net>.
164

AUTHOR and LICENSE

166       ClamAV::Client is Copyright (C) 2004-2005 Julian Mehnle
167       <julian@mehnle.net>.
168
169       ClamAV::Client is free software.  You may use, modify, and distribute
170       it under the same terms as Perl itself, i.e. under the GNU GPL or the
171       Artistic License.
172
173
174
175perl v5.36.0                      2022-07-22                 ClamAV::Client(3)
Impressum