Contribute  :  Advanced Search  :  Directory  :  Forum  :  FAQ's  :  My Downloads  :  Links  :  Polls  
AFP548 Changing the world one server at a time.
Welcome to AFP548
Tuesday, February 09 2010 @ 09:53 am CST
   

Updated Spam/Virus controls for OS X Server

ArticlesThese instructions have been successfully followed and tested on the following OSXS Versions

10.2.6, 10.2.8, 10.3.0, 10.3.4, 10.3.5, 10.3.6, 10.3.7, 10.4-DEV


With so many Articles out there, it's hard to find one that contains all of the instructions required to do an install without problems so I have put this together in the hopes that it makes the installation as easy and painless as possible.


This is an updated version of Joel's Article and was used as the starting point for what I hope includes all of the required installation instructions and related information.

Updated 12/20/2004

The use of fink to install modules and libraries has not been considered due the non-canonical locations that software is stored.


These instructions work if they are followed as described, the author warrants no merchantability or fitness for a particular purpose and is not meant to be educational material for those who do not understand the instructions as they are provided.




    1. - Introduction and Prerequisites

    2. - Getting the archives

    3. - Unpacking the archives

    4. - Building BerkeleyDB

    5. - Building gmp

    6. - Building ClamAV

    7. - Installing amavisd-new with SpamAssassin

    8. - Installing the Startup Item

    9. - (Optional) Installing the Log Roll Item



  1. - Introduction and Prerequisites

  2. This article covers using amavisd to provide spam and virus controls to Postfix. This method will provide server-wide spam and virus filters for all incoming and outgoing mail. It's a very robust system and can be easily configured to provide a number of different site-specific options for your users. However, combating unwanted e-mail is an ongoing war and not just a single engagement. This article will describe a good beginning to a full-featured mail system, but you should not stop here.

    This process works as a content filter for postfix. This means that Postfix will receive the e-mail and then pass it off, using an SMTP connection to port 10024 on the local machine, to amavisd before doing any actual processing of it. Amavisd will then run the mail through ClamAV, for virus detection, and then SpamAssassin, for spam detection. If the e-mail passes both sets of tests amavisd will then return the e-mail to Postfix by using an SMTP connection to port 10025 on the local machine. At this point Postfix will then deliver the mail to the POP/IMAP server that you are using.

    If you are using OS X 10.2 you'll need to first upgrade your installation of Perl to 5.8 or higher.

    I opted to build Perl from source just to see what was involved and it's a fairly complex install so I wont be going into details on it's install process.

    If you don't want to build Perl from source, you can grab an installer from Aron Faby's site at http://www.serverlogistics.com/downloads-jag.php#perl.

    Also note that if you have Perl support enabled in Apache under Mac OS X Server 10.2.x, you must disable it, as Faby’s Perl 5.8 is not compatible with Apple’s supplied Perl modules.

    Download the Perl updater and double-click to install.


    Examine the Macintosh.tar.gz tarball included with amavisd-new and ClamAV for updated files and installation instruction, these files will be updated to correspond with it's released version as required.


    The files included in the Macintosh tarball provide a way to start the service without logging in as well as a way to manually start, stop and reload the service and include a 'log-rolling' option that is easy to implement.


    Setting up the user/group. (10.3.x can use method a or b)

    a).
    % sudo dscl localhost -create /NetInfo/root/Groups/mailtransport

    % sudo dscl localhost -create /NetInfo/root/Groups/mailtransport gid 30

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport uid 30

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport gid 30

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport shell /bin/tcsh

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport home /tmp

    % sudo dscl localhost -create /NetInfo/root/Users/mailtransport passwd "*"



    b). (10.2.x only)
    % sudo niutil -create . /groups/mailtransport

    % sudo niutil -createprop . /groups/mailtransport gid 30

    % sudo niutil -create . /users/mailtransport

    % sudo niutil -createprop . /users/mailtransport uid 30

    % sudo niutil -createprop . /users/mailtransport gid 30

    % sudo niutil -createprop . /users/mailtransport shell /bin/tcsh

    % sudo niutil -createprop . /users/mailtransport home /tmp

    % sudo niutil -createprop . /users/mailtransport passwd "*"



    Setting up the folders.

    % sudo mkdir /var/amavis

    % sudo mkdir /var/amavis/tmp

    % sudo mkdir /var/amavis/db

    % sudo chown -R mailtransport:mailtransport /var/amavis

    % sudo chmod -R 750 /var/amavis

    % sudo mkdir /var/virusmails

    % sudo chown mailtransport:mailtransport /var/virusmails

    % sudo chmod 750 /var/virusmails

    % sudo touch /var/amavis/whitelist_sender

    % sudo mkdir /var/clamav

    % sudo chown mailtransport:mailtransport /var/clamav

    % sudo chmod 0750 /var/clamav

    % sudo mkdir /var/log/mailtransport

    % sudo touch /var/log/mailtransport/clamd.log

    % sudo touch /var/log/mailtransport/freshclam.log

    % sudo chmod 0644 /var/log/mailtransport/clamd.log

    % sudo chmod 0644 /var/log/mailtransport/freshclam.log

    % sudo chown mailtransport /var/log/mailtransport/clamd.log

    % sudo chown mailtransport /var/log/mailtransport/freshclam.log





  3. - Getting the archives


  4. Download amavisd-new, ClamAV, db (BerkeleyDB), gmp.

    The official URLs for these libraries are:

    amavisd-new
    http://www.ijs.si/software/amavisd/
    ClamAV
    http://sourceforge.net/projects/clamav/
    BerkeleyDB
    http://www.sleepycat.com/download/db/
    gmp
    ftp://ftp.gnu.org/gnu/gmp/

    You can choose to download either Gzipped (.gz or .tgz extensions) or Bzipped (.bz2 extension) archives, since the latter are smaller. In any case, I advise to locally compute and compare MD5 checksums, if the distribution home lists them. You do that by executing:

    % md5 <filename>




  5. - Unpacking the archives


  6. With all archives in the same directory, do:

    % ls *.gz | xargs -n 1 tar zxvf

    (I know, xargs is evil). If you downloaded any Bzipped archives, do:

    % ls *.bz2 | xargs -n 1 tar jxvf

    (when done it would be helpful to reduce the folder names without the version numbers)

    ex.
    % mv ./clamav-0.80 ./clamav


    Now for a little cleanup.

    % sudo rm -r *.gz




  7. - Building BerkeleyDB


  8. Don't install BerkeleyDB using an installer package, build it from source using the following instructions

    % cd ../db/build_unix

    % ../dist/configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc

    % make; sudo make install

    % cd ../





  9. - Building gmp


  10. % cd ../gmp

    % ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --enable-devel

    % make; sudo make install





  11. - Building ClamAV


  12. % cd ../clamav

    % ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --enable-bigstack --with-user=mailtransport --with-group=mailtransport

    % make; sudo make install



    Open /etc/freshclam.conf and make the following changes.
    ("Example" is an actual line to be deleted or commented out)

    # Example

    UpdateLogFile /var/log/mailtransport/freshclam.log

    LogVerbose

    PidFile /var/clamav/freshclam.pid

    DatabaseOwner mailtransport

    DNSDatabaseInfo current.cvd.clamav.net

    DatabaseMirror database.clamav.net

    MaxAttempts 5

    Checks 24


    Open /etc/clamd.conf and make the following changes.
    ("Example" is an actual line to be deleted or commented out)

    # Example

    LogTime

    LogFile /var/log/mailtransport/clamd.log

    LogVerbose

    PidFile /var/clamav/clamd.pid

    LocalSocket /var/clamav/clamd.sock

    MaxThreads 20

    SelfCheck 1800

    User mailtransport





  13. - Installing amavisd-new with SpamAssassin


  14. % cd ../amavisd


    Next we need to move the files to their working locations.

    % sudo cp amavisd.conf-sample /etc/amavisd.conf/

    % sudo chown root /etc/amavisd.conf

    % sudo chmod 644 /etc/amavisd.conf

    % sudo cp amavisd /usr/bin/

    % sudo chown root /usr/bin/amavisd

    % sudo chmod 755 /usr/bin/amavisd



    Now we need to get some perl modules installed. CPAN makes this easy, but we will have to force one or two of them to go. I haven't come across any problems with this in testing, but do keep an eye on things. Also, when you are installing these perl modules you may run across dependencies that you don't have installed yet. Please respond in the affirmative when it asks you if you want them installed too.

    % sudo perl -MCPAN -e shell


    Now you are in the CPAN system. You will then type in the next four commands which will install the modules. Some of these modules may ask if you want to install the dependencies., say "yes" to this.

    cpan> install Archive::Tar Archive::Zip BerkeleyDB Compress::Zlib Convert::UUlib Digest::MD5

    cpan> install IO::Stringy Mail::ClamAV Mail::Internet Mail::SpamAssassin MIME::Base64 MIME::Parser

    cpan> install Net::SMTP Net::Server Time::HiRes Unix::Syslog Digest::SHA1

    cpan> force install Convert::TNEF Net::SMTP



    Finally exit out of CPAN.

    cpan> quit


    If you experience problems building any of the perl modules, you probably have CPAN configured to not follow dependancies and any module that requires another module to be installed will fail to install, reconfigure your perl to prompt for dependent modules rather than ignore them.


    You now need to edit your amavisd config file. You can find it at /etc/amavisd.conf. This file contains a huge number of options that will pretty much determine your spam and virus policies for your server. You should familiarize yourself with this file so that you get the desired results from this system. It's rather well commented so you shouldn't need to mess with it too much. Although there are a few directives that you will need to change before you are able to launch amavisd.


    In Section I you'll need to change

    $MYHOME to "/var/amavis"

    $mydomain to your main e-mail domain.

    $myhostname to your FQDN.

    $daemon_user should be set to "mailtransport"

    $daemon_group should be set to "mailtransport"

    $pid_file to "$MYHOME/amavisd.pid"

    $lock_file to "$MYHOME/amavisd.lock"

    $unix_socketname to "$MYHOME/amavisd.sock"


    Section II and III you can leave alone.


    Section IV will require you to make some decisions. This section determines what happens when an e-mail is determined to be a spam or virus e-mail. Here you can specify the notification templates for what your bounce messages say. More importantly you an determine what you'll do with spam and virus e-mails.


    The final destiny variables are what you are interested in here. By default amavisd will bounce all spam back to the sender. You may find that this clogs up your mail system attempting to be nice to spammers. If that's the case you can set this to D_DISCARD which will effectively delete the mail in question.


    You will also want to set your $virus_admin and $spam_admin settings where the respective notifications will be sent.


    The quarantine settings allow you to specify where the spam and virus e-mails will be stored. If you are interested in keeping the e-mails you can direct them to an e-mail address or folder, otherwise you can set these to "undef" which will delete the mails. If you do keep them, make sure you clean the folder out on a regular basis or else you'll fill your drive up.


    Section V sets up white and black lists for amavis. Use these to add in any domains that you know are good or bad.


    Section VI you can leave alone.


    Section VII is where you specify when e-mail is tagged as spam. The sa_tag levels determine when to quarantine spam mails and when to kill them. Also in this section you'll want to uncomment and ammend the clamd section to look something like this when done:


    ['Clam Antivirus-clamd',
    \&ask_daemon, ["CONTSCAN {}n", "/var/clamav/clamd.sock"],
    qr/bOK$/, qr/bFOUND$/,
    qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],



    Section VIII and IX you can leave alone.


    Now we can edit the Postfix files, first you need to add the following lines to /etc/postfix/main.cf it will tell Postfix to run amavisd as a content filter before delivery.

    
    # =====================================================
    #                    amavis-new/ClamAV
    # =====================================================
    #
    content_filter=smtp-mailtransport:[127.0.0.1]:10024
    Once these changes have been made you can save and close this file. Now add the following to /etc/postfix/master.cf:
    #
    # =====================================================
    #                    amavis-new/ClamAV
    # =====================================================
    #
    smtp-mailtransport unix -       -       y       -       2       smtp
       -o smtp_data_done_timeout=1200
       -o smtp_send_xforward_command=yes
       -o disable_dns_lookups=yes
    127.0.0.1:10025 inet n       -       y       -       -       smtpd
       -o content_filter=
       -o local_recipient_maps=
       -o relay_recipient_maps=
       -o smtpd_restriction_classes=
       -o smtpd_client_restrictions=
       -o smtpd_helo_restrictions=
       -o smtpd_sender_restrictions=
       -o smtpd_recipient_restrictions=permit_mynetworks,reject
       -o mynetworks=127.0.0.0/8
       -o strict_rfc821_envelopes=yes
       -o smtpd_error_sleep_time=0
       -o smtpd_soft_error_limit=1001
       -o smtpd_hard_error_limit=1000
       -o receive_override_options=no_header_body_checks



    Once these changes have been made you can save and close this file.




  15. - Installing the Startup Item


  16. Move the "MAILTRANSPORT" folder to "/System/Library/StartupItems/".

    % sudo mv MAILTRANSPORT /System/Library/StartupItems/

    % sudo chown root:admin /System/Library/StartupItems/MAILTRANSPORT/*

    % sudo chmod 0755 /System/Library/StartupItems/MAILTRANSPORT/MAILTRANSPORT


    Note: You can also place the folder in /Library/StartupItems/

    Open /etc/hostconfig with an editor and insert the following line:

    "MAILTRANSPORT=-YES-"


    With the flag set to "-YES-", the service will be enabled at startup.

    If you wish to disable auto startup at any time, set "MAILTRANSPORT=-NO-" in /private/etc/hostconfig and it will disable this service and prevent manually starting it.

    With the service enabled, you can start, stop and reload the service manually at any time from terminal with one of the following commands:

    % sudo SystemStarter start "MAILTRANSPORT"

    % sudo SystemStarter stop "MAILTRANSPORT"

    % sudo SystemStarter restart "MAILTRANSPORT"



    A safety has been built in preventing you from starting the service if you have disabled it in the /private/etc/hostconfig file.




  17. - (Optional) Installing the Log Roll Item


  18. First we move the mailtransport folder to the periodic folder and create some files.

    % cd logroll

    % sudo touch /var/log/mailtransport/amavis.log

    % sudo chmod 0644 /var/log/mailtransport/amavis.log

    % sudo chown mailtransport /var/log/mailtransport/amavis.log

    % sudo mv ./mailtransport /etc/periodic/

    % chmod 0755 /etc/periodic/mailtransport

    % chmod 0755 /etc/periodic/mailtransport/*

    % chown root:wheel /etc/periodic/mailtransport

    % chown root:wheel /etc/periodic/mailtransport/*



    Using your favorite editor, edit /etc/crontab and add the following entry:

    30 4 * * 0 root periodic mailtransport


    Next, we need to create a link to this file for periodic to access it with.

    % cd /etc

    % sudo ln -s periodic/mailtransport/500.mailtransport mailtransport

    % sudo touch /var/log/mailtransport/amavis.log



    Make the following changes to amavisd.conf:

    $LOGFILE to "/var/log/mailtransport/amavis.log"

    $DO_SYSLOG to 0


    Finally, we need to add our entry into the periodic config file located
    at /etc/default/periodic.conf using your favorite editor.

    # mailtransport options
    # These options are used by periodic(8) itself to determine what to do
    # with the output of the sub-programs that are run, and where to send
    # that output.
    #
    mailtransport_output="/var/log/mailtransport.out" # user or /file
    mailtransport_show_success="YES" # scripts returning 0
    mailtransport_show_info="YES" # scripts returning 1
    mailtransport_show_badconfig="NO" # scripts returning 2



    This step is not required but I like to be able to see my available options so I have also edited /usr/share/man/man8/periodic.8 and /usr/share/man/cat8/periodic.8.gz to include my added routines.

    To edit the periodic.8.gz you must first unpack it, I recommend you use BBEdit to edit the file since it has an option to show invisible characters and this file is riddled with them.

    After you have made your additions to this file, repack it (gz) and place it back in the /usr/share/man/cat8 folder and your done.

    (It will roll the logs once a week and retain the 8 previous weeks of the logs.)


    The grand finally is to start the service and restart postfix.

    % sudo SystemStarter start "MAILTRANSPORT"

    % sudo postfix reload





    NOTE:

    Additional patch files may be included in the Macintosh archive 'Macintosh.tar.gz' for advanced/modified features, please see included 'README' for related information.



Story Options

Advertising

Updated Spam/Virus controls for OS X Server | 75 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Updated Spam/Virus controls with OS X Server
Authored by: Anonymous on Thursday, December 09 2004 @ 03:45 am CST
cpan> install Mail::ClamAV
it is fails:

CPAN.pm: Going to build S/SA/SABECK/Mail-ClamAV-0.13.tar.gz

Please install Inline::C before continuing: 'Can't locate Inline/MakeMaker.pm
 in @INC (@INC contains: /sw/lib/perl5 /sw/lib/perl5/darwin 
/System/Library/Perl/5.8.1/darwin-thread-multi-2level 
/System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level 
/Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level 
/Network/Library/Perl/5.8.1 /Network/Library/Perl .) at (eval 1) line 2.

BEGIN failed--compilation aborted at (eval 1) line 2.
'
Running make test
  Make had some problems, maybe interrupted? Won't test
Running make install
  Make had some problems, maybe interrupted? Won't install

Any other modules installed successfull
How can I reinstall or solve this?
thanx
Updated Spam/Virus controls with OS X Server
Authored by: Anonymous on Thursday, December 09 2004 @ 10:09 am CST
I have a problem starting up:

sudo SystemStarter start "AMAVISCLAMAV"
Password:
Welcome to Macintosh.
Initializing network
Starting AMAVIS-CLAMAV
Waiting for AMAVISCLAMAV
Problem in Amavis::DB or Amavis::DB::SNMP code: Can't locate BerkeleyDB.pm in @INC (@INC contains: /System/Library/Perl/5.8.1/darwin-thread-multi -2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi -2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/ darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/ Perl) at (eval 33) line 11.
BEGIN failed--compilation aborted at (eval 33) line 11.
AMAVISCLAMAV (1217) did not complete successfully.br> The following StartupItems failed to properly start: /System/Library/StartupItems/AMAVISCLAMAV - execution of Startup script failed
Startup complete.
Hangup


I did not notice a problem when building the Berkely DB. or the perl module. Any ideas? Thanks, Jeff
Updated Spam/Virus controls with OS X Server
Authored by: Anonymous on Thursday, December 09 2004 @ 10:43 am CST
I was successfully installed the utilities.
But I have a problem:

Postfix says:
Dec 9 17:40:03 ______ postfix/qmgr[8588]: warning: connect to transport smtp-amavis: No such file or directory

Searched on net, but no success.

Can anybody help me?

thanx
allowing users to train Spamassassin
Authored by: nbirnbaum on Monday, December 13 2004 @ 02:56 pm CST
Is there a way to allow users to train Spamassassin to improve their filtering?
A GUI would really be the best. Or, perhaps an email address that users
could forward spam to that would automagically add it to the spam db? Or,
have sa-learn search their Junk folder every week and train it thereby? You
know, something relatively easy like that which wouldn't require them to go
command line. Thanks!
Updated Spam/Virus controls with OS X Server
Authored by: Anonymous on Monday, December 13 2004 @ 07:32 pm CST
I noticed this build uses gmp.. I don't think the last one did. Can anyone
explain where gmp comes into play here?

I also noticed a new directory created: /var/amavis/db. I'm assuming this is
for BDB?? I don't believe the last article left this out too. Any caveats to not
having this directory in the setup?

I followed the last article a few months back.. I'm running 10.3.6, newest SA
3.0.1, and all seems well, so I'm hesitant to make any changes unless needed.

Thanks for any info. Great article... it's very much appreciated.
Updated Spam/Virus controls with OS X Server
Authored by: Anonymous on Wednesday, December 15 2004 @ 10:14 pm CST
We experienced the same problem. We solved it by downloading the latest
source for BerkeleyDB, compiling it, and then creating a symbolic link to the
folder.

Here's the steps we followed.

--- http://www.sleepycat.com/download/db/
cd db-4.3.21/build_unix
../dist/configure
make
make install

Install a link from BerkleyDB to BerkeleyDB.4.3
ln -s /usr/local/BerkeleyDB.4.3 /usr/local/BerkeleyDB

Now install the CPAN BerkeleyDB perl module
Updated Spam/Virus controls with OS X Server
Authored by: steve on Thursday, December 16 2004 @ 08:43 pm CST
I had no issues on the install of all items, thanks to the great directions in
this article. The only problem I cam across was in section 8, Installing the
Strat up item. When was the AMAVISCLAMAV folder created? If it was created
during an earlier install, where is it located?
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Monday, December 20 2004 @ 08:25 pm CST
Please Please Please - add the backslash before the '&' in the example of how to edit the /etc/amavisd.conf. It is really hard to realize that &ask_daemon needs to be \ask_daemon. Those who edit the existing version will be alright, those who simply paste the text from this web site get screwed.

Also, warn people that it is not the time to install CPAN, libnet or LWP. There are two versions of Data::Dumper and installing any of those will attempt to update them which will conflict because you wind up with the system installed one in /System/Library and the regular installed one in /Library. Also, does anyone know which versions of BerkeleyDB are incompatible. I would up following the suggestiong of using a symlink to /usr/local/BerkeleyDB so that
CP AN would find the libraries and install the BerkeleyDB module.
Might also consider ASSP
Authored by: heavyboots on Tuesday, December 21 2004 @ 01:58 pm CST
Or... you might consider installing ASSP instead. It's definitely worth taking a look. The one caveat I should note is that I've only done a test install of ASSP on our XServe. We aren't handling mail from it yet. However, I've been running ASSP 1.09 on our Redhat Linux box for over a year with great results (currently running about 10,000 message a day through it, 75% of which is spam, and receiving

The thing I like about it the most is that ASSP 550 Rejects the spam before it ever clogs the mail queue. Also, while it can be set up to do virus filtering in the latest incarnation, the default settings for rejecting .pif, .scr, .exe etc attachments filter almost all viruses out to start with and take practically no CPU power to do so.

If you decide to go that route, the two HOW-TOs of specific interest are probably:

  1. ASSP and SIMS on Mac OS X. This has info on making a startup item for ASSP and some other good stuff, but he's using Stalker's product, so you also need to look at the postfix config.
  2. ASSP & Postfix which details how to point postfix at a different port number. Note: Use the second post, not the first for best results.

Updated Spam/Virus controls for OS X Server
Authored by: ezat on Tuesday, December 21 2004 @ 02:48 pm CST
I am having problems with parts of the article. In 'Installing the Startup Item',
there is the statement:

Move the "MAILTRANSPORT" folder to "/System/Library/StartupItems/"

Where is the 'MAILTRANSPORT' folder in the first place. Do I download it from
somewhere?

Also, there is a similar reference to 'logroll' in the article:

cd logroll

WHere is this directory supposed to be found?

EH
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Wednesday, December 22 2004 @ 08:02 am CST
GREAT ARTICLE, my first installation with OSX server and it was good.
i want ask only a question
how i can update virus definition, spam list ecc ecc, it was automatically update by amavis?
i have to set up an automatic tools or i have to upgrade it by a shell?
thanks for all
djv
Updated Spam/Virus controls for OS X Server - ClamAV fails to build
Authored by: Anonymous on Thursday, December 23 2004 @ 03:38 pm CST
[I'll preface this by saying that I'm new to building executables from source,
so tell me if I'm missing something obvious.]

ClamAV fails to build:

admin$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/
etc --enable-bigstack --with-user=mailtransport --with-
group=mailtransport

. . .

checking resolv.h usability... no
checking resolv.h presence... yes
configure: WARNING: resolv.h: present but cannot be compiled
configure: WARNING: resolv.h: check for missing prerequisite headers?
configure: WARNING: resolv.h: see the Autoconf documentation
configure: WARNING: resolv.h: section "Present But Cannot Be Compiled"
configure: WARNING: resolv.h: proceeding with the preprocessor's result
configure: WARNING: resolv.h: in the future, the compiler will take precedence
configure: WARNING: ## ------------------------------------------
##
configure: WARNING: ## Report this to the AC_PACKAGE_NAME lists. ##
configure: WARNING: ## ------------------------------------------
##

This is on OSXS 10.3.6, using current versions of all source packages (as of
12/15/04). If I need to RTFM, I'd appreciate links to good resources. =]
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Monday, December 27 2004 @ 12:48 pm CST
when I restart MAILTRANSPORT I get

sudo SystemStarter restart "MAILTRANSPORT"
Welcome to Macintosh.
Reloading MAILTRANSPORT
Stoping MAILTRANSPORT
Waiting for MAILTRANSPORT
Starting MAILTRANSPORT
ERROR: You must select server type (local/tcp).
Waiting for MAILTRANSPORT
Waiting for MAILTRANSPORT
Startup complete.
Hangup

I don't see anything like (local/tcp)
What am I missing?
marvelous....
Authored by: aurfalien on Wednesday, December 29 2004 @ 01:57 pm CST
... simply marvelous!

I enjoyed the article as well as the fact that it works!

I'm seeing Apple in the back end enterprise more and more.

Thanks for the hard work at putting this together, very much appreciated!
Updated Spam/Virus controls for OS X Server
Authored by: siddhartha on Sunday, January 02 2005 @ 01:42 am CST
thank you for the update. my loggrolling was spawning a whole bunch of processes and consuming my machine up in the old how-to.

so a couple of question.

1 how do i unisntall the old user and programs and reinstall this.

2 how does this differ from apple's how-to. More complete i guess?

http://developer.apple.com/server/virusfiltering.html
Amavisd-new with SpamAssassin
Authored by: Mach5 on Wednesday, January 05 2005 @ 01:47 am CST
Great article.

Questions:
Will this provide each mail user Bayesian spam filtering and corpus database that can be maintained by himself/herself? In another word, can each mail user have and update his/her own corpus spam database and maintain white/black list?
Can these be done by modifing the config file?

Thank you for your answers in advance.

Mach5
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Friday, January 07 2005 @ 02:00 pm CST
I have followed the directions explicitly, but every time I try to install the
BerkeleyDB module in cpan, I get this:

http://www.dallasdrivers.org/cpan.txt

I am running 10.3.7, I have the Xcode tools installed, I have cpan configured
to download all dependencies. What am I doing wrong?
Can't connect to UNIX socket
Authored by: Anonymous on Tuesday, January 11 2005 @ 07:44 pm CST
Using (ClamAV-clamd) on dir: CONTSCAN /var/amavis/tmp/amavis
-20050111T203211-16663/parts\n
ClamAV-clamd: Sending CONTSCAN /var/amavis/tmp/amavis
-20050111T203211-16663/parts\n to UNIX socket /var/clamav/clamd.sock
ClamAV-clamd: Can't send to socket /var/clamav/clamd.sock: Socket is not
connected, retrying (1)
ClamAV-clamd: sleeping for 1 s
I am getting the following in the debug output of amavisd debug:

ClamAV-clamd: Connecting to socket /var/clamav/clamd.sock, retry #1
ClamAV-clamd: Can't connect to UNIX socket /var/clamav/clamd.sock: No
such file or directory, retrying (2)
ClamAV-clamd: sleeping for 6 s
ClamAV-clamd: Connecting to socket /var/clamav/clamd.sock, retry #2
ClamAV-clamd av-scanner FAILED: Too many retries to talk to /var/clamav/
clamd.sock (Can't connect to UNIX socket /var/clamav/clamd.sock: No such
file or directory) at (eval 38) line 257.
WARN: all primary virus scanners failed, considering backups

I checked to make sure that the LocalSocket in clamd.conf is the same value
as the value in amavisd.conf. They both point to the same location.

Any help would be appreciated.
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Friday, January 14 2005 @ 05:04 pm CST
I'm wondering if the Berkley DB installed with sieve works with this anti virus setup.
The reason I ask is beause in these directions it explicitly states
"Don't install BerkeleyDB using an installer package, build it from source"
I already installed the Berkley DB with the pkg as the sieve instructions require.
Does anybody have this and sieve running ? Anything special needed for setup ?
Thanks
Updated Spam/Virus controls for OS X Server
Authored by: serversolutions on Sunday, January 16 2005 @ 11:15 pm CST
This article assumes one of the following:

1) you have no clue what you are doing you must follow the instructions
exactly as stated.

2) you know what your doing and know what changes to make to use
software/modules installed in other locations.

3) if you can't install the perl BerkeleyDB module then you didn't install the
BerkeleyDB binary as instructed.

4) if you have a can't connect to socket mesage then something isn't running
or you didn't follow the directions.

5) if you can't find the logroll or startup item folders then you didn't read the
instructions.

6) if you leave a message as an anonymous user, maybe one of the other
users might respond to you.
BerkeleyDB libdb and db.h versions
Authored by: johnwall on Thursday, January 27 2005 @ 01:26 pm CST
I have installed this on a few servers and they all worked fine. Now I am trying
to reinstall it on a restored server. I donwloaded new binaries and ran the
installs. But when I try to start amavisd I get the following:
Problem in Amavis::DB or Amavis::DB::SNMP code:
BerkeleyDB needs compatible versions of libdb & db.h
you have db.h version 4.3.21 and libdb version 4.3.27
Compilation failed in require at (eval 34) line 11.
BEGIN failed--compilation aborted at (eval 34) line 11.

The annoying thing is that I checked the header in /usr/include/db.h and it
says:
/*
* Berkeley DB version information.
*/
#define DB_VERSION_MAJOR 4
#define DB_VERSION_MINOR 3
#define DB_VERSION_PATCH 27
#define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 4.3.27:
(December 22, 2004)"
So who or what is claiming that it is a different version?

