Compiling Dansguardian with Increased MaxChildren

I have three main proxy servers running Squid, Squidguard and DansGuardian servicing over 1300 desktop computers. The stock DansGuardian code includes a setting to limit the number of potential DansGuardian child processes to the operating system file descriptor limits. I have managed to increase this to 900 but would like to push it further. The setting controlling this is:

maxchildren = 900

in my dansguardian.conf file. This limit was a bit unrealistic since the machines running DansGuardian had the memory available to deal with a much higher load. So following on from what other users have done I set about building an rpm for DansGuardian with higher limits.


I am assuming CentOS5 and Clam version 0.98 so amendments may be needed for future versions. I created a virtual machine for compilation purposes and then deployed the rpm on the production servers.

Install dependencies
On the CentOS5 VM used for compilation:

yum install zlib-devel pcre-devel

yum groupinstall 'Development Tools'

Install the RPMforge Repository

yum install clamd clamav-devel

Get the Source Files

mkdir -p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cd /usr/src/redhat/SOURCES
cd ../SPECS

Edit the Source Code
To the SPEC file you just downloaded an extra line is needed under the %{configure} section:

so it afterwards should read:

%{configure} \
--enable-clamav=no \
--enable-clamd=yes \

Dansguardian Compilation ConfigurationNext we need to make some changes to the operating system (only on the compilation machine).



#define __FD_SETSIZE 8192
And also:
#define __FD_SETSIZE 8192



Before comiling/building also set ulimit:
ulimit -n 8192

Build the RPM

Next, in the /usr/src/redhat directory:

rpmbuild -v -bb --clean /usr/src/redhat/SPECS/dansguardian-centos-clamav.spec

Assuming the build runs successfully you will find the rpm in /usr/src/redhat/RPMS/x86_64

Tar File

I have tarred up the contents of my own /usr/src/redhat directory for future convenience. This tar file includes:

This tar file can be extracted and you could run the script to attempt the build or you can do the steps above manually.  If you just want to install DansGuardian version on Centos 5 x86_64 you could use the RPM.

The instructions above may need to be amended for CentOS6 / RedHat 6 – I haven’t tried that yet.


After installing the RPM try amending the dansguardian.conf file setting maxchildren value to say 2048 to see how things go. If there are problems (e.g. rabbits dammit) try the check list below.

Check list

If you are still having problems getting it to work check the following:

  • Has “ulimit -n 8192” been set in the dansguardian startup script?
  • When you run “/usr/sbin/dansguardian -v” do you see ‘CXXFLAGS=-DFD_SETSIZE=8192’
  • Did you amend the following files on the build machine before running the rpmbuild command:
    • /usr/include/bits/typesizes.h
    • /usr/include/linux/posix_types.h
  • Do you have enough RAM to cope with the increase in DansGuardian processes?


2 Responses to “Compiling Dansguardian with Increased MaxChildren”

  1. Thiago

    Nice tuto… But… I’m having trouble to build the rpm on CentOS 6.6 and Dansguardian It keeps asking for the wrong directory and the dansguardian_gcc43.patch. After ignoring those, it fails by the end of the building process. Can you update the tutorial revalidating the steps?


Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>