xref: /netbsd-src/usr.sbin/syslogd/syslog.conf.5 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\"	$NetBSD: syslog.conf.5,v 1.18 2010/01/01 21:44:07 wiz Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
31.\"
32.Dd January 1, 2010
33.Dt SYSLOG.CONF 5
34.Os
35.Sh NAME
36.Nm syslog.conf
37.Nd
38.Xr syslogd 8
39configuration file
40.Sh DESCRIPTION
41The
42.Nm
43file is the configuration file for the
44.Xr syslogd 8
45program.
46It consists of extended options (lines with one key="value" assignment)
47and blocks of lines separated by
48.Em program
49and
50.Em hostname
51specifications, with each line containing two fields: the
52.Em selector
53field which specifies the types of messages and priorities to which the
54line applies, and an
55.Em action
56field which specifies the action to be taken if a message
57.Xr syslogd 8
58receives matches the selection criteria.
59The
60.Em selector
61field is separated from the
62.Em action
63field by one or more tab characters.
64.Pp
65The
66.Em Selectors
67function
68are encoded as a
69.Em facility ,
70a period
71.Pq Sq \&. ,
72an optional set of comparison flags
73.Pq Bo ! Bc Bq \*[Lt]=\*[Gt] ,
74and a
75.Em level ,
76with no intervening white-space.
77Both the
78.Em facility
79and the
80.Em level
81are case insensitive.
82.Pp
83The
84.Em facility
85describes the part of the system generating the message, and is one of
86the following keywords: auth, authpriv, cron, ftp, daemon, kern, lpr,
87mail, mark, news, syslog, user, uucp and local0 through local7.
88These keywords (with the exception of mark) correspond to the
89similar
90.Dq Dv LOG_
91values specified to the
92.Xr openlog 3
93and
94.Xr syslog 3
95library routines.
96.Pp
97The
98.Em comparison flags
99may be used to specify exactly what levels are logged.
100If unspecified, the default comparison is
101.Sq \*[Gt]=
102.Pq greater than or equal to ,
103or, if the
104.Fl U
105option is passed to
106.Xr syslogd 8 ,
107.Sq =
108.Pq equal to .
109Comparison flags beginning with
110.So ! Sc
111will have their logical sense inverted.
112Thus,
113.Sq !=info
114means all levels except info and
115.Sq !notice
116has the same meaning as
117.Sq \*[Lt]notice .
118.Pp
119The
120.Em level
121describes the severity of the message, and is a keyword from the
122following ordered list (higher to lower): emerg, alert, crit, err,
123warning, notice, info and debug.
124These keywords correspond to the
125similar
126.Pq Dv LOG_
127values specified to the
128.Xr syslog 3
129library routine.
130.Pp
131Each block of lines is separated from the previous block by a
132.Em program
133or
134.Em hostname
135specification.
136A block will only log messages corresponding to the most recent
137.Em program
138and
139.Em hostname
140specifications given.
141Consider the case of a block that selects
142.Ql pppd
143as the
144.Em program ,
145directly followed by a block that selects messages from the
146.Em hostname
147.Ql dialhost .
148The second block will log only messages from the
149.Xr pppd 8
150program from the host
151.Sq dialhost .
152.Pp
153A
154.Em program
155specification of the form
156.Ql #!+prog1,prog2
157or
158.Ql !+prog1,prog2
159will cause subsequent blocks to be applied to messages logged by the
160specified programs.
161A
162.Em program
163specification of the form
164.Ql #!-prog1,prog2
165or
166.Ql !-prog1,prog2
167will cause subsequent blocks to be applied to messages logged by programs
168other than the ones specified.
169A
170.Em program
171specification of the form
172.Ql #!prog1,prog2
173or
174.Ql !prog1,prog2
175is equivalent to
176.Ql !+prog1,prog2 .
177Program selectors may also match kernel-generated messages.
178For example, a program specification of
179.Ql !+subsys
180will match kernel-generated messages of the form
181.Ql subsys: here is a message .
182The special specification
183.Ql !*
184will cause subsequent blocks to apply to all programs.
185.Pp
186A
187.Em hostname
188specification of the form
189.Ql #+host1,host2
190or
191.Ql +host1,host2
192will cause subsequent blocks to be applied to messages received from
193the specified hosts.
194A
195.Em hostname
196specification of the form
197.Ql #-host1,host2
198or
199.Ql -host1,host2
200will cause subsequent blocks to be applied to messages from hosts other
201than the ones specified.
202If the hostname is given as
203.Ql @ ,
204the local hostname will be used.
205The special specification
206.Ql +*
207will cause subsequent blocks to apply to all hosts.
208.Pp
209See
210.Xr syslog 3
211for a further descriptions of both the
212.Em facility
213and
214.Em level
215keywords and their significance.
216It is preferred that selections be made based on
217.Em facility
218rather than
219.Em program ,
220since the latter can vary in a networked environment.
221However, there are cases where a
222.Em facility
223may be too broadly defined.
224.Pp
225If a received message matches the specified
226.Em facility ,
227and the specified
228.Em level
229comparison is true,
230and the first word in the message after the date matches the
231.Em program ,
232the action specified in the
233.Em action
234field will be taken.
235.Pp
236Multiple
237.Em selectors
238may be specified for a single
239.Em action
240by separating them with semicolon
241.Pq Sq \&;
242characters.
243It is important to note, however, that each
244.Em selector
245can modify the ones preceding it.
246.Pp
247Multiple
248.Em facilities
249may be specified for a single
250.Em level
251by separating them with comma
252.Pq Sq \&,
253characters.
254.Pp
255An asterisk
256.Pq Sq \&*
257can be used to specify all
258.Em facilities
259or all
260.Em levels .
261.Pp
262The special
263.Em facility
264.Dq mark
265receives a message at priority
266.Dq info
267every 20 minutes
268(see
269.Xr syslogd 8 ) .
270This is not enabled by a
271.Em facility
272field containing an asterisk.
273.Pp
274The special
275.Em level
276.Dq none
277disables a particular
278.Em facility .
279.Pp
280The
281.Em action
282field of each line specifies the action to be taken when the
283.Em selector
284field selects a message.
285There are five forms:
286.Bl -bullet
287.It
288A pathname (beginning with a leading slash).
289Selected messages are appended to the file.
290.Pp
291To ensure that kernel messages are written to disk promptly,
292.Xr syslogd 8
293calls
294.Xr fsync 2
295after writing messages from the kernel.
296Other messages are not synced explcitly.
297You may disable syncing of files specified to receive kernel messages
298by prefixing the pathname with a minus sign
299.Ql - .
300Note that use of this option may cause the loss of log information in
301the event of a system crash immediately following the write attempt.
302However, using this option may prove to be useful if your system's
303kernel is logging many messages.
304.Pp
305Normally the priority and version is not written to file.
306In order to use syslog-sign you may prefix a pathname with the plus sign
307.Ql + .
308If both switches are used the order has to be
309.Ql +- .
310.It
311A hostname (preceded by an at
312.Pq Sq @
313sign).
314Selected messages are forwarded to the
315.Xr syslogd 8
316program on the named host with UDP.
317.It
318A hostname preceded by an at
319.Pq Sq @
320sign and enclosed in brackets
321.Pq Sq []
322.
323Selected messages are forwarded with TLS to the
324.Xr syslogd 8
325program on the named host.
326After the closing bracket a colon
327.Pq Sq \&:
328and a port or service name may be appended.
329Additional options are configured in parantheses in the form of key="value".
330Recognized keywords are
331.Ar subject ,
332.Ar fingerprint ,
333.Ar cert ,
334and
335.Ar verify .
336.It
337A comma separated list of users.
338Selected messages are written to those users
339if they are logged in.
340.It
341An asterisk.
342Selected messages are written to all logged-in users.
343.It
344A vertical bar
345.Pq Sq |
346followed by a command to which to pipe the selected messages.
347The command string is passed to
348.Pa /bin/sh
349for evaluation, so the usual shell metacharacters or input/output
350redirection can occur.
351(Note that redirecting
352.Xr stdio 3
353buffered output from the invoked command can cause additional delays,
354or even lost output data in case a logging subprocess exits with a
355signal.)
356The command itself runs with
357.Em stdout
358and
359.Em stderr
360redirected to
361.Pa /dev/null .
362Upon receipt of a
363.Dv SIGHUP ,
364.Xr syslogd 8
365will close the pipe to the process.
366If the process does not exit voluntarily, it will be sent a
367.Dv SIGTERM
368signal after a grace period of up to 60 seconds.
369.Pp
370The command will only be started once data arrives that should be
371piped to it.
372If the command exits, it will be restarted as necessary.
373.Pp
374If it is desired that the subprocess should receive exactly one line of
375input, this can be achieved by exiting after reading and processing the
376single line.
377A wrapper script can be used to achieve this effect, if necessary.
378Note that this method can be very resource-intensive if many log messages
379are being piped through the filter.
380.Pp
381Unless the command is a full pipeline, it may be useful to
382start the command with
383.Em exec
384so that the invoking shell process does not wait for the command to
385complete.
386Note that the command is started with the UID of the
387.Xr syslogd 8
388process, normally the superuser.
389.Pp
390Just like with files a plus sign
391.Ql +
392will leave the priority and version information intact.
393.El
394.Pp
395Blank lines and lines whose first non-blank character is a hash
396.Pq Sq #
397character are ignored.
398.Sh "TLS OPTIONS"
399Additional options are used for TLS configuration:
400.Bl -ohang
401.It Em tls_server
402Enables TLS server mode.
403.It Em tls_bindport
404Service name or port number to bind to.
405Default is
406.Sq syslog .
407.Em As long as no official port is assigned this option is required
408.Em for TLS servers.
409.It Em tls_bindhost
410Hostname or IP to bind to.
411.It Em tls_gen_cert
412Automatically generate a private key and certificate.
413.It Em tls_key
414File with private key.
415Default is
416.Sq /etc/openssl/default.key
417.It Em tls_cert
418File with certificate to use.
419Default is
420.Sq /etc/openssl/default.crt
421.It Em tls_ca
422File with CA certificate to use.
423.It Em tls_cadir
424Directory containing CA certificates.
425.It Em tls_verify
426If set to
427.Sq off
428then certificate authentication is skipped.
429.It Em tls_allow_fingerprints
430List of fingerprints of trusted client certificates.
431.It Em tls_allow_clientcerts
432List of filenames with trusted client certificates.
433.El
434.Sh "TLS AUTHENTICATION"
435One function of TLS is mutual authentication of client and server.
436Unless authentication is disabled by setting
437.Sq tls_verify=off
438the following rules are used:
439.Ss "As client:"
440A client can be configured not to check a server's certificate by setting the
441parameter
442.Ar verify
443to
444.Sq off .
445If the server's certificate is signed by a trusted CA then it is checked
446if its hostname or IP is given in its certificate (as a CommonName, as a
447DNS SubjectAltName, or as an IP SubjectAltName).
448If any match is found then the server is authenticated.
449If a
450.Ar subject
451parameter is given then it is can satisfy this test as well.
452This allows DNS-independent configurations using the server's IP address in the
453destination and adding its hostname as
454.Ar subject
455to authenticate the TLS connection without having to add the IP to the X.509
456certificate.
457.Pp
458If no CA is used or no trust path between CA and server certificate exists, then
459hash value of the server's certificate is compared with the hash given in
460.Ar fingerprint
461and the hash of the certificate in
462.Ar cert .
463If the hashes are equal then the server is authenticated.
464.Ss "As server:"
465If using a CA and the client's certificate is signed by it then the client is
466authenticated.
467Otherwise the hash of the client's certificate is compared with the hashes given
468in
469.Ar tls_allow_fingerprints
470and the hashes of the certificates given in
471.Ar tls_allow_clientcerts .
472On any match the client is authenticated.
473.Sh BUFFERING
474.Xr syslogd 8
475is able to buffer temporary not writeable messages in memory.
476To limit the memory consumed for this buffering the following optons may be
477given:
478.Bl -ohang
479.It Em file_queue_length
480.It Em pipe_queue_length
481.It Em tls_queue_length
482The maximum number of messages buffered for one destination of type tls, file,
483or pipe respectively.
484Defaults are
485.Sq 1024 ,
486.Sq 1024 ,
487and
488.Sq -1
489(no limit).
490.It Em file_queue_size
491.It Em pipe_queue_size
492.It Em tls_queue_size
493The maximum memory usage in bytes of messages buffered for one destination.
494Defaults are
495.Sq 1M ,
496.Sq 1M ,
497and
498.Sq 16M .
499.El
500.Sh SIGNING
501.Xr syslogd 8
502is able to digitally sign all processed messages.
503The used protocol is defined by RFC nnnn (syslog-sign):
504at the start of a session the signing sender sends so called certificate
505blocks containing its public key; after that it periodically sends a signed
506message containing hashes of previous messages.
507.Pp
508To detect later manipulation one has to keep a copy of the key used for
509signing (otherwise an attacker could alter the logs and sign them with his
510his own key).
511If TLS is used with a DSA key then the same key will be used for signing.
512This is the recommended setup because it makes it easy to have copies of
513the certificate (with the public key) in backups.
514Otherwise new keys are generated on every restart and for certain verification
515it is necessary to have copies of all used keys.
516So logging only to a local file is not secure; at least the used keys should
517be logged to another host.
518.Bl -ohang
519.It Em sign_sg
520Enables signing.
521Set this option to enable syslog-sign and select how to assign
522messages to signature groups (subsets of messages that are signed together).
523To enable later signature verification and detection of lost messages the
524assignment should be chosen such that all messages of one signature group
525are written to the same file.
526Four possible values for this option are:
527.Bl -hang -offset indent
528.It Em 0
529Use one global signature group for all messages.
530.It Em 1
531Use one signature group per priority.
532.It Em 2
533Use signature groups for ranges of priorities.
534.It Em 3
535Use one signature group per destination.
536This is a custom strategy not defined by the standard.
537With this setting one signature group is set up for
538every file and network action.
539.El
540.It Em sign_delim_sg2
541This option is only evaluated with
542.Sq sign_sg=2
543and allows to configure the priority ranges for signature groups.
544The parameters are numerical values used as the maximum priority for one group.
545The default is to use one signature groups per facility, which is equal to
546setting
547.Sq sign_delim_sg2=7 15 23 31 39 ... .
548.El
549.Sh FILES
550.Bl -tag -width /etc/syslog.conf -compact
551.It Pa /etc/syslog.conf
552The
553.Xr syslogd 8
554configuration file.
555.It Pa /usr/share/examples/syslogd/verify.pl
556Example script to verify message signatures.
557(Requires Perl and modules not part of NetBSD.)
558.El
559.Sh EXAMPLES
560A configuration file might appear as follows:
561.Bd -literal
562# Log all kernel messages, authentication messages of
563# level notice or higher and anything of level err or
564# higher to the console.
565# Don't log private authentication messages!
566*.err;kern.*;auth.notice;authpriv.none	/dev/console
567
568# Log anything (except mail) of level info or higher.
569# Don't log private authentication messages!
570*.info;mail.none;authpriv.none		/var/log/messages
571
572# Log daemon messages at debug level only
573daemon.=debug				/var/log/daemon.debug
574
575# The authpriv file has restricted access.
576# Write logs with priority for later verification with syslog-sign.
577authpriv.*				+/var/log/secure
578
579# Log all the mail messages in one place.
580mail.*					/var/log/maillog
581
582# Everybody gets emergency messages, plus log them on another
583# machine.
584*.emerg					*
585*.emerg					@arpa.berkeley.edu
586
587# Log all messages of level info or higher to another
588# machine using TLS with an alternative portname and a
589# fingerprint for athentication
590*.info			@[logserver]:1234(fingerprint="SHA1:01:02:...")
591
592# Root and Eric get alert and higher messages.
593*.alert					root,eric
594
595# Save mail and news errors of level err and higher in a
596# special file.
597mail,news.err				/var/log/spoolerr
598
599# Pipe all authentication messages to a filter.
600auth.*					|exec /usr/local/sbin/authfilter
601
602# Log kernel messages to a separate file without syncing each message.
603kern.*					-/var/log/kernlog
604
605# Save ftpd transactions along with mail and news.
606!ftpd
607*.*					/var/log/spoolerr
608
609# Send all error messages from a RAID array through a filter.
610!raid0
611kern.err				|exec /usr/local/sbin/raidfilter
612
613# Save pppd messages from dialhost to a separate file.
614!pppd
615+dialhost
616*.*					/var/log/dialhost-pppd
617
618# Save non-local log messages from all programs to a separate file.
619!*
620-@
621*.*					/var/log/foreign
622
623# Generate digital signatures for all messages
624# to each file or network destination.
625sign_sg=3
626.Ed
627.Sh SEE ALSO
628.Xr syslog 3 ,
629.Xr syslogd 8
630.Sh HISTORY
631The
632.Nm
633file appeared in
634.Bx 4.3 ,
635along with
636.Xr syslogd 8 .
637.Sh BUGS
638The effects of multiple selectors are sometimes not intuitive.
639For example
640.Dq mail.crit;*.err
641will select
642.Dq mail
643facility messages at
644the level of
645.Dq err
646or higher, not at the level of
647.Dq crit
648or higher.
649