Thanks for any help.
Updated Spam/Virus controls for OS X Server
Authored by: sdevore on Saturday, January 29 2005 @ 10:08 am CST
I just finished upgrading from the earlier version of this article and it seems that I am getting some messages to go through but other seem to be getting postfix/qmgr[333]: warning: connect to transport smtp-amavis: Connection refused errors, I have double checked all the information and I think I have everything write, the only thing that I noticed was it seemed like clamav is writing it's socket in /var/clamav/clamav.sock is this from the old version's config file not being overwritten with the new one? I changed the amavisd config to point to this sock, or should I remove all the old config files and re-install them? Sam D
Updated Spam/Virus controls for OS X Server
Authored by: alexiskai on Thursday, February 03 2005 @ 10:36 pm CST
Problem: Inline::C refuses to install, saying "Couldn't find diagnostic data."

Cause: Inline.pm requires perldiag.pod, which is only installed if you install the XCode Documentation package.

Solution: Enter the following commands:

sudo mkdir /System/Library/Perl/5.8.1/pods
curl -O http://public.activestate.com/gsar/APC/perl-current/pod/perldiag.pod
sudo mv perldiag.pod /System/Library/Perl/5.8.1/pods/perldiag.pod

Then install Inline::C via CPAN again.
Updated Spam/Virus controls for OS X Server
Authored by: dougthurston on Thursday, February 10 2005 @ 02:29 pm CST
OK - i thought i had followed the steps exactly.... but when I try to start up
the mailtransport item with the SystemStarter, I get the following:

