File: dccifd.8

package info (click to toggle)
dcc 1.2.74-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,552 kB
  • ctags: 4,041
  • sloc: ansic: 41,034; perl: 2,310; sh: 2,186; makefile: 224
file content (1080 lines) | stat: -rw-r--r-- 29,512 bytes parent folder | download | duplicates (4)
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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
.\" Copyright (c) 2005 by Rhyolite Software
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE DISCLAIMS ALL
.\" WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE
.\" BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
.\" WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
.\" Rhyolite Software DCC 1.2.74-1.34 $Revision$
.\"
.Dd 2005/03/18 23:47:04
.ds volume-ds-DCC Distributed Checksum Clearinghouse
.Dt dccifd 8 SMM
.Sh NAME
.Nm dccifd
.Nd Distributed Checksum Clearinghouse Program Interface
.Sh SYNOPSIS
.Bk -words
.Nm dccifd
.Op Fl VdbxANQ
.Op Fl G Ar on | off | noIP | IPmask/xx
.Op Fl h Ar homedir
.Op Fl p Ar /sock | host,port,rhost/bits
.Op Fl o Ar /sock | host,port
.br
.Op Fl D Ar local-domain
.Op Fl r Ar rejection-msg
.Op Fl m Ar map
.Op Fl w Ar whiteclnt
.Op Fl U Ar userdirs
.Op Fl a Ar IGNORE|REJECT
.Oo
.Fl t Xo
.Sm off
.Ar type,
.Op Ar log-thold,
.Ar rej-thold
.Sm on
.Xc
.Oc
.br
.Oo
.Fl g Xo
.Sm off
.Op Ar not-
.Ar type
.Sm on
.Xc
.Oc
.Op Fl S Ar header
.Op Fl l Ar logdir
.Op Fl R Ar rundir
.Op Fl T Ar tmpdir
.br
.Op Fl j Ar maxjobs
.Op Fl B Ar dnsbl-option
.Op Fl L Ar ltype,facility.level
.Ek
.Sh DESCRIPTION
.Pp
.Nm Dccifd
is a daemon intended to connect spam filters such as SpamAssasin
and mail transfer agents (MTAs) other than sendmail to DCC servers.
The MTA or filter
.Nm
which in turn reports related checksums to the nearest DCC server.
DCCIFD
then adds an
.Em X-DCC
SMTP header line to the message.
The MTA is told to reject the message if it is unsolicited bulk.
.Pp
.Nm Dccifd
is similar to the DCC sendmail milter interface,
.Xr dccm 8
and the DCC Procmail interface,
.Xr dccproc 8 .
.Nm
is more efficient than dccproc
but not restricted to use with sendmail.
All three send reports of checksums related to mail received by DCC clients
and queries about the total number of reports of particular checksums.
.Pp
MTA programs generally use a simple ASCII protocol to send
a mail message including its SMTP envelope to the daemon.
.Nm Dccifd
responds with an indication of whether the message is unsolicited bulk
and an optional copy of the message with an
.Em X-DCC
header added.
The protocol is described below and in the
.Pa include/dccif.h
file in the DCC source.
There is a sample C interface routine in the
.Pa dcclib/dccif.c
file in the DCC source and the
.Pa dcclib.a
library generated from the source.
A
.Em Perl
version of the interface routine is in
.Pa dccifd/dccif.pl .
Test or demonstration programs in the style of
.Xr dccproc 8
that use those interface routines are in
.Pa dccifd/dccif-test .
.Pp
A subset of ESMTP can be used instead of the ASCII protocol
to connect
.Nm
to postfix as a "Before-Queue Content Filter."
See the
.Fl o
flag.
.Pp
Since the checksums of messages that are whitelisted locally
by the
.Fl w Ar whiteclnt
file are not reported to the DCC server,
.Nm
knows nothing about the total recipient counts for their checksums and
so cannot add
.Em X-DCC
header lines to such messages.
.Pp
The list of servers that
.Nm
contacts is in a memory mapped file shared by local DCC clients.
The file is maintained with
.Xr cdcc 8 .
Turn on the daemon and put its parameters in the
.Pa dcc_conf .
Start the daemon with the
.Pa start-dccifd
script.
.Ss OPTIONS
The following options are available:
.Bl -tag -width 3n
.It Fl V
displays the version of the DCC program interface.
.It Fl d
enables debugging output from the DCC client library.
Additional
.Fl d
options increase the number of messages.
A single
.Fl d
causes aborted SMTP transactions to be logged.
.It Fl b
causes the daemon to not detach itself from the controlling tty
and put itself into the background.
.It Fl x
causes the daemon to try "extra hard" to contact a DCC server.
Since it is usually more important to deliver mail than to report its
checksums,
.Nm
normally does not delay too long while trying to contact a DCC server.
It also will not try again for several seconds after a failure.
With
.Fl x ,
it will always try to contact the DCC server
and it will tell the MTA to answer the DATA command with a 4yz
temporary failure.
.It Fl A
adds to existing X-DCC headers in the message
instead of replacing existing headers
of the brand of the current server.
.It Fl N
neither adds, deletes, nor replaces existing X-DCC headers in the message.
Each message is logged, rejected, and otherwise handled the same.
.It Fl Q
only queries the DCC server about the checksums of messages
instead of reporting and querying.
This is useful when
.Nm
is used to filter mail that has already been reported to a DCC
server by another DCC client.
This can also be useful when applying a private white or black list to
mail that has already been reported to a DCC server.
No single mail message should be reported to a DCC
server more than once per recipient,
because each report will increase the apparent "bulkness" of the message.
.It Fl G Ar on | off | noIP | IPmask/xx
controls
.Em greylisting .
At least one working greylist server must be listed in the
.Pa map
file in the DCC home directory.
If more than one is named,
they must "flood" or change checksums and they must use the
same
.Fl G
parameters.
See
.Xr dccd 8 .
Usually all DCC client processes of dccm or dccifd should use the same
.Fl G
parameters.
.Pp
.Ar IPmask/xx
and
.Ar noIP
remove part or all of the IP address from the greylist triple.
The CIDR block size,
.Ar xx ,
must be between 1 and 128.
96 is added to block sizes smaller than 33 to make them appropriate for
the IPv6 addresses used by the DCC.
.Ar IPmask/96
differs from
.Ar noIP
because the former retains the IPv4 to IPv6 mapping prefix.
.It Fl W
turns off DCC filtering by default to ease managing systems where
only a minority of
users want unsolicited bulk mail to be rejected.
This is equivalent to a
.Ar option dcc-off
line in the main
.Fl w Ar whiteclnt
file.
When DCC filtering is off,
the DCC server is queried and the
.Em X-DCC
header is added but the message is marked to be delivered regardless of
target counts and thresholds.
.Pp
DCC filtering is enabled for a mailbox when
.Fl W
is not used and there is no
.Ar option dcc-off
line
in the main
or per-user
.Ar whiteclnt
file or there is a
.Ar option dcc-on
pine in the per-user
.Ar whiteclnt
file for the mailbox.
DCC filtering can also be enabled
with an "OK2" entry for the fully qualified mailbox in the
main or per-user
.Ar whiteclnt
file.
.Pp
Messages sent
.Em only
to target addresses that are listed in the global or relevant per-user
.Fl w Ar whiteclnt
file with "OK" are not reported to the DCC server
and so are not rejected and do not receive
.Em X-DCC
headers.
.It Fl h Ar homedir
overrides the default DCC home directory, which is often /var/dcc.
.It Fl p Ar /sock/name | host,port,rhost/bits
overrides the default address at which programs contact
.Nm dccifd .
The default is a UNIX domain socket named dccifd in the DCC home directory.
.\" dccifd socket name is DCC_DCCIF_UDS
.Pp
The second form specifies a local host name or IP address,
a local TCP port number,
and the host names or IP addresses of computers that can use
.Nm dccifd .
127.0.0.1 or
.Em localhost
are common choices for
.Ar host .
The string
.Ar @
specifies IN_ADDRANY or all local IP addresses.
127.0.0.0/8 is a common choice for
.Ar rhost/bits .
.It Fl o Ar /sock | host,port
enables SMTP proxy mode instead of the ASCII protocol
and specifies the address of the SMTP server
for which
.Nm
acts as SMTP client.
When
.Ar /sock
is
.Pa /var/null ,
.Nm
acts as if there were downstream SMTP server that always answers "250\ ok".
The string
.Ar @
specifies the same IP address as the incoming TCP connection.
.Pp
See below concerning the subset of ESMTP used in this mode.
.It Fl m Ar map
specifies a name or path of the memory mapped parameter file instead
of the default
.Pa map
in the DCC home directory.
It should be created with the
.Xr cdcc 8
command.
.It Fl w Ar whiteclnt
specifies an optional file containing SMTP client IP addresses,
SMTP envelope values, and header values
of mail that is not spam, does not need a X-DCC header,
and whose checksums should not be reported to the DCC server.
Local whitelist
.Ar env_To
values are handy for whitelisting or exempting destination addresses
such as Postmaster from filtering
and for blacklisting or marking addresses that should never receive mail.
Mail sent to blacklisted addresses or with other blacklisted values
such as From or env_From values is reported to the DCC server as
spam or with target counts of millions.
.Pp
If the pathname
.Ar whiteclnt
is not absolute, it is relative to the DCC home directory.
The format of the
.Nm
whiteclnt file is the same as the
.Pa whitelist
files used by
.Xr dbclean 8
and the
.Pa whiteclnt
file used by
.Xr dccproc 8 .
See
.Xr dcc 8
for a description of DCC white and blacklists.
Because the contents of the
.Ar whiteclnt
file are used frequently, a companion file is automatically
created and maintained.
It has the same pathname but with an added suffix of
.Ar .dccw
and contains a memory mapped hash table of the main file.
.Pp
A local whitelist entry ("OK") or two or more semi-white listings ("OK2")
for one of the message's checksums prevents all of
the message's checksums from being reported to the DCC server 
and the addition of a
.Em X-DCC
header line by
.Nm dccifd
(except for env_To checksums or when
.Fl W
is used).
A local whitelist entry for a checksum
also prevents rejecting the message based on DCC recipient
counts as specified by
.Fl t .
Otherwise, one or more checksums with blacklisting entries ("MANY") cause
all of the message's
checksums to be reported to the server with an addressee count of "MANY".
.Pp
If the message has a single recipient, an
.Ar env_To
local
.Ar whiteclnt
entry of "OK" for the checksum of its recipient address acts like any other
.Ar whiteclnt
entry of "OK."
When the SMTP message has more than one recipient,
the effects can be complicated.
When a message has several recipients with some but not all listed in the
.Ar whiteclnt
file,
.Nm
tries comply with the wishes of the users who want filtering as
well as those who don't by silently not delivering the message to 
those who want filtering (i.e. are not whitelisted) and delivering
the message to don't want filtering.
.Pp
Consider the
.Fl W
option for implicitly or by default whitelisting
.Em env_to
values.
.It Fl U Ar userdirs
enables private whitelists and log files.
Each target of a message can have a directory of log files named
.Ar userdirs/addr/log
where
.Ar addr
is the local user or mailbox name computed by the MTA.
The name of each user's log directory must be
.Ar log .
If it is not absolute,
.Ar userdirs
is relative to the DCC home directory.
The sub-directory prefixes for
.Fl l Ar logdir
are not honored.
The directory containing the log files must be named
.Ar log
and it must be writable by the
.Nm
process.
Each log directory must exist or logging for the corresponding
is silently disabled.
The files created in the log directory are owned by the UID of the
.Nm
process,
but they have
.Em group
and
.Em other
read and write permissions copied from the corresponding
.Ar log
directory.
To ensure the privacy of mail,
it may be good to make the directories readable only by
.Em owner
and
.Em group ,
and to use a
.Xr cron
script that changes the owner of each file to match the grandparent
.Ar addr
directory.
.Pp
There can also be a whitelist named
.Ar userdirs/addr/whiteclnt
for each address
.Ar addr.
The name of the file must be
.Ar whiteclnt .
Any checksum that is not white- or blacklisted by an individual
addressee's whitelist is checked in the
.Fl w whiteclnt
list.
A missing per-address
.Ar whiteclnt
file is the same as an empty file.
Relative paths for whitelists included in per-address files
are resolved in the DCC home directory.
The
.Ar whiteclnt
files and the
.Ar addr
directories containing them must be writable by the
.Nm
process.
.It Fl a Xo Ar IGNORE | REJECT
.Xc
specifies the action taken when
.Nm
is in proxy mode with
.Fl o
and the DCC server counts or
.Fl t
thresholds say that a message is unsolicited bulk.
.Ar IGNORE
causes the message to be unaffected except for adding the
.Em X-DCC
header line to the message.
This turns off DCC filtering.
.Pp
Spam can also be
.Ar REJECT Ns ed.
The default is
.Ar REJECT .
.Pp
With an action of
.Ar REJECT ,
spam sent to both white-listed targets
and non-white-listed targets is delivered to white-listed targets and
if possible, silently discarded for non-white-listed targets.
This is not possible if there are too many non-white-listed targets
to be saved in a buffer of about 500 bytes.
.Pp
The effects of the
.Fl w Ar whiteclnt
are not affected by
.Fl a .
.It Fl t Xo
.Sm off
.Ar type,
.Op Ar log-thold,
.Ar rej-thold
.Sm on
.Xc
sets logging and "spam" thresholds for checksum
.Ar type .
The checksum types are
.Ar IP ,
.Ar env_From ,
.Ar From ,
.Ar Message-ID ,
.Ar Received ,
.Ar Body ,
.Ar Fuz1 ,
and
.Ar Fuz2 .
The string
.Ar ALL
sets thresholds for all types, but is unlikely to be useful except for
setting logging thresholds.
The string
.Ar CMN
specifies the commonly used checksums
.Ar Body ,
.Ar Fuz1 ,
and
.Ar Fuz2 .
.Ar Rej-thold
and
.Ar log-thold
must be numbers, the string
.Ar NEVER ,
or the string
.Ar MANY
indicating millions of targets.
Counts from the DCC server as large as the threshold for any single type
are taken as sufficient evidence
that the message should be logged or rejected.
.Pp
.Ar Log-thold
is the threshold at which messages are logged.
It can be handy to log messages at a lower threshold to find
solicited bulk mail sources such as mailing lists.
If no logging threshold is set,
only rejected mail and messages with complicated combinations of white
and blacklisting are logged.
Messages that reach at least one of their rejection thresholds are
logged regardless of logging thresholds.
.Pp
.Ar Rej-thold
is the threshold at which messages are considered "bulk,"
and so should be rejected if not whitelisted.
.Pp
The checksums of locally whitelisted messages are not checked with
the DCC server and so only the number of targets of the current instance of
a whitelisted message are compared against the thresholds.
.Pp
The default is
.Fl t Ar ALL,NEVER ,
so that nothing is rejected or logged.
A common choice is
.Fl t Ar CMN,25,50
to reject
mail with common bodies except as overridden by
the whitelist of the DCC server and local
.Fl g ,
and
.Fl w .
.It Fl g Xo
.Sm off
.Op Ar not-
.Ar type
.Sm on
.Xc
indicates that whitelisted,
.Ar OK
or
.Ar OK2 ,
counts from the DCC server for a type of checksum are to be believed.
They should be ignored if prefixed with
.Ar not- .
.Ar Type
is one of the same set of strings as for
.Fl t .
Only
.Ar IP ,
.Ar env_From ,
and
.Ar From
are likely choices.
By default all three are honored,
and hence the need for
.Ar not- .
.It Fl S Ar hdr
adds to the list of substitute or locally chosen headers that
are checked with the
.Fl w Ar whiteclnt
file and sent to the DCC server.
The checksum of the last header of type
.Ar hdr
found in the message is checked.
.Ar Hdr
can be
.Em HELO
to specify the SMTP envelope HELO value.
.Ar Hdr
can also be
.Em mail_host
to specify the host name from
the Mail_from value in the SMTP envelope.
.\"see DCC_MAX_SUB_CKS
As many as 6 different substitute headers can be specified, but only
the checksum of the first of the 6 will be sent to the DCC server.
.It Fl l Ar logdir
specifies a directory in which files containing copies of messages processed by
.Nm
are kept.
All messages logged are copied to the
.Fl l Ar logdir
directory.
They can also be copied to per-user directories specified with
.Fl U .
Information about other recipients of a message is deleted from
the per-user copies.
.Pp
If
.Ar logdir
starts with
.Em D? ,
log files are put into subdirectories of the form
.Ar logdir/JJJ
where
.Ar JJJ
is the current julian day.
.Ar H?logdir
puts logs files into subdirectories of the form
.Ar logdir/JJJ/HH
where
.Ar HH
is the current hour.
.Ar M?logdir
puts log files into subdirectories of the form
.Ar logdir/JJJ/HH/MM
where
.Ar MM
is the current minute.
See the FILES section below concerning the contents of the files.
.Pp
The directory is relative to the DCC home directory if it is not absolute
.It Fl R Ar rundir
specifies the "run" directory where the UNIX domain socket and file
containing the daemon's process ID are stored.
The default value is often /var/run/dcc.
.It Fl T Ar tmpdir
changes the default directory for temporary files from the default.
The default is the directory specified with
.Fl l
or the system default if there
.Fl l
is not used.
The system default is often
.Pa /tmp .
.It Fl D Ar local-domain
specifies a host name by which the system is known.
There can be several
.Fl D
settings.
.Pp
To find the per-user log directory and whitelist for each mail recipient,
.Nm
must know each recipient's user name.
The default ASCII protocol
includes an optional user name with each
recipient SMTP address.
When that user name is absent or when
the subset of ESMTP enabled with
.Fl o
is used,
each mail address is checked against the
list of
.Fl D Ar local-domains .
If there is at least one match,
the part of the recipient address remaining after matching the longest
.Ar local-domain
is taken as the user name.
The matching is anchored at the right or the end of the recipient address.
It must start at a period (.) or at-sign (@) in the domain name part of
the address.
.It Fl r Ar rejection-msg
specifies the rejection message for unsolicited bulk mail or
for mail temporarily blocked by
.Em greylisting
when
.Fl G
is specified.
The first
.Ar rejection-msg
replaces the default bulk mail rejection message,
.Bk -words
"5.7.1 550 mail %s from %s rejected by DCC"
.Ek
." see DCC_XCODE and DCC_RCODE in cmn.c
The second replaces
.Bk -words
"4.2.1 452 mail %s from %s greylist temporary embargoed".
.Ek
." see GREY_XCODE and GREY_RCODE in cmn.c
There can be zero, one, or two "%s" strings.
The first is replaced an empty string and the second is replaced by
the IP address of the SMTP client.
.Pp
A common alternate for the bulk mail rejection message is
.Bk -words
"4.7.1 451 Access denied by DCC"
.Ek
." see GREY_XCODE and GREY_RCODE in cmn.c
to tell the sender to continue trying.
Use a 4yz response with caution, because it is likely to delay for days
a delivery failure message for false positives.
If the bulk mail rejection message
does not start with a recognized error type and number,
type 5.7.1 and 550 or 4.2.1 and 452 are used.
." see DCC_XCODE DCC_RCODE GREY_XCODE GREY_RCODE in cmn.c
.It Fl j Ar maxjobs
limits the number of simultaneous requests that will be
processed.
The default value is the maximum number that seems to be possible given
the number of open files, select() bit masks, and so forth that are
available.
.\"
.\"
.\"
.\" syncronize changes in dccm, dccproc and dccifd man pages
.\"     it is too bad groff .so doesn't seem to work
.It Fl B Ar dnsbl-option
enables DNS blacklist checks of the SMTP client IP address, SMTP envelope
Mail_From sender domain name, and of host names in URLs in the message body.
Body URL blacklisting has far too many false positives to use on
abuse mailboxes.
It is less effective than greylisting with
.Xr dccm 8
or
.Xr dccifd 8
but can be useful in situations where
greylisting cannot be used.
.Pp
.Ar Dnsbl-option
is either of the form
.Ar set:option
or of the form
.Ar domain Ns Op Ar ,IPaddr Ns Op Ar ,bltype .
.Ar Domain
is a DNS blacklist domain such as example.com
that will be searched.
.Ar IPaddr
is the IP address in the DNS blacklist that indicates that the mail message
is spam.  127.0.0.1 is assumed if
.Ar IPaddr
is absent.
IPv6 addresses can be specified with the usual colon (:) notation.
Names can be used instead of numeric addresses.
The type of DNS blacklist
is specified by
.Ar bltype
as
.Ar name ,
.Ar IPv4 ,
or
.Ar IPv6 .
Given an envelope sender domain name or a domain name in a URL of
spam.domain.org
and a blacklist of type
.Ar name ,
spam.domain.org.example.com will be tried.
Blacklist types of
.Ar IPv4
and
.Ar IPv6
require that the domain name in a URL be resolved into an IPv4 or IPv6
address.
The address is then written as a reversed string of decimal
octets to check the DNS blacklist, as in 2.0.0.127.example.com,
.Pp
More than one blacklist can be specified.
They are searched in order.
All searching is stopped at the first positive result.
Positive results are ignored after being logged unless an
.Ar option Ar DNSBL-on
line appears in the global or per-user
.Pa whiteclnt
file.
.Pp
.Fl B Ar set:debug
sends more messages about all DNS resolutions to the system log.
.Pp
.Fl B Ar set:msg-secs=S
limits
.Nm
to
.Ar S
seconds total for checking all DNS blacklists.
The default is 20.
.Pp
.Fl B Ar set:URL-secs=S
limits
.Nm
to at most
.Ar S
seconds resolving and checking any single URL.
The default is 5.
Some spam contains dozens of URLs and that
some "spamvertised" URLs contain host names that need minutes to
resolve.
Busy mail systems cannot afford to spend minutes checking each incoming
mail message.
In order to use typical single-threaded DNS resolver libraries,
.Xr dccm 8
and
.Xr dccifd 8
use fleets of helper processes.
.Pp
.Fl B Ar set:no-envelope
says that SMTP client IP addresses and sender Mail_From domain names should
not be checked in the following blacklists.
.Fl B Ar set:envelope
restores the default for subsequently named blacklists.
.Pp
.Fl B Ar set:no-body
says that URLs in the message body should not be checked in the
in the following blacklists.
.Fl B Ar set:body
restores the default for later blacklists.
.Pp
.Fl B Ar set:no-MX
says MX servers of sender Mail_From domain names and host names in URLs
should not be checked in the following blacklists.
.Fl B Ar set:MX
restores the default.
.\"
.\"
.\"
.It Fl L Ar ltype,facility.level
specifies how messages should be logged.
.Ar Ltype
must be
.Ar error
or
.Ar info
to indicate which of the two types of messages are being controlled.
.Ar Level
must be a
.Xr syslog 3
level among
.Ar EMERG , ALERT , CRIT , ERR ,
.Ar WARNING , NOTICE , INFO ,
and
.Ar DEBUG .
.Ar Facility
must be among
.Ar AUTH , AUTHPRIV , CRON , DAEMON ,
.Ar FTP , KERN , LPR , MAIL , NEWS ,
.Ar USER , UUCP ,
and
.Ar LOCAL0
through
.Ar LOCAL7 .
The default is equivalent to
.Pp
.Dl Fl L Ar info,MAIL.NOTICE Fl L Ar error,MAIL.ERR
.El
.Pp
.Nm
normally sends counts of mail rejected and so forth the system log at
midnight.
The SIGUSR1 signal sends an immediate report to the system log.
The reports will be repeated every 24 hours at the same minute as the signal
instead of at midnight.
.Ss Protocol
.Nm Dccifd
uses a simple ASCII protocol to receive mail messages to be checked and
to return results.
For each message, the MTA must open a connection to the interface daemon,
send options, envelope recipients, and the message, receive the results,
and close the connection.
.Pp
Instead of the ASCII protocol, a subset of ESMTP is enabled by
.Fl o .
Only the familiar HELO, EHLO, Mail, Rcpt, DATA, RSET, and QUIT
commands and the Postfix extensions XFORWARD and XCLIENT are honored.
Since SMTP has no provisions for user names,
the protocol enabled by
.Fl o
depends on a list of local domain names specified with
.Fl D
to find per-user log directories and whitelist files.
If neither XFORWARD nor XCLIENT are used,
.Nm
uses the IP address of the MTA and the value of the HELO command.
.Pp
In the ASCII protocol, each of the following lines are sent in order to
.Nm .
Each ends with a newline ('\\n') character.
.Bl -tag -offset 2n -width "recipients" -compact
.It options
zero or more blank-separated strings among:
.Bl -tag -offset 2n -width grey-query -compact
.It Ar spam
the message is already known to be spam
.It Ar body
return all of the headers with the added
.Em X-DCC
header line and the body
.It Ar header
return the
.Em X-DCC
header
.It Ar query
ask the DCC server about the message without reporting it as if
.Nm
were running with
.Fl Q .
.It Ar grey-query
only query the greylist server for this message.
.Fl G Ar on
must be in use.
.It Ar no-reject
suppress the overall, one character line 'R' result.
This can be useful when using
.Nm
only for greylisting.
.El
.It client
IP address of the SMTP client in a "dotted" or "coloned" ASCII string
and reverse-DNS host name.
If the host name is present,
it must follow a carriage return character ('\\r') after the IP address.
The client IP address must be present and non-null if the host name is present.
If the client IP address is absent, then the IP address and host name
are taken from the first Received header if it has the standard
"name (name [IP address])..." format.
.It HELO
SMTP HELO value or nothing, followed by a newline character.
.It sender
or SMTP
.Em Mail From
command value
.It recipients
or SMTP
.Em Rcpt To
values followed by corresponding local user names, one pair to a line.
Each optional local user name is separated from the
corresponding recipient address by a carriage return ('\\r').
A local user name can be null if it is not known.
Recipients that lack local user names will lack per-user log files
and will not invoke a per-user whitelist.
.El
.Pp
The last recipient-user name pair is followed by an empty line
and the headers and body of the message.
The end of the body of the mail message is signaled by the MTA
half-closing the connection.
See
.Xr shutdown 2 .
.Pp
.Nm Dccifd
responds with three things.
First is a one character line of the overall result advising the MTA to
.Bl -tag -offset 2n -width 3n -compact
.It A
accept the message for all recipients and answer the SMTP DATA command
with a 2yz result.
.It G
answer with a 4yz result to embargo the message for greylisting.
.It R
reject the message and answer the DATA command with a 5yz result.
.It S
accept the message for some recipients
and so answer the DATA command with a 2yz result.
.It T
temporary failure by the DCC system and so answer with a 4yz result.
.El
.Pp
Second is a line of 'A', 'G', and 'R' characters indicating that
the message should be
accepted and delivered or discarded for each corresponding recipient.
Limitations in the SMTP protocol allows only a single
result for the DATA command for all recipients that were not rejected
before body of the message was offered with the DATA command.
To accept the message for some recipients and reject it for others,
the MTA must tell the SMTP client it is accepting the message for all
recipients and then discard it for those that would reject it.
.Pp
Finally, if the
.Em body
or
.Em header
strings are in the first line of
.Em options
sent by the MTA to the daemon,
then the
.Em X-DCC
header line
or the entire body with the
.Em X-DCC
header line follows.
.Sh FILES
.Bl -tag -width dccifd.pid -compact
.It Pa /var/dcc
is the DCC home directory in which other files are found.
.It Pa libexec/start-dccifd
is a script often used to the daemon.
.It Pa dcc/dcc_conf
contains parameters used by the scripts to start DCC daemons and cron jobs.
.It Pa logdir
is an optional directory specified with
.Fl l
and containing marked mail.
Each file in the directory contains one message, at least one of whose
checksums reached its
.Fl t
thresholds or that is interesting for some other reason.
Each file starts with lines containing the date when the message
was received, the IP address of the SMTP client, and SMTP envelope
values.
Those lines are followed by the body of the SMTP message including its header
as it was received.
Only approximately the first 32 KBytes of the body are recorded
unless modified by
.Em ./configure --with-max-log-size=xx
The checksums for the message follow the body.
They are followed by lines indicate that
one of the checksums is white- or blacklisted by the
.Fl w Ar whiteclnt
file.
Each file ends with the
.Em X-DCC
header line added to the message and the disposition of
the message.
.It Pa map
is the memory mapped file of information concerning DCC servers
in the DCC home directory.
.It Pa whiteclnt
contains the client whitelist in
the format described in
.Xr dcc 8 .
.It Pa whiteclnt.dccw
is a memory mapped hash table of the
.Pa whiteclnt
file.
.It Pa dccifd.pid
in the
.Fl R Ar rundir
directory contains daemon's process ID.
.El
.Sh SEE ALSO
.Xr cdcc 8 ,
.Xr dbclean 8 ,
.Xr dcc 8 ,
.Xr dccd 8 ,
.Xr dblist 8 ,
.Xr dccm 8 ,
.Xr dccproc 8 ,
.Xr dccsight 8 ,
.Sh HISTORY
Implementation of
.Nm
was started at Rhyolite Software in 2002.
This describes version 1.2.74.
.Sh BUGS
.Nm
uses
.Fl t
where
.Xr dccproc 8
uses
.Fl c .
.Pp
Systems without
.Xr setrlimit 2
and
.Xr getrlimit 2
can have problems with the default limit on the number of simultaneous
jobs, the value of
.Fl j .
Every job requires four open files.
These problems are usually seen with errors messages that say something like
.Dl dccifd[24448]: DCC: accept() returned invalid socket
A fix is to use a smaller value for
.Fl j
or to allow
.Nm
to open more files.
.\"  LocalWords:  DCC whiteclnt whitelist setrlimit getrlimit dccproc MTA MTAs
.\"  LocalWords:  greylist greylisted