Commit graph

154 commits

Author SHA1 Message Date
Micah Snyder (micasnyd)
9e20cdf6ea Add CMake build tooling
This patch adds experimental-quality CMake build tooling.

The libmspack build required a modification to use "" instead of <> for
header #includes. This will hopefully be included in the libmspack
upstream project when adding CMake build tooling to libmspack.

Removed use of libltdl when using CMake.

Flex & Bison are now required to build.

If -DMAINTAINER_MODE, then GPERF is also required, though it currently
doesn't actually do anything.  TODO!

I found that the autotools build system was generating the lexer output
but not actually compiling it, instead using previously generated (and
manually renamed) lexer c source. As a consequence, changes to the .l
and .y files weren't making it into the build. To resolve this, I
removed generated flex/bison files and fixed the tooling to use the
freshly generated files. Flex and bison are now required build tools.
On Windows, this adds a dependency on the winflexbison package,
which can be obtained using Chocolatey or may be manually installed.

CMake tooling only has partial support for building with external LLVM
library, and no support for the internal LLVM (to be removed in the
future). I.e. The CMake build currently only supports the bytecode
interpreter.

Many files used include paths relative to the top source directory or
relative to the current project, rather than relative to each build
target. Modern CMake support requires including internal dependency
headers the same way you would external dependency headers (albeit
with "" instead of <>). This meant correcting all header includes to
be relative to the build targets and not relative to the workspace.

For example, ...

```c
include "../libclamav/clamav.h"
include "clamd/clamd_others.h"
```

... becomes:

```c
// libclamav
include "clamav.h"

// clamd
include "clamd_others.h"
```

Fixes header name conflicts by renaming a few of the files.

Converted the "shared" code into a static library, which depends on
libclamav. The ironically named "shared" static library provides
features common to the ClamAV apps which are not required in
libclamav itself and are not intended for use by downstream projects.
This change was required for correct modern CMake practices but was
also required to use the automake "subdir-objects" option.
This eliminates warnings when running autoreconf which, in the next
version of autoconf & automake are likely to break the build.

libclamav used to build in multiple stages where an earlier stage is
a static library containing utils required by the "shared" code.
Linking clamdscan and clamdtop with this libclamav utils static lib
allowed these two apps to function without libclamav. While this is
nice in theory, the practical gains are minimal and it complicates
the build system. As such, the autotools and CMake tooling was
simplified for improved maintainability and this feature was thrown
out. clamdtop and clamdscan now require libclamav to function.

Removed the nopthreads version of the autotools
libclamav_internal_utils static library and added pthread linking to
a couple apps that may have issues building on some platforms without
it, with the intention of removing needless complexity from the
source. Kept the regular version of libclamav_internal_utils.la
though it is no longer used anywhere but in libclamav.

Added an experimental doxygen build option which attempts to build
clamav.h and libfreshclam doxygen html docs.

The CMake build tooling also may build the example program(s), which
isn't a feature in the Autotools build system.

Changed C standard to C90+ due to inline linking issues with socket.h
when linking libfreshclam.so on Linux.

Generate common.rc for win32.

Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef
from misc.c.

Add CMake files to the automake dist, so users can try the new
CMake tooling w/out having to build from a git clone.

clamonacc changes:
- Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other
  similar macros.
- Added a new clamav-clamonacc.service systemd unit file, based on
  the work of ChadDevOps & Aaron Brighton.
- Added missing clamonacc man page.

Updates to clamdscan man page, add missing options.

Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use
libclamav).

Rename Windows mspack.dll to libmspack.dll so all ClamAV-built
libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
Andy Ragusa (aragusa)
5b168b50cd bb12435: Create PID file before dropping privileges.
This commit writes the PID file before dropping privileges so that it
is owned by the super user, and an the less privileged user cannot
change it.
2020-07-24 10:47:20 -07:00
Jamie Biggar
9335b56052 Correct log output for AlertEncryptedArchive 2020-07-16 16:14:12 -07:00
Micah Snyder
34c3441bcd bb10979: multi-threaded reload minor corrections
dboptions should be an unsigned int.

Julius Plenz accidentally missing from NEWS.md.

Fail out if cl_engine_settings_apply() fails, because the only possible
cause of failure is a malloc issue.
2020-07-01 22:06:15 -07:00
Micah Snyder
dac084fb91 bb10979: clamd multi-threaded database reload #2
Add clamd config option to force blocking clamd database reload to
conserve RAM. Users may set `ConcurrentDatabaseReload no` in their
clamd.conf config file to force a blocking reload.