Welcome to Macintosh.
Unable to open parameters file /System/Library/StartupItems/Sendmail/
StartupParameters.plist for item Sendmail. (No such file or directory)
Initializing network
Starting MAILTRANSPORT
Waiting for MAILTRANSPORT
Scalar found where operator expected at /etc/amavisd.conf line 84, near
"$TEMPBASE"
(Missing semicolon on previous line?)
Error in config file "/etc/amavisd.conf": syntax error at /etc/amavisd.conf line
84, near "$TEMPBASE "
MAILTRANSPORT (6439) did not complete successfully.
The following StartupItems failed to properly start:
/Library/StartupItems/MAILTRANSPORT - execution of Startup script
failedStartup complete.
Hangup

So, what's the syntax error?

Here's what I see in TextWrangler from line 83-85:
#$TEMPBASE = "$MYHOME"; # (must be set if other config vars use is)
$TEMPBASE = "$MYHOME/tmp"; # prefer to keep home dir /var/
amavis clean

Changing the double-quotes to single and so on had no effect.

Am I just really dense and mis-copied something?
Error setting GID
Authored by: Anonymous on Friday, February 11 2005 @ 07:40 am CST

When I try to start /usr/bin/amavisd, I get the folowing message:

Net::Server: Setting gid to "30 30"
Net::Server: Couldn't become gid "30" (0)nn  at line 481 in file /Library/Perl/5.8.1/Net/Server.pm

