| 0.94 API usage | 0.95 API usage | Notes |
|---|---|---|
| - | ret = cl_init(options); | You must initialize libclamav by calling cl_init() once, before calling any other API functions. If successful, it will return CL_SUCCESS, and an error code otherwise. |
| struct cl_engine *engine = malloc(sizeof(struct cl_engine)); | struct cl_engine engine = *cl_engine_new(); if (engine) { ... } |
Call cl_engine_new(), instead of malloc(). It will return NULL if there is an error, such as if there isn't enough memory to allocate engine. |
| cl_free(engine); | ret = cl_engine_free(engine); | Call cl_engine_free() instead of cl_free() to free the engine. Returns CL_SUCCESS on success, and an error code otherwise. |
| dir = cl_retdbdir(); | -- no change -- | |
| cl_load(path, engine, &signo, options); | --no change-- | |
| errordescription = cl_strerror(ret); | --no change-- | |
| ret = cl_build(engine); | ret = cl_engine_compile (engine); | Call cl_engine_compile(), instead of cl_build() after loading a new database. |
| limits.maxscansize = ...; cl_scanfile(..., &limits, ...); | ret = cl_engine_set_num(engine, CL_ENGINE_MAX_SCANSIZE, &val64); if (ret != CL_SUCCESS) { ... handle error ...} val64 = cl_engine_get_num(engine, CL_ENGINE_MAX_SCANSIZE, &ret); if (ret != CL_SUCCESS) { .. handle error ...} |
When a new engine is created, certain internal values are set to default, they can later be queried/modified via cl_engine_get_num()/cl_engine_get_str()/cl_engine_set_num()/cl_engine_set_str(). For example scan limits can be set this way, instead of struct cl_limit. Please don't modify any of the values unless you know what you are doing. |
| cl_settempdir("/path/to/tmpdir", 0); | cl_engine_set_str(engine, CL_ENGINE_TMPDIR, "/path/to/tmpdir"); const char* tmpdir = cl_engine_get_str(engine, CL_ENGINE_TMPDIR, &err); |
For setting string attributes, use cl_engine_set_str()/cl_engine_get_str() |
| ret = cl_statinidir(dirname, &dbstat); | --no change-- | |
| ret = cl_statchkdir(&dbstat); | --no change-- | |
| ret = cl_scanfile(filename, &virname, &scanned, engine, &limits, options); | ret = cl_scanfile(filename, &virname, &scanned, engine, options); | Limits is no longer a parameter to cl_scanfile(), you can set it via cl_engine_set() |
| ret = cl_scandesc(fd, &virname, &scanned, engine, &limits, options); | ret = cl_scandesc(fd, &virname, &scanned, engine, options); | Limits is no longer a parameter to cl_scandesc(), you can set it via cl_engine_set() |
| pid = fork(); if (pid == 0) { srand(); cl_... } | --no change-- | You still need to call srand() in a forked child, before making any calls to libclamav functions. Multithreaded programs aren't required to call srand(). |
# Define the interface through which we communicate with sendmail # This option is mandatory! Possible formats are: # [[unix|local]:]/path/to/file - to specify a unix domain socket # inet:port@[hostname|ip-address] - to specify an ipv4 socket # inet6:port@[hostname|ip-address] - to specify an ipv6 socket # # Default: no default #MilterSocket /tmp/clamav-milter.socket #MilterSocket inet:7357When using a UNIX domain socket, please make sure sendmail/postfix has read/write access to it. Libmilter will honour the current umask. Then we need a second socket to interface to clamd:
# Define the clamd socket to connect to for scanning. # This option is mandatory! Syntax: # ClamdSocket unix:path # ClamdSocket tcp:host:port # The first syntax specifies a local unix socket (needs an bsolute path) e.g.: # ClamdSocket unix:/var/run/clamd/clamd.socket # The second syntax specifies a tcp local or remote tcp socket: the # host can be a hostname or an ip address; the ":port" field is only required # for IPv6 addresses, otherwise it defaults to 3310 # ClamdSocket tcp:192.168.0.1 # # This option can be repeated several times with different sockets or even # with the same socket: clamd servers will be selected in a round-robin fashion. # # Default: no default #ClamdSocket tcp:scanner.mydomain:7357Clamav-milter does not need to be run as a privileged user or group. You can fiddle with the following options or leave them unset to let it run as the current user:
# Run as another user (clamav-milter must be started by root for this option to work) # # Default: unset (don't drop privileges) #User clamav # Initialize supplementary group access (clamav-milter must be started by root). # # Default: no #AllowSupplementaryGroups noOptionally, clamav-milter can be run inside a chroot. If you do set this option, please ensure you understand implication for paths and privileges.
# Chroot to the specified directory. # Chrooting is performed just after reading the config file and before dropping privileges. # # Default: unset (don't chroot) #Chroot /newrootThen we have the actions configuration. Here's how to tell the milter what to do with the emails:
# The following group of options controls the delievery process under # different circumstances. # The following actions are available: # - Accept # The message is accepted for delievery # - Reject # Immediately refuse delievery (a 5xx error is returned to the peer) # - Defer # Return a temporary failure message (4xx) to the peer # - Blackhole (not available for OnFail) # Like accept but the message is sent to oblivion # - Quarantine (not available for OnFail) # Like accept but message is quarantined instead of being delivered # In sendmail the quarantine queue can be examined via mailq -qQ # For Postfix this causes the message to be accepted but placed on hold # # Action to be performed on clean messages (mostly useful for testing) # Default Accept #OnClean Accept # Action to be performed on infected messages # Default: Quarantine #OnInfected Quarantine # Action to be performed on error conditions (this includes failure to # allocate data structures, no scanners available, network timeouts, # unknown scanner replies and the like) # Default Defer #OnFail DeferClamav-milter knows two type of exclusions to the above rules.
# Messages originating from these hosts/networks will not be scanned # This option takes a host(name)/mask pair in CIRD notation and can be # repeated several times. If "/mask" is omitted, a host is assumed. # To specify a locally orignated, non-smtp, email use the keyword "local" # # Default: unset (scan everything regardless of the origin) #LocalNet local #LocalNet 192.168.0.0/24 #LocalNet 1111:2222:3333::/48Secondly, exclusions based on the sender's or recipient's email address:
# This option specifies a file which contains a list of POSIX regular # expressions. Addresses (sent to or from - see below) matching these regexes # will not be scanned. Optionally each line can start with the string "From:" # or "To:" (note: no whitespace after the colon) indicating if it is, # respectively, the sender or recipient that is to be whitelisted. # If the field is missing, "To:" is assumed. # Lines starting with #, : or ! are ignored. # # Default unset (no exclusion applied) #Whitelist /etc/whitelisted_addressesSeveral options are provided to tune the logging (note that clamav-milter now has its own log files), the most important are:
# Uncomment this option to enable logging. # LogFile must be writable for the user running daemon. # A full path is required. # # Default: disabled #LogFile /tmp/clamav-milter.log # Use system logger (can work together with LogFile). # # Default: no #LogSyslog yesThe remaining options are extensively documented inside the example config file. Additionally a quick and dirty Perl script is available to automatically generate a clamav-milter.conf file. Just invoke the script with the same parameters you were passing to the old milter and then review all the preset options to make sure everything is sane. For more information, see this post on the mailing list and the ClamAV blog.
error while loading shared libraries: libclamav.so.6: cannot open shared object file: No such file or directory then you should run ldconfig
LibClamAV Warning: Cannot dlopen: file not found - unrar support unavailable