The blocking mode will still perform the reload in a new thread, but
will first free the current database, wait for scans targeting that
database to complete, and then load the new database in the new thread
and wait (`pthread_join()`) on that thread. Once loaded, any pending
scans will continue. This is effectively the same behavior as how
clamd reloads worked before the multi-threaded database reload feature
was added.
2020-07-01 22:06:15 -07:00
Micah Snyder
2444a01f19 bb10979: clamd multi-threaded database reload
Offload the DB load to a separate thread and only replace the current
engine instance afterwards.

While reload is pending:
- existing scan requests use the old db (this is unchanged)
- new scan requests are honored instead of blocked and they also use
  the old db (this is new)

After the reload is complete:
- existing scan requests use the old db (this is unchanged)
- new scan requests use the new db (this is unchanged)

The existing engine is refcounted so it'll be eventually freed when no
longer in use.

Reload requests while reload is pending are silently ignored (i.e. It
never forks more than a single reload thread).

Patch courtesy of Alberto Wu. We would also like to thank Julius Plenz
for original work on this issue, as well as Alexander Sulfrian,
Arjen de Korte, David Heidelberg, and Ged Haywood for their work
updating and testing these patches.
2020-07-01 22:06:15 -07:00
John Schember
a6a355629d Add DLP feature to detect credit cards only
Add Data-Loss-Prevention option to detect credit cards only, excluding
debit and private label cards where possible.

You can select the credit card-only DLP mode for clamscan with the
`--structured-cc-mode` command-line option.

You can select the credit card-only DLP mode for clamd with the
`StructuredCCOnly` clamd.conf config option.

