1SPAMD(1) User Contributed Perl Documentation SPAMD(1)
2
3
4
6 spamd - daemonized version of spamassassin
7
9 spamd [options]
10
11 Options:
12
13 -l, --allow-tell Allow learning/reporting
14 -c, --create-prefs Create user preferences files
15 -C path, --configpath=path Path for default config files
16 --siteconfigpath=path Path for site configs
17 --cf='config line' Additional line of configuration
18 --pre='config line' Additional line of ".pre" (prepended to configuration)
19 -d, --daemonize Daemonize
20 -h, --help Print usage message
21 -i [ip_or_name[:port]], --listen=[ip_or_name[:port]] Listen on IP addr and port
22 -p port, --port=port Listen on specified port, may be overridden by -i
23 -4, --ipv4-only, --ipv4 Use IPv4 where applicable, disables IPv6
24 -6 Use IPv6 where applicable, disables IPv4
25 -A host,..., --allowed-ips=..,.. Restrict to IP addresses which can connect
26 -m num, --max-children=num Allow maximum num children
27 --min-children=num Allow minimum num children
28 --min-spare=num Lower limit for number of spare children
29 --max-spare=num Upper limit for number of spare children
30 --max-conn-per-child=num Maximum connections accepted by child
31 before it is respawned
32 --round-robin Use traditional prefork algorithm
33 --timeout-tcp=secs Connection timeout for client headers
34 --timeout-child=secs Connection timeout for message checks
35 -q, --sql-config Enable SQL config (needs -x)
36 -Q, --setuid-with-sql Enable SQL config (needs -x,
37 enables use of -H)
38 --ldap-config Enable LDAP config (needs -x)
39 --setuid-with-ldap Enable LDAP config (needs -x,
40 enables use of -H)
41 --virtual-config-dir=dir Enable pattern based Virtual configs
42 (needs -x)
43 -r pidfile, --pidfile Write the process id to pidfile
44 -s facility, --syslog=facility Specify the syslog facility
45 --syslog-socket=type How to connect to syslogd
46 --log-timestamp-fmt=fmt strftime(3) format for timestamps, may be
47 empty to disable timestamps, or 'default'
48 -u username, --username=username Run as username
49 -g groupname, --groupname=groupname Run as groupname
50 -v, --vpopmail Enable vpopmail config
51 -x, --nouser-config Disable user config files
52 -U username, --default-user=username Fall back to this username if spamc user
53 is not found (default: nobody)
54 -D, --debug[=areas] Print debugging messages (for areas)
55 -L, --local Use local tests only (no DNS)
56 -P, --paranoid Die upon user errors
57 -H [dir], --helper-home-dir[=dir] Specify a different HOME directory
58 --ssl Enable SSL on TCP connections
59 --ssl-verify Request a client certificate and verify it
60 --ssl-ca-file cafile Certificate Authority certificate file
61 --ssl-ca-path capath Certificate Authority directory
62 --ssl-port port Override --port setting for SSL connections
63 --server-key keyfile Specify an SSL keyfile
64 --server-cert certfile Specify an SSL certificate
65 --socketpath=path Listen on a given UNIX domain socket
66 --socketowner=name Set UNIX domain socket file's owner
67 --socketgroup=name Set UNIX domain socket file's group
68 --socketmode=mode Set UNIX domain socket file's mode
69 --timing Enable timing and logging
70 -V, --version Print version and exit
71
72 The --listen option (or -i) may be specified multiple times, its syntax
73 is: [ ssl: ] [ host-name-or-IP-address ] [ : port ] or an absolute
74 path (filename) of a Unix socket. If port is omitted it defaults to
75 --port or to 783. Option --ssl implies a prefix 'ssl:'. An IPv6
76 address should be enclosed in square brackets, e.g. [::1]:783, an IPv4
77 address may be but need not be enclosed in square brackets. An
78 asterisk '*' in place of a hostname implies an unspecified address,
79 ('0.0.0.0' or '::'), i.e. it binds to all interfaces. An empty option
80 value implies '*'. A default is '--listen localhost', which binds to a
81 loopback interface only.
82
84 The purpose of this program is to provide a daemonized version of the
85 spamassassin executable. The goal is improving throughput performance
86 for automated mail checking.
87
88 This is intended to be used alongside "spamc", a fast, low-overhead C
89 client program.
90
91 See the README file in the "spamd" directory of the SpamAssassin
92 distribution for more details.
93
94 Note: Although "spamd" will check per-user config files for every
95 message, any changes to the system-wide config files will require
96 either restarting spamd or forcing it to reload itself via SIGHUP for
97 the changes to take effect.
98
99 Note: If "spamd" receives a SIGHUP, it internally reloads itself, which
100 means that it will change its pid and might not restart at all if its
101 environment changed (ie. if it can't change back into its own
102 directory). If you plan to use SIGHUP, you should always start "spamd"
103 with the -r switch to know its current pid.
104
106 Options of the long form can be shortened as long as they remain
107 unambiguous. (i.e. --dae can be used instead of --daemonize) Also,
108 boolean options (like --user-config) can be negated by adding no
109 (--nouser-config), however, this is usually unnecessary.
110
111 -l, --allow-tell
112 Allow learning and forgetting (to a local Bayes database),
113 reporting and revoking (to a remote database) by spamd. The client
114 issues a TELL command to tell what type of message is being
115 processed and whether local (learn/forget) or remote
116 (report/revoke) databases should be updated.
117
118 Note that spamd always trusts the username passed in so clients
119 could maliciously learn messages for other users. (This is not
120 usually a concern with an SQL Bayes store as users will typically
121 have read-write access directly to the database, and can also use
122 "sa-learn" with the -u option to achieve the same result.)
123
124 -c, --create-prefs
125 Create user preferences files if they don't exist (default: don't).
126
127 -C path, --configpath=path
128 Use the specified path for locating the distributed configuration
129 files. Ignore the default directories (usually
130 "/usr/share/spamassassin" or similar).
131
132 --siteconfigpath=path
133 Use the specified path for locating site-specific configuration
134 files. Ignore the default directories (usually
135 "/etc/mail/spamassassin" or similar).
136
137 --cf='config line'
138 Add additional lines of configuration directly from the command-
139 line, parsed after the configuration files are read. Multiple
140 --cf arguments can be used, and each will be considered a separate
141 line of configuration.
142
143 --pre='config line'
144 Add additional lines of .pre configuration directly from the
145 command-line, parsed before the configuration files are read.
146 Multiple --pre arguments can be used, and each will be considered a
147 separate line of configuration.
148
149 -d, --daemonize
150 Detach from starting process and run in background (daemonize).
151
152 -h, --help
153 Print a brief help message, then exit without further action.
154
155 -V, --version
156 Print version information, then exit without further action.
157
158 -i [ipaddress[:<port>]], --listen[=ipaddress[:<port>]]
159 Additional alias names for this option are --listen-ip and
160 --ip-address. Tells spamd to listen on the specified IP address,
161 defaults to a loopback interface, i.e. "--listen localhost"). If
162 no value is specified after the switch, or if an asterisk '*'
163 stands in place of an <ipaddress>, spamd will listen on all
164 interfaces - this is equivalent to address '0.0.0.0' for IPv4 and
165 to '::' for IPv6. You can also use a valid hostname which will make
166 spamd listen on all addresses that a name resolves to. The option
167 may be specified multiple times. See also options -4 and -6 for
168 restricting address family to IPv4 or to IPv6. If a port is
169 specified it overrides for this socket the global --port (and
170 --ssl-port) setting. An IPv6 addresses should be enclosed in square
171 brackets, e.g. [::1]:783. For compatibility square brackets on an
172 IPv6 address may be omitted if a port number specification is also
173 omitted.
174
175 -p port, --port=port
176 Optionally specifies the port number for the server to listen on
177 (default: 783).
178
179 If the --ssl switch is used, and --ssl-port is not supplied, then
180 this port will be used to accept SSL connections instead of
181 unencrypted connections. If the --ssl switch is used, and
182 --ssl-port is set, then unencrypted connections will be accepted on
183 the --port at the same time as encrypted connections are accepted
184 at --ssl-port.
185
186 -q, --sql-config
187 Turn on SQL lookups even when per-user config files have been
188 disabled with -x. this is useful for spamd hosts which don't have
189 user's home directories but do want to load user preferences from
190 an SQL database.
191
192 If your spamc client does not support sending the "User:" header,
193 like "exiscan", then the SQL username used will always be nobody.
194
195 This inhibits the setuid() behavior, so the "-u" option is
196 required. If you want the setuid() behaviour, use "-Q" or
197 "--setuid-with-sql" instead.
198
199 --ldap-config
200 Turn on LDAP lookups. This is completely analog to "--sql-config",
201 only it is using an LDAP server.
202
203 Like "--sql-config", this disables the setuid behavior, and
204 requires "-u". If you want it, use "--setuid-with-ldap" instead.
205
206 -Q, --setuid-with-sql
207 Turn on SQL lookups even when per-user config files have been
208 disabled with -x and also setuid to the user. This is useful for
209 spamd hosts which want to load user preferences from an SQL
210 database but also wish to support the use of -H (Helper home
211 directories.)
212
213 --setuid-with-ldap
214 Turn on LDAP lookups even when per-user config files have been
215 disabled with -x and also setuid to the user. This is again
216 completely analog to "--setuid-with-sql", only it is using an LDAP
217 server.
218
219 --virtual-config-dir=pattern
220 This option specifies where per-user preferences can be found for
221 virtual users, for the -x switch. The pattern is used as a base
222 pattern for the directory name. Any of the following escapes can
223 be used:
224
225 %u -- replaced with the full name of the current user, as sent by
226 spamc.
227 %l -- replaced with the 'local part' of the current username. In
228 other words, if the username is an email address, this is the part
229 before the "@" sign.
230 %d -- replaced with the 'domain' of the current username. In other
231 words, if the username is an email address, this is the part after
232 the "@" sign.
233 %x -- replaced with the full name of the current user, as sent by
234 spamc. If the resulting config directory does not exist, replace
235 with the domain part to use a domain-wide default.
236 %% -- replaced with a single percent sign (%).
237
238 So for example, if "/vhome/users/%u/spamassassin" is specified, and
239 spamc sends a virtual username of "jm@example.com", the directory
240 "/vhome/users/jm@example.com/spamassassin" will be used.
241
242 The set of characters allowed in the virtual username for this path
243 are restricted to:
244
245 A-Z a-z 0-9 - + _ . , @ =
246
247 All others will be replaced by underscores ("_").
248
249 This path must be a writable directory. It will be created if it
250 does not already exist. If a file called user_prefs exists in this
251 directory (note: not in a ".spamassassin" subdirectory!), it will
252 be loaded as the user's preferences. The Bayes databases for that
253 user will be stored in this directory.
254
255 Note that this requires that -x is used, and cannot be combined
256 with SQL- or LDAP-based configuration.
257
258 The pattern must expand to an absolute directory when spamd is
259 running daemonized (-d).
260
261 Currently, use of this without -u is not supported. This inhibits
262 setuid.
263
264 -r pidfile, --pidfile=pidfile
265 Write the process ID of the spamd parent to the file specified by
266 pidfile. The file will be unlinked when the parent exits. Note
267 that when running with the -u option, the file must be writable by
268 that user.
269
270 -v, --vpopmail
271 Enable vpopmail config. If specified with -u set to the vpopmail
272 user, this allows spamd to lookup/create user_prefs in the vpopmail
273 user's own maildir. This option is useful for vpopmail virtual
274 users who do not have an entry in the system /etc/passwd file.
275
276 Currently, use of this without -u is not supported. This inhibits
277 setuid.
278
279 -s facility, --syslog=facility
280 Specify the syslog facility to use (default: mail). If "stderr" is
281 specified, output will be written to stderr. (This is useful if
282 you're running "spamd" under the "daemontools" package.) With a
283 facility of "file", all output goes to spamd.log. facility is
284 interpreted as a file name to log to if it contains any characters
285 except a-z and 0-9. "null" disables logging completely (used
286 internally).
287
288 Examples:
289
290 spamd -s mail # use syslog, facility mail (default)
291 spamd -s ./mail # log to file ./mail
292 spamd -s stderr 2>/dev/null # log to stderr, throw messages away
293 spamd -s null # the same as above
294 spamd -s file # log to file ./spamd.log
295 spamd -s /var/log/spamd.log # log to file /var/log/spamd.log
296
297 If logging to a file is enabled and that log file is rotated, the
298 spamd server must be restarted with a SIGHUP. (If the log file is
299 just truncated, this is not needed but still recommended.)
300
301 Note that logging to a file does not use locking, so you cannot
302 intermix logging from spamd and other processes into the same file.
303 If you want to mix logging like this, use syslog instead.
304
305 If you use syslog logging, it is essential to send a SIGHUP to the
306 spamd daemon when you restart the syslogd daemon. (This is due to
307 a shortcoming in Perl's syslog handling, where the disappearance of
308 the connection to the syslogd is considered a fatal error.)
309
310 --syslog-socket=type
311 Specify how spamd should send messages to syslogd. The type can be
312 any of the socket types or logging mechanisms as accepted by the
313 subroutine Sys::Syslog::setlogsock(). Depending on a version of
314 Sys::Syslog and on the underlying operating system, one of the
315 following values (or their subset) can be used: "native",
316 "eventlog", "tcp", "udp", "inet", "unix", "stream", "pipe", or
317 "console". The value "eventlog" is specific to Win32 events logger
318 and requires a perl module Win32::EventLog to be installed. For
319 more information please consult the Sys::Syslog documentation.
320
321 A historical setting --syslog-socket=none is mapped to
322 --syslog=stderr.
323
324 A default for Windows platforms is "none", otherwise the default is
325 to try "unix" first, falling back to "inet" if perl detects errors
326 in its "unix" support.
327
328 Some platforms, or versions of perl, are shipped with old or
329 dysfunctional versions of the Sys::Syslog module which do not
330 support some socket types, so you may need to set this option
331 explicitly. If you get error messages regarding __PATH_LOG or
332 similar spamd, try changing this setting.
333
334 The socket types "file" is used internally and should not be
335 specified. Use the "-s" switch instead.
336
337 --log-timestamp-fmt=format
338 The --log-timestamp-fmt option can provide a POSIX strftime(3)
339 format for timestamps included in each logged message. Each logger
340 (stderr, file, syslog) has its own default value for a timestamp
341 format, which applies when --log-timestamp-fmt option is not given,
342 or with --log-timestamp-fmt=default . Timestamps can be turned off
343 by specifying an empty string with this option, e.g.
344 --log-timestamp-fmt='' or just --log-timestamp-fmt= . Typical use:
345 --log-timestamp-fmt='%a %b %e %H:%M:%S %Y' (provides localized
346 weekday and month names in the ctime(3) style), or '%a, %e %b %Y
347 %H:%M:%S %z (%Z)' for a RFC 2822 format, or maybe '%Y-%m-%d
348 %H:%M:%S%z' for an ISO 8601 (EN 28601) format, or just
349 '%Y%m%dT%H%M%S' .
350
351 -u username, --username=username
352 Run as the named user. If this option is not set, the default
353 behaviour is to setuid() to the user running "spamc", if "spamd" is
354 running as root.
355
356 Note: "--username=root" is not a valid option. If specified,
357 "spamd" will exit with a fatal error on startup.
358
359 -g groupname, --groupname=groupname
360 Run as the named group if --username is being used. If this option
361 is not set when --username is used then the primary group for the
362 user given to --username is used.
363
364 -x, --nouser-config, --user-config
365 Turn off (on) reading of per-user configuration files (user_prefs)
366 from the user's home directory. The default behaviour is to read
367 per-user configuration from the user's home directory
368 (--user-config).
369
370 This option does not disable or otherwise influence the SQL, LDAP
371 or Virtual Config Dir settings.
372
373 -U username, --default-user=username
374 Fall back to this username, if the username provided by spamc is
375 not found. Default is nobody, which might not exist or not have a
376 usable home directory, use this setting to define a suitable user
377 if needed.
378
379 -A host,..., --allowed-ips=host,...
380 Specify a comma-separated list of authorized hosts or networks
381 which can connect to this spamd instance. Each element of the list
382 is either a single IP addresses, or a range of IP addresses in
383 address/masklength CIDR notation, or ranges of IPv4 addresses by
384 specifying 3 or less octets with a trailing dot. Hostnames are not
385 supported, only IPv4 or IPv6 addresses. This option can be
386 specified multiple times, or can take a list of addresses separated
387 by commas. IPv6 addresses may be (but need not be) enclosed in
388 square brackets for consistency with option --listen. Examples:
389
390 -A 10.11.12.13 -- only allow connections from 10.11.12.13.
391
392 -A 10.11.12.13,10.11.12.14 -- only allow connections from
393 10.11.12.13 and 10.11.12.14.
394
395 -A 10.200.300.0/24 -- allow connections from any machine in the
396 range "10.200.300.*".
397
398 -A 10. -- allow connections from any machine in the range
399 "10.*.*.*".
400
401 -A [2001:db8::]/32,192.0.2.0/24,::1,127.0.0.0/8 -- only accept
402 connections from specified test networks and from localhost.
403
404 In absence of the -A option, connections are only accepted from IP
405 address 127.0.0.1 or ::1, i.e. from localhost on a loopback
406 interface.
407
408 -D [area,...], --debug [area,...]
409 Produce debugging output. If no areas are listed, all debugging
410 information is printed. Diagnostic output can also be enabled for
411 each area individually; area is the area of the code to instrument.
412 For example, to produce diagnostic output on bayes, learn, and dns,
413 use:
414
415 spamassassin -D bayes,learn,dns
416
417 Higher priority informational messages that are suitable for
418 logging in normal circumstances are available with an area of
419 "info".
420
421 For more information about which areas (also known as channels) are
422 available, please see the documentation at:
423
424 C<https://wiki.apache.org/spamassassin/DebugChannels>
425
426 -4, --ipv4only, --ipv4-only, --ipv4
427 Use IPv4 where applicable, do not use IPv6. The option affects a
428 set of listen sockets (see option "--listen") and disables IPv6 for
429 DNS tests.
430
431 -6 Use IPv6 where applicable, do not use IPv4. The option affects a
432 set of listen sockets (see option "--listen") and disables IPv4 for
433 DNS tests. Installing a module IO::Socket::IP is recommended if
434 spamd is expected to receive requests over IPv6.
435
436 -L, --local
437 Perform only local tests on all mail. In other words, skip DNS and
438 other network tests. Works the same as the "-L" flag to
439 spamassassin(1).
440
441 -P, --paranoid
442 Die on user errors (for the user passed from spamc) instead of
443 falling back to user "--default-user" and using the default
444 configuration.
445
446 -m number , --max-children=number
447 This option specifies the maximum number of children to spawn.
448 Spamd will spawn that number of children, then sleep in the
449 background until a child dies, wherein it will go and spawn a new
450 child.
451
452 Incoming connections can still occur if all of the children are
453 busy, however those connections will be queued waiting for a free
454 child. The minimum value is 1, the default value is 5.
455
456 Please note that there is a OS specific maximum of connections that
457 can be queued (Try "perl -MSocket -e'print SOMAXCONN'" to find this
458 maximum).
459
460 Note that if you run too many servers for the amount of free RAM
461 available, you run the danger of hurting performance by causing a
462 high swap load as server processes are swapped in and out
463 continually.
464
465 --min-children=number
466 The minimum number of children that will be kept running. The
467 minimum value is 1, the default value is 1. If you have lots of
468 free RAM, you may want to increase this.
469
470 --min-spare=number
471 The lower limit for the number of spare children allowed to run. A
472 spare, or idle, child is one that is not handling a scan request.
473 If there are too few spare children available, a new server will be
474 started every second or so. The default value is 1.
475
476 --max-spare=number
477 The upper limit for the number of spare children allowed to run.
478 If there are too many spare children, one will be killed every
479 second or so until the number of idle children is in the desired
480 range. The default value is 2.
481
482 --max-conn-per-child=number
483 This option specifies the maximum number of connections each child
484 should process before dying and letting the master spamd process
485 spawn a new child. The minimum value is 1, the default value is
486 200.
487
488 --round-robin
489 By default, "spamd" will attempt to keep a small number of "hot"
490 child processes as busy as possible, and keep any others as idle as
491 possible, using something similar to the Apache httpd server
492 scaling algorithm. This is accomplished by the master process
493 coordinating the activities of the children. This switch will
494 disable this scaling algorithm, and the behaviour seen in the 3.0.x
495 versions will be used instead, where all processes receive an equal
496 load and no scaling takes place.
497
498 --timeout-tcp=number
499 This option specifies the number of seconds to wait for headers
500 from a client (spamc) before closing the connection. The minimum
501 value is 1, the default value is 30, and a value of 0 will disable
502 socket timeouts completely.
503
504 --timeout-child=number
505 This option specifies the number of seconds to wait for a spamd
506 child to process or check a message. The minimum value is 1, the
507 default value is 300, and a value of 0 will disable child timeouts
508 completely.
509
510 -H directory, --helper-home-dir=directory
511 Specify that external programs such as Razor, DCC, and Pyzor should
512 have a HOME environment variable set to a specific directory. The
513 default is to use the HOME environment variable setting from the
514 shell running spamd. By specifying no argument, spamd will use the
515 spamc caller's home directory instead.
516
517 --ssl
518 Accept only SSL connections on the associated port. The
519 IO::Socket::SSL perl module must be installed.
520
521 If the --ssl switch is used, and --ssl-port is not supplied, then
522 --port port will be used to accept SSL connections instead of
523 unencrypted connections. If the --ssl switch is used, and
524 --ssl-port is set, then unencrypted connections will be accepted on
525 the --port, at the same time as encrypted connections are accepted
526 at --ssl-port.
527
528 --ssl-verify
529 Implies --ssl. Request a client certificate and verify the
530 certificate. Requires --ssl-ca-file or --ssl-ca-path.
531
532 --ssl-ca-file=cafile
533 Implies --ssl-verify. Use the specified Certificate Authority
534 certificate to verify the client certificate. The client
535 certificate must be signed by this certificate.
536
537 --ssl-ca-path=capath
538 Implies --ssl-verify. Use the Certificate Authority certificate
539 files in the specified set of directories to verify the client
540 certificate. The client certificate must be signed by one of these
541 Certificate Authorities. See the man page for IO::Socket::SSL for
542 additional details.
543
544 --ssl-port=port
545 Optionally specifies the port number for the server to listen on
546 for SSL connections (default: whatever --port uses). See --ssl for
547 more details.
548
549 --server-key keyfile
550 Specify the SSL key file to use for SSL connections.
551
552 --server-cert certfile
553 Specify the SSL certificate file to use for SSL connections.
554
555 --socketpath pathname
556 Listen on a UNIX domain socket at path pathname, in addition to
557 sockets specified with a "--listen" option. This option is provided
558 for compatibility with older versions of spamd. Starting with
559 version 3.4.0 the "--listen" option can also take a UNIX domain
560 socket as its value (an absolute path name). Unlike "--socketpath",
561 the "--listen" option may be specified multiple times if spamd
562 needs to listen on multiple UNIX or INET or INET6 sockets.
563
564 Warning: the Perl support on BSD platforms for UNIX domain sockets
565 seems to have a bug regarding paths of over 100 bytes or so
566 (SpamAssassin bug 4380). If you see a 'could not find newly-
567 created UNIX socket' error message, and the path appears truncated,
568 this may be the cause. Try using a shorter path to the socket.
569
570 By default, use of --socketpath without --listen will inhibit SSL
571 connections and unencrypted TCP connections. To add other sockets,
572 specify them with --listen, e.g. '--listen=:' or '--listen=*:'
573
574 --socketowner name
575 Set UNIX domain socket to be owned by the user named name. Note
576 that this requires that spamd be started as "root", and if "-u" is
577 used, that user should have write permissions to unlink the file
578 later, for when the "spamd" server is killed.
579
580 --socketgroup name
581 Set UNIX domain socket to be owned by the group named name. See
582 "--socketowner" for notes on ownership and permissions.
583
584 --socketmode mode
585 Set UNIX domain socket to use the octal mode mode. Note that if
586 "-u" is used, that user should have write permissions to unlink the
587 file later, for when the "spamd" server is killed.
588
589 --timing
590 Enable timing measurements and output the information for logging. This
591 is the same information as provided by the TIMING tag.
592
594 spamc(1) spamassassin(1) Mail::SpamAssassin::Conf(3)
595 Mail::SpamAssassin(3)
596
598 "Mail::SpamAssassin"
599
601 The SpamAssassin(tm) Project (https://spamassassin.apache.org/)
602
604 SpamAssassin is distributed under the Apache License, Version 2.0, as
605 described in the file "LICENSE" included with the distribution.
606
607
608
609perl v5.36.0 2023-01-21 SPAMD(1)