Build Your Own Engine
This information is not relevant to the Mac App Store version of ClamXav.
Although ClamXav comes with a bundled version of the ClamAV scanning engine, you are not obliged to use it; you can configure, build and install your own version.
Preparation
Before attempting to follow these instructions, you will need to have Apple's Developer Tools installed. You should download the most recently available version of Xcode from the Mac App Store. Alternatively, if you have a developer account (free), download the Xcode developer tools from the Mac Dev Center.
Once you've got Xcode installed, you need to install the command line tools. Do this by launching Xcode, going to the Xcode menu -> Preferences -> Downloads -> Components, and selecting to install the Command Line Tools option.
Alternatively, you can skip the Xcode step and just download the command line tools here, but that link isn't from Apple or supported by Apple, and I haven't tested it myself.
Next, you need to download the source code from the ClamAV project page. I suggest downloading the current stable release, not one of the Release Candidates (RC) as they are, by definition, incomplete.
After unpacking the archive, the next step is to edit the freshclam.conf file. After that, if you're using Mac OS X prior to 10.4 (Tiger), you'll need to create a new ClamAV user and group. Next, we go through the familiar process of "configure", "build", "install". Finally, you must set the appropriate permissions on the ClamAV install location.
Editing conf files
ClamXav Sentry makes use of the "clamd" daemon and clamdscan as a means of greatly improving the speed and efficiency of background scanning. In order to make use of this feature, you must edit clamav-X.XX/etc/clamd.conf and remove the word "Example" wherever you see it in that file. You must also enable LocalSocket and specify a path for the socket file. The default path is sufficient, but you must enable it by removing the hash (#) character from the start of the line. You may, of course, make any further changes you need.
You must also edit clamav-X.XX/etc/freshclam.conf to remove any lines starting with "Example" and to set up any country specific settings such as DatabaseMirror. You also need to make freshclam notify the clamd process after performing a definitions update; this is done by configuring the NotifyClamd setting and giving it the path to where clamd.conf will be found after installation.
Configure, Compile, Install
While in the clamav-X.XX source directory, perform the following actions. You need to be using the bash shell if you want to copy and paste the following commands. If not, you'll need to change them to suit:
- CC="/usr/bin/gcc-4.2" CXX="/usr/bin/g++-4.2"
CFLAGS="-O2 -g -D_FILE_OFFSET_BITS=64"
CXXFLAGS="-O2 -g -D_FILE_OFFSET_BITS=64"
./configure --disable-dependency-tracking --enable-llvm --enable-clamdtop --with-user=_clamav --with-group=_clamav --prefix=/usr/local/clamXav - make
- sudo make install
Each of the three commands above should be entered on one line.
Note, versions of Mac OS X prior to 10.5 do not support gcc 4.2, so you will need to change the commands above from gcc-4.2 to gcc, from g++-4.2 to g++ and -O2 to -O0. Even then, I don't know if it will work correctly, so be sure to run clamscan over the clamav-X.XX/test directory after you install.
Set Appropriate Permissions
The ClamAV directories need special permissions before you can run either clamscan or freshclam.
- chown -R root:wheel /usr/local/clamXav/etc
- chmod 0775 /usr/local/clamXav/etc
- chmod 0664 /usr/local/clamXav/etc/*
- chown -R root:wheel /usr/local/clamXav/bin
- chmod -R 0755 /usr/local/clamXav/bin
- chown clamav /usr/local/clamXav/bin/freshclam
- chmod u+s /usr/local/clamXav/bin/freshclam
- chown -R clamav:clamav /usr/local/clamXav/share/clamav
- chmod 0775 /usr/local/clamXav/share/clamav
- chmod 0664 /usr/local/clamXav/share/clamav/*
- chown -R clamav:clamav /usr/local/clamXav/share/clamav/daily*
- chmod -R a+r /usr/local/clamXav/share/clamav/daily*
- chown -R clamav:clamav /usr/local/clamXav/share/clamav/main*
- chmod -R a+r /usr/local/clamXav/share/clamav/main.*
- touch /usr/local/clamXav/share/clamav/freshclam.log
- chmod a+rw /usr/local/clamXav/share/clamav/freshclam.log
Custom Install Location
If you changed the install location (--prefix flag) during the configure phase, you'll need to tell ClamXav where to find your custom build. You can do this in the terminal by typing:
defaults write uk.co.markallan.clamXav PathToClamav <install_prefix>
Optionally, you may also set a specific path for the freshclam log file. The default with a custom installation will be /tmp/freshclam.log, which you can change with the following command:
defaults write uk.co.markallan.clamXav PathToUpdateLog </path/to/freshclam.log>
For ClamXav to function correctly, the log file should be world readable (or at least readable by you) and writable by the clamav user.
Categories
Please consider making a donation if you like my software.