This patch also adds credit card matching for additional vendors:
- Mastercard 2016
- China Union Pay
- Discover 2009
2020-04-29 13:55:25 -07:00
Micah Snyder
898c08f08b Formatting touch-up 2020-01-03 15:53:29 -05:00
Micah Snyder
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Romain Chollet
ff31e5b486 Add Prelude missing support 2019-10-02 16:08:30 -04:00
Micah Snyder
d9c34c43f6 Eliminates a few warnings. 2019-10-02 16:08:30 -04:00
Micah Snyder (micasnyd)
6a0abb897a Adds --max-scantime clamscan option and MaxScanTime clamd config option.
--max-scantime replaces the --timelimit clamscan option that had been experimental.
Default max-scantime set to 2 minutes (120000 milliseconds).
2019-10-02 16:08:29 -04:00
Mickey Sola
52dc3149e2 clamonacc - add pthread conditional wait to event consumer queue; add uname exclusion; add error handling for selinux permission denied case when reading fanotify kernel event queue; remove deprecated clamuko references; update clamd.conf.sample; remove unsused options in help output; add daemonization/foreground command-line option; add retry and deny on error functionality 2019-10-02 16:08:27 -04:00
Mickey Sola
1b264c0bf2 clamonacc - update autotools scripts to get clamd and onacc building; autojunk'd 2019-10-02 16:08:26 -04:00
Micah Snyder
4524c398f3 Argument and return types for fmap_readn(), cli_writen(), cli_readn() converted to use size_t instead of int. 2019-10-02 16:08:25 -04:00
Micah Snyder (micasnyd)
3df2497aad bb12193 - Change usage of strerror_r to cli_strerror. Patch submitted by aCaB. 2019-10-02 16:08:24 -04:00
Micah Snyder
52cddcbcfd Updating and cleaning up copyright notices. 2019-10-02 16:08:18 -04:00
Micah Snyder
b3e82e5e61 Replacing libclamav/cltypes.h with clamav-types.h.in, which generates a header clamav-types.h that we install alongside clamav.h. 2019-10-02 16:08:17 -04:00
Micah Snyder
72fd33c8b2 clang-format'd using new .clang-format rules. 2019-10-02 16:08:16 -04:00
Micah Snyder (micasnyd)
78606d72ed Correction to logic enabling/disabling heuristic alerts. 2018-12-02 23:07:02 -05:00
Micah Snyder (micasnyd)
f61e92da8f Changing numerous scan options' names, primarily those of heuristic signatature alert options. Original options (command line and clamd) will remain as deprecated & undocumented for a couple releases. Added 2 extra scan options to allow users to differentiate between alerting on encrypted archives vs encrypted documents (bb11911). 2018-12-02 23:06:59 -05:00
Micah Snyder
d7979d4ff7 Restructured scan options flags from a single bitflag field to a structure containing multiple bitflag fields. This also required adding a new function to the bytecode API to get scan options a la carte, and modifying the existing function to hand back scan options in the old/deprecated uint32_t bitflag format. Re-generated bytecode iface header files.
Updated libclamav documentation detailing new scan options structure.
Renamed references to 'algorithmic' detection to 'heuristic' detection. Renaming references to 'properties' to 'collect metadata'.
Renamed references to 'scan all' to 'scan all match'.
Renamed a couple of 'Hueristic.*' signature names as 'Heuristics.*' signatures (plural) to match majority of other heuristics.
2018-12-02 23:06:59 -05:00
Josh Soref
7cd9337a70 Spelling Adjustments (#30)
* spelling: accessed

* spelling: alignment

* spelling: amalgamated

* spelling: answers

* spelling: another

* spelling: acquisition

* spelling: apitid

* spelling: ascii

* spelling: appending

* spelling: appropriate

* spelling: arbitrary

* spelling: architecture

* spelling: asynchronous

* spelling: attachments

* spelling: argument

* spelling: authenticode

* spelling: because

* spelling: boundary

* spelling: brackets

* spelling: bytecode

* spelling: calculation

* spelling: cannot

* spelling: changes

* spelling: check

* spelling: children

* spelling: codegen

* spelling: commands

* spelling: container

* spelling: concatenated

* spelling: conditions

* spelling: continuous

* spelling: conversions

* spelling: corresponding

* spelling: corrupted

* spelling: coverity

* spelling: crafting

* spelling: daemon

* spelling: definition

* spelling: delivered

* spelling: delivery

* spelling: delimit

* spelling: dependencies

* spelling: dependency

* spelling: detection

* spelling: determine

* spelling: disconnects

* spelling: distributed

* spelling: documentation

* spelling: downgraded

* spelling: downloading

* spelling: endianness

* spelling: entities

* spelling: especially

* spelling: empty

* spelling: expected

* spelling: explicitly

* spelling: existent

* spelling: finished

* spelling: flexibility

* spelling: flexible

* spelling: freshclam

* spelling: functions

* spelling: guarantee

* spelling: hardened

* spelling: headaches

* spelling: heighten

* spelling: improper

* spelling: increment

* spelling: indefinitely

* spelling: independent

* spelling: inaccessible

* spelling: infrastructure

Conflicts:
	docs/html/node68.html

* spelling: initializing

* spelling: inited

* spelling: instream

* spelling: installed

* spelling: initialization

* spelling: initialize

* spelling: interface

* spelling: intrinsics

* spelling: interpreter

* spelling: introduced

* spelling: invalid

* spelling: latency

* spelling: lawyers

* spelling: libclamav

* spelling: likelihood

* spelling: loop

* spelling: maximum

* spelling: million

* spelling: milliseconds

* spelling: minimum

* spelling: minzhuan

* spelling: multipart

* spelling: misled

* spelling: modifiers

* spelling: notifying

* spelling: objects

* spelling: occurred

* spelling: occurs

* spelling: occurrences

* spelling: optimization

* spelling: original

* spelling: originated

* spelling: output

* spelling: overridden

* spelling: parenthesis

* spelling: partition

* spelling: performance

* spelling: permission

* spelling: phishing

* spelling: portions

* spelling: positives

* spelling: preceded

* spelling: properties

* spelling: protocol

* spelling: protos

* spelling: quarantine

* spelling: recursive

* spelling: referring

* spelling: reorder

* spelling: reset

* spelling: resources

* spelling: resume

* spelling: retrieval

* spelling: rewrite

* spelling: sanity

* spelling: scheduled

* spelling: search

* spelling: section

* spelling: separator

* spelling: separated

* spelling: specify

* spelling: special

* spelling: statement

* spelling: streams

* spelling: succession

* spelling: suggests

* spelling: superfluous

* spelling: suspicious

* spelling: synonym

* spelling: temporarily

* spelling: testfiles

* spelling: transverse

* spelling: turkish

* spelling: typos

* spelling: unable

* spelling: unexpected

* spelling: unexpectedly

* spelling: unfinished

* spelling: unfortunately

* spelling: uninitialized

* spelling: unlocking

* spelling: unnecessary

* spelling: unpack

* spelling: unrecognized

* spelling: unsupported

* spelling: usable

* spelling: wherever

* spelling: wishlist

* spelling: white

* spelling: infrastructure

* spelling: directories

* spelling: overridden

* spelling: permission

* spelling: yesterday

* spelling: initialization

* spelling: intrinsics

* space adjustment for spelling changes

* minor modifications by klin
2018-02-27 22:00:09 -05:00
Micah Snyder
7e64560ce5 eliminating warnings that cropped up in 32bit ubuntu (16.04) 2017-08-31 11:00:34 -04:00
Steven Morgan
e7dfe57d3a bb11522 - additional block-max w.i.p. : clamd, man pages. 2016-09-20 17:45:40 -04:00
Ningirsu
f4265a5acd Adds a module to use Prelude and connect to a prelude manager
To enable prelude compile with ./configure --enable-prelude

In ClamAV configuration file set Prelude Enable on yes and choose an analyzer name with PreludeAnalyzerName (default ClamAV).

You need to have a prelude manager to use this module.
2016-06-09 10:40:38 -04:00
Mickey Sola
72b7aef197 bb11463 - patch by Jim Morris to increase clamd's soft file descriptor to its potential maximum on 64-bit systems 2016-03-15 11:03:50 -04:00
Kevin Lin
059ca61484 compiler warning suppression 2016-02-29 11:09:09 -05:00
Mickey Sola
b68375fdbb bb10568 - patch from Andreas Cadhalpun to add systemd support for clamd and freshclam 2016-02-09 15:32:40 -05:00
Kevin Lin
e492c653e4 clamd/clamscan: reorder pcre limit handle to prior cl_engine_compile 2016-02-08 15:24:35 -05:00
Kevin Lin
ea9ffd291b add scanning options for scanning xml-based documents (MSXML, OOXML, HWPML) and HWP3 2016-02-02 14:23:19 -05:00
Kevin Lin
731c8e6213 hwp3.x: add support for maximum recursive calls to hwp3 parsing 2016-01-19 14:28:48 -05:00
Mickey Sola
46a35abe56 mass update of copyright headers 2015-09-17 13:41:26 -04:00
Mickey Sola
abbe4c4bc3 onas: improving handling of thread exit cleanup and db reload. 2015-09-08 16:15:52 -04:00
Mickey Sola
5ae59b959d Overhauling clamd onaccess scanning to support dynamic directory determination. 2015-08-28 16:05:18 -04:00
Mickey Sola
5327ca4297 bb-11305: Initialized dbstat entries after clamd first loads. 2015-06-16 14:58:32 -04:00
Shawn Webb
5eb9247676 Merge remote-tracking branch 'origin/master' into features/yara 2014-11-25 16:21:42 -05:00
Shawn Webb
3a670267cf bb#10907: Add trailing newline to the end of the pidfile 2014-11-20 12:38:33 -05:00
Shawn Webb
d3c4f5ee2e Merge remote-tracking branch 'origin/features/yara' into swebb/clamyara
Conflicts:
	libclamav/Makefile.am
	libclamav/Makefile.in
	libclamav/readdb.c
2014-11-10 12:09:12 -05:00
Shawn Webb
cf3138e1d2 bb11160 - Plug a few memory leaks 2014-11-04 18:38:34 -05:00
Kevin Lin
3741573205 added option to limit pcre execution based on filesize 2014-09-19 02:39:52 -04:00
Kevin Lin
9bc7c13882 pcre: added and linked options to set match_limit and match_limit_recursion
pcre: separated parsing function into parsing and compiling functions
2014-08-25 19:11:12 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
Kevin Lin
1361015c56 bb#11028 - fixed a deadlock issue with fanotify and logg_mutex 2014-06-05 12:23:29 -04:00
Kevin Lin
067bce5fbc engine: added max-iconspe(MaxIconsPE) option and docs 2014-03-07 10:23:18 -05:00
Shawn Webb
b842e8bf75 Migrate ClamAV's crypto routines over to OpenSSL. 2014-02-12 17:55:38 -05:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
Kevin Lin
97fbb02b58 libclamav: added an engine option to set max partitions in raw dmgs
libclamav: added partition intersection checking support
clamd/clamscan: added max-partitions and partition-intersection options
2014-02-06 18:59:05 -05:00
David Raynor
46d85dff8c clamd: avoid closing bad socket if already exiting-on-error, cid #11004 2013-08-12 13:17:10 -04:00
Steve Morgan
0e5dfd5676 Coverity: don't kill a thread that was not created 2013-02-07 12:34:46 -08:00