Then the server quits. I checked that the user and group exist OK, which they do. Any ideas?

  • Error setting GID - Authored by: Anonymous on Friday, September 02 2005 @ 04:29 am CDT
Updated Spam/Virus controls for OS X Server
Authored by: matwyn on Monday, February 14 2005 @ 08:16 pm CST
Just tried installing this for the first time on a live server, after sucessfuly testing it on a test server, and no joy.

We get the following:

Problem in the antispam code: Can't locate Mail/SpamAssassin.pm in @INC (@INC contains: /System/Library/Perl/5.8.1/darwin-thread-multi-2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/Perl) at (eval 39) line 13. BEGIN failed--compilation aborted at (eval 39) line 13.

I'm assuming that this is something to do with the CPAN installation. The test server was pretty much out of the box so we just went with the defaults. This server already had had some Perl tools installed for other services - could that be the cause. There doesn't seem to be a SpamAssassin.pm file in any of the @INC folders, so I'm assuming that's the problem - I just need to know why it isn't there and at which point is (should) it (be) created?

Cheers

Corrupted attachments after amavisd/clam scanning?
Authored by: shay on Thursday, February 24 2005 @ 07:58 pm CST
Hi...

Excellent article.

After following this installation everything seemed to be working fine, except
that some attachments (I've noticed PDF's and JPEGS) are being corrupted.

