summaryrefslogtreecommitdiff
path: root/debian/examples/amavis-doc/amavis-doc.lyx
blob: 180015bdbc98253c514728f299deedf62ef441b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
#LyX 1.1 created this file. For more info see http://www.lyx.org/
\lyxformat 218
\textclass linuxdoc
\language english
\inputencoding default
\fontscheme default
\graphics default
\paperfontsize 10
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Title
\added_space_top vfill \added_space_bottom vfill 
How to Install Amavis-milter for Debian Sendmail
\layout Author

Jean-Paul Stewart <jps@maxlingua.com>
\layout Date

23.10.2001
\layout Abstract

This document provides a step-by-step guide to the installation and configuratio
n of the Amavis antivirus software available from 
\begin_inset LatexCommand \url{http://www.amavis.org/}

\end_inset 

 on the Debian GNU/Linux operating system.
 It has been adapted from the documentation available there.
 Amavis supports many different methods of implementation.
 I have chosen to implement Amavis-libmilter as the interface between Amavis
 and Sendmail.
 Another option with Amavis + Sendmail, which I am not describing here,
 involves employing Amavis as a sort of intermediate local delivery agent.
 Please be advised that this software requires an existing CLI antivirus
 scanning engine and database.
 The selection and procurement of such software is not discussed in this
 document.
 There is ample information available at the amavis.org site.
 These installation examples make extensive use of the outstanding Sendmail
 and libmilter-dev Debian packages maintained by Richard 
\begin_inset Quotes eld
\end_inset 

cowboy
\begin_inset Quotes erd
\end_inset 

 Nelson.
 Thanks Cowboy! Thank you Amavis developers!
\layout Standard


\begin_inset LatexCommand \tableofcontents{}

\end_inset 


\layout Section

Software Dependencies
\layout Enumerate

At a minimum you need to be running the Debian 3.0 (Woody) distribution from
 
\begin_inset LatexCommand \url{http://www.debian.org/}

\end_inset 

.
 Older versions of Debian do not provide an adequate sendmail package (they
 lack the libmilter API).
\layout Enumerate

Obviously, sendmail needs to be installed on your system.
\layout Enumerate

As mentioned in the abstract, you will have to obtain your own antiviral
 engine from an independent vendor.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

file
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

arc
\begin_inset Quotes erd
\end_inset 

 utility.
 It is not available as a Debian package.
 You can obtain the source code for this program at 
\begin_inset LatexCommand \url{ftp://metalab.unc.edu/pub/Linux/utils/compress/arc521.tar.Z}

\end_inset 

.
 
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

bzip2
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

lha
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

unarj
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

unrar
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

The 
\begin_inset Quotes eld
\end_inset 

zoo
\begin_inset Quotes erd
\end_inset 

 package.
\layout Enumerate

You may need to install a few perl modules.
 The required modules are
\layout Itemize

IO-stringy
\layout Itemize

Syslog
\layout Itemize

MailTools
\layout Itemize

MIME-Base64
\layout Itemize

MIME-tools
\layout Itemize

Convert-UUlib
\layout Itemize

Convert-TNEF
\layout Itemize

Compress-Zlib
\layout Itemize

Archive-Tar
\layout Itemize

Archive-Zip
\layout Itemize

libnet
\layout Section

Installing the Software Dependencies
\layout Standard

Update your distribution files with the usual:
\layout Verbatim

apt-get update
\layout Standard

and install file, bzip2, lha, unarj, unrar, and zoo in one shot with:
\layout Verbatim

apt-get install file bzip2 lha unarj unrar zoo
\layout Standard

Install all the perl modules in one shot with:
\layout Verbatim

apt-get install libio-stringy-perl libunix-syslog-perl libmailtools-perl
 libmime-base64-perl libmime-perl libconvert-uulib-perl libconvert-tnef-perl
 libcompress-zlib-perl libarchive-tar-perl libarchive-zip-perl libnet-perl
\layout Standard

Installing the 
\begin_inset Quotes eld
\end_inset 

arc
\begin_inset Quotes erd
\end_inset 

 utility is much more of a hassle.
 Furthermore, it is an unmaintained old MS-DOS port with a non-free license.
 I will describe what I did to compile it on a Intel platform (suggestions
 on better ways to do this are appreciated).
 The next few steps assume that you have the GNU 
\begin_inset Quotes eld
\end_inset 

make
\begin_inset Quotes erd
\end_inset 

 and 
\begin_inset Quotes eld
\end_inset 

gcc
\begin_inset Quotes erd
\end_inset 

 packges installed on your system.
 If this is not the case then try:
\layout Verbatim

apt-get install make gcc
\layout Standard

Let's create a temporary directory somewhere so that we can make a mess
 in it.
 Since my login is 
\begin_inset Quotes eld
\end_inset 

jps
\begin_inset Quotes erd
\end_inset 

, I made a directory named 
\begin_inset Quotes eld
\end_inset 

/home/jps/tmp/
\begin_inset Quotes erd
\end_inset 

.
 Copy the arc521.tar.Z file into your new temporary diretory and type: 
\layout Verbatim

uncompress arc521.tar.Z; tar xf arc521.tar
\layout Standard

or something equivalent to uncompress and untar the archive.
 This will create a bunch of files.
 We need to delete some lines from the file named 
\begin_inset Quotes eld
\end_inset 

arcdos.c
\begin_inset Quotes erd
\end_inset 

.
 It is probably set to be read-only, so type:
\layout Verbatim

chmod u+w arcdos.c
\layout Standard

Open arcdos.c for editing and delete (or comment out) lines 35-38 inclusive.
 (It is the definition of a structure that begins with 
\begin_inset Quotes eld
\end_inset 

struct timeval
\begin_inset Quotes erd
\end_inset 

 on line 35 and ends with 
\begin_inset Quotes eld
\end_inset 

};
\begin_inset Quotes erd
\end_inset 

 on line 38).
 We are done with that, so close the file.
 Now type:
\layout Verbatim

make
\layout Standard

This command WILL FAIL with a bunch of warnings and an error message complaining
 about 
\begin_inset Quotes eld
\end_inset 

tmclock.o
\begin_inset Quotes erd
\end_inset 

, but it accomplished some necessary things anyway.
 Now open the file named 
\begin_inset Quotes eld
\end_inset 

Makefile
\begin_inset Quotes erd
\end_inset 

 for editing.
 Go to the line that says 
\begin_inset Quotes eld
\end_inset 

System = -DBSD=1
\begin_inset Quotes erd
\end_inset 

.
 It should be on line 31.
 Change the line so that it says:
\layout Verbatim

System = -DSYSV=1
\layout Standard

Close the Makefile and run make again by typing:
\layout Verbatim

make
\layout Standard

That should compile the 
\begin_inset Quotes eld
\end_inset 

arc
\begin_inset Quotes erd
\end_inset 

 utility successfully.
 You can ignore the warnings about 
\begin_inset Quotes eld
\end_inset 

mktemp
\begin_inset Quotes erd
\end_inset 

 and 
\begin_inset Quotes eld
\end_inset 

mkstemp
\begin_inset Quotes erd
\end_inset 

.
 There should now be an executable program with the name of 
\begin_inset Quotes eld
\end_inset 

arc
\begin_inset Quotes erd
\end_inset 

 in your temporary directory.
 As root, copy this file to 
\begin_inset Quotes eld
\end_inset 

/usr/local/bin
\begin_inset Quotes erd
\end_inset 

 or the usual place where you keep home-cooked binaries.
 Just make sure that it is in your path.
 Test this by typing 
\begin_inset Quotes eld
\end_inset 

arc
\begin_inset Quotes erd
\end_inset 

 and see if the arc usage guide scrolls up your terminal.
 You can delete all the files in your temporary directory now, but leave
 the directory itself because we will be using it later.
 Aren't .deb packages so much easier? 
\layout Section

Example Installation of an Antivirus Scanner
\layout Standard

I am using a Linux commandline scanner from NAI Associates, Inc.
 You will have to avail yourself of the documentation at 
\begin_inset LatexCommand \url{http://www.amavis.org/}

\end_inset 

 if you don't know where to obtain a scanner.
 For example, you could place your scanner binary along with its' data files
 in a directory named 
\begin_inset Quotes eld
\end_inset 

/usr/local/share/av
\begin_inset Quotes erd
\end_inset 

.
 Then create a symlink to the binary in the 
\begin_inset Quotes eld
\end_inset 

/usr/local/bin
\begin_inset Quotes erd
\end_inset 

 directory.
 This way, the command to execute the scanner is in your path, and the Amavis
 configure script will find it.
 For a more advanced configuration (once you have the easy stuff out of
 the way), take a look at the example start-stop script at the end of this
 document.
\layout Section

Obtaining the Libmilter Sourcecode and Libraries
\layout Standard

In order to be able to build Amavis with the libmilter interface, you need
 to have the Sendmail's libmilter sourcecode and libraries available.
 Don't worry, this is very easy with Debian.
 The following command will dowload everything required to your system:
\layout Verbatim

apt-get install libmilter-dev
\layout Section

Obtaining the Amavis Sourcecode
\layout Subsection

Checking the latest copy out of CVS
\layout Standard

\begin_float footnote 
\layout Standard

As of October 23, 2001; the CVS copy might not compile.
 Skip to the next section if you don't want to fool around.
\end_float 
Now that we have extracted the libmilter files, the next step is to obtain
 the latest copy of the Amavis sourcecode.
 We will retrieve this code from the Amavis CVS repository at 
\begin_inset LatexCommand \url{http://sourceforge.net/}

\end_inset 

.
 If you do not already have the CVS package installed on your system, you
 can obtain it with the command:
\layout Verbatim

apt-get install cvs
\layout Verbatim

cvs -d:pserver:anonymous@cvs.amavis.sourceforge.net:/cvsroot/amavis login
\layout Standard

You will be logging in anonymously, so just press enter at the password
 prompt.
 If CVS gives you a hard time about 
\begin_inset Quotes eld
\end_inset 

$HOME/.cvspass
\begin_inset Quotes erd
\end_inset 

 not existing, then simply type:
\layout Verbatim

touch $HOME/.cvspass
\layout Standard

and issue the command once more.
 With these preliminaries out of the way we can download the actual source
 with:
\layout Verbatim

cvs -z3 -d:pserver:anonymous@cvs.amavis.sourceforge.net:/cvsroot/amavis co
 amavis
\layout Standard

This will create a subdirectory named 
\begin_inset Quotes eld
\end_inset 

amavis
\begin_inset Quotes erd
\end_inset 

 in your temporary directory.
 Please skip to section titled 
\begin_inset Quotes eld
\end_inset 

Building Amavis
\begin_inset Quotes erd
\end_inset 

.
\layout Subsection

If the CVS copy blows chunks
\layout Standard

If you are like me, and the CVS copy died hideously during 
\begin_inset Quotes eld
\end_inset 

./configure
\begin_inset Quotes erd
\end_inset 

, then download the the 
\begin_inset Quotes eld
\end_inset 

official
\begin_inset Quotes erd
\end_inset 

 CVS snapshot from 
\begin_inset LatexCommand \url{http://sourceforge.net/projects/amavis/}

\end_inset 

.
 The available version at the time of this writing was 
\begin_inset Quotes eld
\end_inset 

amavisd-snaphot-20010714
\begin_inset Quotes erd
\end_inset 

.
 You can dowload this as a tarball.
 Copy this file into your temporary directory and run:
\layout Verbatim

tar zxf <filename>
\layout Standard

That should give you a nice directory of sourcecode.
\layout Section

Building Amavis
\layout Standard

Regardless of the method you used to obtain it, please change to your new
 amavis sourcecode directory and type the following command to build Amavis
 with libmilter:
\layout Verbatim

LDFLAGS=
\begin_inset Quotes erd
\end_inset 

-L/usr/lib/libmilter
\begin_inset Quotes erd
\end_inset 

 ./configure --with-amavisuser=amavis --prefix=/usr/local --with-runtime-dir=/var
/local/amavis --enable-milter --with-sendmail-source=/usr/include/libmilter
\layout Standard

Then simply run make by typing:
\layout Verbatim

make
\layout Standard

This will create, among other things, the amavisd perl script and the amavis-mil
ter binary in your 
\begin_inset Quotes eld
\end_inset 

<amavis-sourcecode-directory>/amavis/
\begin_inset Quotes erd
\end_inset 

 directory.
 If the previous steps failed for any reason, go to the section titled 
\begin_inset Quotes eld
\end_inset 

If the CVS copy blows chunks
\begin_inset Quotes erd
\end_inset 

 and rerun the 
\begin_inset Quotes eld
\end_inset 

Building Amavis
\begin_inset Quotes erd
\end_inset 

 section from the beginning.
\layout Section

Installing and Running Amavis
\layout Standard

Hopefully we passed the correct options to the Amavis configure script so
 that when we install it, the Debian file system policy won't be violated.
 That would be bad karma.
 Create a user named 
\begin_inset Quotes eld
\end_inset 

amavis
\begin_inset Quotes erd
\end_inset 

 with:
\layout Verbatim

useradd amavis
\layout Standard

From the amavis-sourcecode-directory type:
\layout Verbatim

make install
\layout Standard

If everythiny worked, the install script should have
\layout Itemize

copied the amavisd perl script to /usr/local/sbin
\layout Itemize

copied the amavis-milter binary to /usr/local/sbin
\layout Itemize

created the /var/local/amavis directory with owner amavis and mode 2700
 or 0700
\layout Itemize

created a file named /etc/amavisd.conf
\layout Standard

Now you will need to create an alias in /etc/aliases or /etc/mail/aliases
 (or wherever you keep your mail aliases) for the 
\begin_inset Quotes eld
\end_inset 

virusalert
\begin_inset Quotes erd
\end_inset 

 email address that Amavis will try and send virus reports to.
 Generally, this should be the system administrator.
\layout Standard

Don't forget to rebuild the aliases file by issuing:
\layout Verbatim

newaliases
\layout Standard

Finally, open up the /etc/mail/sendmail.mc file for editing and insert the
 following two lines anywhere after the line the begins with 
\begin_inset Quotes eld
\end_inset 

## Custom configurations
\begin_inset Quotes erd
\end_inset 

 (it is near the bottom):
\layout Verbatim

define(`_FFR_MILTER', `1')dnl
\layout Verbatim

INPUT_MAIL_FILTER(`milter-amavis', `S=local:/var/local/amavis/amavis-milter.sock,
 T=S:10m;R:10m;E:10m')dnl
\layout Standard

After you close the /etc/mail/sendmail.mc file, start-up amavis-milter and
 amavisd with the following three commands:
\layout Verbatim

rm -rf /var/local/amavis/amavis-milter.sock
\layout Verbatim

nohup /usr/local/sbin/amavis-milter -p /var/local/amavis/amavis-milter.sock
 &
\layout Verbatim

/usr/local/sbin/amavisd
\layout Standard

Now that Amavis is ready and running, you can fire-up your new sendmail
 configuration with:
\layout Verbatim

sendmailconfig
\layout Standard

This command will recreate the /etc/mail/sendmail.cf file from the /etc/mail/send
mail.mc file and reload the sendmail daemon.
 An alternate approach is to delete the /etc/mail/sendmail.cf file, run 
\begin_inset Quotes eld
\end_inset 

make
\begin_inset Quotes erd
\end_inset 

 in the /etc/mail directory, and restart sendmail with 
\begin_inset Quotes eld
\end_inset 

/etc/init.d/sendmail restart
\begin_inset Quotes erd
\end_inset 

 (or whatever it is that you use).
\layout Section

An Example Startup script
\layout Code

#!/bin/sh 
\layout Code

# /etc/init.d/amavis-ramdisk
\layout Code

# Script to run Amavis from a ram disk.
\layout Code

\layout Code

# I keep my antiviral scanner and data files on a ramdisk for speed.
\layout Code

AVDIR="/usr/local/share/av.original"
\layout Code

RAMDISK="/usr/local/share/av.ramdisk"
\layout Code

AMAVISBIN="/usr/local/sbin"
\layout Code

AMAVISSOCK="/var/local/amavis"
\layout Code

[ -d $AVDIR -a -d $RAMDISK ] || exit 0
\layout Code

case "$1" in
\layout Code

start)
\layout Code

   mke2fs /dev/ram0 > /dev/null 2>&1
\layout Code

   mount /dev/ram0 $RAMDISK
\layout Code

   cp $AVDIR/* $RAMDISK
\layout Code

   if [ -S $AMAVISSOCK/amavis-milter.sock ]; then
\layout Code

      rm -rf $AMAVISSOCK/amavis-milter.sock
\layout Code

   fi
\layout Code

   if [ -S $AMAVISSOCK/amavisd.sock ]; then
\layout Code

      rm -rf $AMAVISSOCK/amavisd.sock
\layout Code

   fi
\layout Code

   nohup $AMAVISBIN/amavis-milter -p $AMAVISSOCK/amavis-milter.sock &
\layout Code

   $AMAVISBIN/amavisd
\layout Code

;;
\layout Code

stop)
\layout Code

   kill -9 `ps x | grep amavisd | grep -v grep | awk '{print $1}'`2> /dev/null
\layout Code

   kill -9 `ps x | grep amavis-milter | grep -v grep | awk '{print $1}'`
 2> /dev/null
\layout Code

   # I need to sleep for some reason :(
\layout Code

   sleep 2umount /dev/ram0
\layout Code

;;
\layout Code

*)
\layout Code

   echo "Usage: /etc/init.d/amavis-ramdisk {start|stop}"
\layout Code

   exit 1
\layout Code

;;
\layout Code

esac
\layout Code

exit 0
\layout Standard

Don't forget to update your antivirus data files regularly.
 
\layout Quote

Send all comments and corrections to <jps@maxlingua.com>.
 Support free software!
\the_end