Any ideas? I would have thought the e-mail would simply be sent through
untouched if it was uninfected, rather than being re-encoded.

Thanks!
Shay
Updated Spam/Virus controls for OS X Server
Authored by: mefkeys on Tuesday, March 01 2005 @ 07:24 am CST
I got most of it running but some questions arose, maybe some of you are
willing to answer them:

First I would like to indicate a typo. When adding spamassassin via CPAN the
author lists mail::spamassassin. However if you look closely you'll see that it
can't find spamassassin. Just write SpamAssassin and you'll be fine.

Furthermore I found out I needed the XCode development tools in order to
successfully compile berkeley and others. May sound obvious to you but I
didn't realise it :)

I can't seem to understand the instructions for the log rolling. The first
command makes no sense to ma as there is no dir called logroll. Then you
want to move the mailtransport dir but which mailtransport dir that is is
unclear to me. It's *not* the dir with the logs in it, that's for sure. Could you
shine a light on this ?

Along the process I made some typos myself but was able to correct them all
and everything (except the log rolling) seems to work now. In the incoming
email I notice a header from amavis and in the SMTP log I can see than an
email was found to be clean but I don't see anything that indicates a spam
check has been issued and/or processed. Did I miss something ?

Last but not least...
Updated Spam/Virus controls for OS X Server
Authored by: dtauvdiodr on Wednesday, April 06 2005 @ 05:48 pm CDT
I had spamassassin running with procmail, and following these instructions to add amavisd and clamav worked great, thank you for the good summary - would have been crawling through READMEs for days without this.

Some notes:

I prefer to install 3rd party stuff in /usr/local - putting symlinks in /usr/bin and /usr/sbin to the appropriate daemons under /usr/local works fine for me:

/usr/bin/amavisd@ -> /usr/local/bin/amavisd
/usr/bin/freshclam@ -> /usr/local/bin/freshclam
/usr/sbin/clamd@ -> /usr/local/sbin/clamd

I put my MAILTRANSPORT startup item in /Library/StartupItems and was not able to use the SystemStarter method of starting it up. But running '/Library/StartupItems/MAILTRANSPORT/MAILTRANSPORT start' worked.

HUP'ing (soft reset) postfix does not seem to work and/or load master.cf - actually I'm not sure what it's not doing. Errors were to the effect of 'smtp-mailtransport not found' (which I see some others are experiencing). When did a hard shutdown and restart of postfix, it works fine, and is delivering mail to amavisd. This might be because of the way my /etc/hostconfig file was setup - for some reason in OSX Panther (10.3.x), MAILSERVER is set to -NO-. I've changed this to YES, but things are working right now (and it's a production server), so leaving well enough alone for the moment. :)
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Friday, April 15 2005 @ 05:51 am CDT
Two things that are not necessarily clear, that would be helpful to update are:

in "Installing the Startup Item", and "- (Optional)
Installing the Log Roll Item", the files you're referring to are found
in the "Macintosh.tar.gz" file, which itself is within the Amavis files after
one has decompressed amavisd-new-2.2.x.tar.gz
(2.2.1 as of now).

The one other odd typo is, under the "Installing the Log Roll Item"
is that "/etc/default/periodic.conf" should read:
/etc/defaults/periodic.conf


The first of these is far more pressing, the second thing only takes a passing
moment to figure out/resolve.

Thanks for this article and method, I love it !
Patching Berleley DB
Authored by: roobieroo on Saturday, April 30 2005 @ 06:37 pm CDT
For those of you who may be unfamiliar with how to patch files, this is how to
apply the three patches for Berkeley DB 4.3.27. The patch files may not show up
depending on where you try and download BDB from. If you go here http://
www.sleepycat.com/download/index.shtml as of 4.3.27 there will be three
patch files. Save the patch files to your BDB directory. Now just run patch -p0 <
patchfile where patchfile is the name of the file itself. For example patch -p0 <
patch.4.3.27.1
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Friday, May 13 2005 @ 08:19 am CDT
SpamAssasin is working fine. But these days some spam are able to make it through. Is there any setting to change so that most of the spam can be caught ?

Also I see in the log file "No $DSPAM found". What is this ?

Appreciate any help.
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Saturday, May 21 2005 @ 12:38 am CDT
I just wanted to say thanks for such a great info package, this saved a lot
of time and other than a few quirky things, worked like a charm!

Just thought I'd help clarify some things for others:
- First of all, make sure you have the X-Tools developers tools installed on
your system before doing the installs, the development tools are available
from developer.apple.com

- After downloading all the archives, the instructions tell you to change
folder names, just to make it really obvious, it refers to all folders:
ex.
% mv ./clamav-0.80 ./clamav
so also change amavis, gmp, berkeley etc..

If you are like me and wanted to use virtual domain aliases (as opposed
to just aliases) and an email archive of all incoming/outgoing messages,
you will need to make some other changes (note: these changes work on
OSX Server 10.3.9, so I presume will work on atleast all Panther server
configs):
- first, for the always_bcc option, don't use the Apple GUI to set this, it
will bcc all emails BEFORE the filters get to the message, you will need to
edit your postfix master.cf file (/etc/postfix/master.cf) and look for the
line:

smtp inet n - n - - smtpd

which should be at the top of all the daemons list, change it to the
following for archiving all email that goes through the server (after the
filters):

smtp inet n - n - - smtpd
-o always_bcc=[archive]

where [archive] is the name of an account you have set up to store all
email.

- The other problem I had was using Virtual Domain Aliases (in /etc/
postfix/virtual), for example:

webmaster@domain.com localuser
webmaster@domain2.com otherlocaluser

and have all aliased names scanned by SPAMASSASSIN as well (all emails
are scanned for viruses, but using the setup instructions above, only real
user accounts are scanned by SPAMASSASSIN, leaving all the virtual
domain alias names open for spammers), now you would think this would
be easy (and there probably is another way that is easier which hopefully
someone can share here for me as well!), after DAYS of looking around
the net, reading everything I can and MUCH trial and error, I found the
following additions to the master.cf file work:

Find this line:
smtp inet n - n - - smtpd

Change to:
smtp inet n - n - - smtpd
-o always_bcc=[archive]
-o cleanup_service_name=pre-cleanup
#note: the always_bcc option is only used if you want to archive all
messages as noted above

Find this line:
pickup fifo n - n 60 1 pickup

Change to:
pickup fifo n - n 60 1 pickup
-o cleanup_service_name=pre-cleanup

go to the bottom of the master.cf file and add:
pre-cleanup unix n - n - 0 cleanup
-o virtual_alias_maps=
# comment out above to leave virtual aliasing to be done after cleanup
-o canonical_maps=
-o sender_canonical_maps=
-o recipient_canonical_maps=
-o masquerade_domains=

cleanup unix n - n - 0 cleanup
-o mime_header_checks=
-o nested_header_checks=
-o body_checks=
-o header_checks=

Once you have made these changes, save the master.cf file and sudo
postfix reload, this will now use SPAMASSASSIN to check ALL emails
including virtual domain aliased emails as well as scan ALL emails with
clamd anti-virus.

I have also found that simply doing a sudo postfix reload does not always
reset the changes made in main.cf or master.cf and found the only way to
do it properly (and easily) is to use the Apple GUI to stop the server and
then wait a few moments and start it again.

I hope this saves someone else a lot of time, this is working perfectly for
me now and as far as I know is not creating any extra demand on
processes, if anyone knows an easier way to do this or has any feedback
that I can improve on this, please post it here!
Updated Spam/Virus controls for OS X Server
Authored by: nelson-macforce on Tuesday, May 24 2005 @ 12:33 pm CDT
Very nice stuff! Thanks for posting this. One small tip; when executing multiple commands that are dependent on each other in a single shell line, use && (logical AND) rather than ";" to separate them. For eample:

# make && sudo make install
Doing it this way, the "make install" will not execute if the first "make" returns failure. Usually not a big deal, but can save you problems if the makefile is poorly written.
Updated Spam/Virus controls for OS X Server
Authored by: Anonymous on Tuesday, May 24 2005 @ 09:51 pm CDT
I just finished upgrading a client's system to Tiger server from Panther server
with the homerolled Clamav/Amavis system posted here.

A few things to watch out for!

1. If you perform an upgrade rather than a fresh install the installer will
append the new ClamAv/Amavis settings to the current one and cause you
LOTS of headaches. I recommend deactivating the old main.cf and master.cf
files, remove the MAILTRANSPORT startup item and the entry in /etc/
hostconfig and perhaps reset all your settings in the mail section of Server
admin.

2. I also had to rebuild the DNS domain entries from scratch. The new format
and GUI in Tiger, while better in some respects was problematic after the
upgrade.

3. The old Webserver folder gets renamed! If you try and just fire up the web
process after the upgrade your sites will fail to load! Its a simple process to
touch each of the entries and point them to the new location of the folder or
you can rename the old folder and get things going again quickly.

Otherwise the upgrade went pretty well.
Updated Spam/Virus controls for OS X Server
Authored by: mkennard20 on Monday, November 28 2005 @ 04:12 am CST
I want to do this with buildsmart. Does anyone know how to remove this setup
as I did it sometime ago?
Updated Spam/Virus controls for OS X Server
Authored by: davidstodolsky on Saturday, May 27 2006 @ 06:03 am CDT
On a clean 10.3.9 install, I got this error when trying the first format for
Setting up the user/group, while the second worked. Does this indicate a
problem?
-------

mail:~ admin$ sudo dscl localhost -create /NetInfo/root/Groups/
mailtransport

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Password:
<main> attribute status: eDSPermissionError
mail:~ admin$ sudo niutil -create . /groups/mailtransport
Password:
mail:~ admin$ sudo niutil -createprop . /groups/mailtransport gid 30
MAILTRANSPORT PROBLEM 10.3.9
Authored by: Iceman on Monday, August 04 2008 @ 03:55 am CDT
Hello everybody. I instaled all thinks thru this manual. All seems to be OK, but when i tried to configure startup item i saw folowing error.

I puted comman:

sudo mv MAILTRANSPORT /System/Library/StartupItems/

..and terminal tald me:

mv: rename MAILTRANSPORT to /System/Library/StartupItems/MAILTRANSPORT: No such file or directory

...so and what now?

i tried to locate MAILTRANSPORT and i didnt find anything (only log Folders founds) on my server.
Anybody knows where could be problem?
I have 10.3.9 server.

Thank you everybody for you advices.

Iceman