Document changes
[infodrom/sysklogd] / sysklogd.8
1 .\" Copyright 1994 Dr. Greg Wettstein, Enjellic Systems Development.
2 .\" Copyright 2004,6-8 Martin Schulze <joey@infodrom.org>
3 .\" May be distributed under the GNU General Public License
4 .\"
5 .TH SYSKLOGD 8 "11 May 2008" "Version 1.5" "Linux System Administration"
6 .SH NAME
7 sysklogd \- Linux system logging utilities.
8 .SH SYNOPSIS
9 .B syslogd
10 .RB [ " \-4" " ] [ " \-6 " ] [ " \-A " ]"
11 .RB [ " \-a "
12 .I socket
13 ]
14 .RB [ " \-d " ]
15 .RB [ " \-f "
16 .I config file
17 ]
18 .RB [ " \-h " ] 
19 .RB [ " \-l "
20 .I hostlist
21 ]
22 .RB [ " \-m "
23 .I interval
24
25 .RB [ " \-n " ]
26 .RB [ " \-p"
27 .IB socket 
28 ]
29 .RB [ " \-r " ]
30 .RB [ " \-s "
31 .I domainlist
32 ]
33 .RB [ " \-v " ]
34 .SH DESCRIPTION
35 .B Sysklogd
36 provides two system utilities which provide support for
37 system logging and kernel message trapping.  Support of both internet and
38 unix domain sockets enables this utility package to support both local
39 and remote logging.
40
41 System logging is provided by a version of 
42 .BR syslogd (8)
43 derived from the
44 stock BSD sources.  Support for kernel logging is provided by the
45 .BR klogd (8)
46 utility which allows kernel logging to be conducted in either a
47 standalone fashion or as a client of syslogd.
48
49 .B Syslogd
50 provides a kind of logging that many modern programs use.  Every logged
51 message contains at least a time and a hostname field, normally a
52 program name field, too, but that depends on how trusty the logging
53 program is.
54
55 While the
56 .B syslogd
57 sources have been heavily modified a couple of notes
58 are in order.  First of all there has been a systematic attempt to
59 insure that syslogd follows its default, standard BSD behavior.
60 The second important concept to note is that this version of syslogd
61 interacts transparently with the version of syslog found in the
62 standard libraries.  If a binary linked to the standard shared
63 libraries fails to function correctly we would like an example of the
64 anomalous behavior.
65
66 The main configuration file
67 .I /etc/syslog.conf
68 or an alternative file, given with the 
69 .B "\-f"
70 option, is read at startup.  Any lines that begin with the hash mark
71 (``#'') and empty lines are ignored.  If an error occurs during parsing
72 the whole line is ignored.
73 .SH OPTIONS
74 .TP
75 .B "\-4"
76 Force
77 .B syslogd
78 to use IPv4 addresses only.
79 .TP
80 .B "\-6"
81 Force
82 .B syslogd
83 to use IPv6 addresses only.
84 .TP
85 .B "\-A"
86 Ordinarily,
87 .B syslogd
88 tries to send the message to only one address even if the host has
89 more than one A or AAAA record.  If this option is specified,
90 .B syslogd
91 tries to send the message to all addresses.
92 .TP
93 .BI "\-a " "socket"
94 Using this argument you can specify additional sockets from that
95 .B syslogd
96 has to listen to.  This is needed if you're going to let some daemon
97 run within a chroot() environment.  You can use up to 19 additional
98 sockets.  If your environment needs even more, you have to increase
99 the symbol
100 .B MAXFUNIX
101 within the syslogd.c source file.  An example for a chroot() daemon is
102 described by the people from OpenBSD at
103 <http://www.guides.sk/psionic/dns/>.
104 .TP
105 .B "\-d"
106 Turns on debug mode.  Using this the daemon will not proceed a 
107 .BR fork (2)
108 to set itself in the background, but opposite to that stay in the
109 foreground and write much debug information on the current tty.  See the
110 DEBUGGING section for more information.
111 .TP
112 .BI "\-f " "config file"
113 Specify an alternative configuration file instead of
114 .IR /etc/syslog.conf ","
115 which is the default.
116 .TP
117 .BI "\-h "
118 By default syslogd will not forward messages it receives from remote hosts.
119 Specifying this switch on the command line will cause the log daemon to
120 forward any remote messages it receives to forwarding hosts which have been
121 defined.
122 This can cause syslog loops that fill up hard disks quite fast and
123 thus needs to be used with caution.
124 .TP
125 .BI "\-l " "hostlist"
126 Specify a hostname that should be logged only with its simple hostname
127 and not the fqdn.  Multiple hosts may be specified using the colon
128 (``:'') separator.
129 .TP
130 .BI "\-m " "interval"
131 The
132 .B syslogd
133 logs a mark timestamp regularly.  The default
134 .I interval
135 between two \fI-- MARK --\fR lines is 20 minutes.  This can be changed
136 with this option.  Setting the
137 .I interval
138 to zero turns it off entirely.  Depending on other log messages
139 generated these lines may not be written consecutively.
140 The \fI-- MARK --\fR message is only written if the log file hasn't
141 been touched in
142 .IR interval /2
143 minutes.
144 .TP
145 .B "\-n"
146 Avoid auto-backgrounding.  This is needed especially if the
147 .B syslogd
148 is started and controlled by
149 .BR init (8).
150 .TP
151 .BI "\-p " "socket"
152 You can specify an alternative unix domain socket instead of
153 .IR /dev/log "."
154 .TP
155 .B "\-r"
156 This option will enable the facility to receive message from the
157 network using an internet domain socket with the syslog service (see 
158 .BR services (5)).
159 The default is to not receive any messages from the network.
160
161 This option is introduced in version 1.3 of the sysklogd
162 package.  Please note that the default behavior is the opposite of
163 how older versions behave, so you might have to turn this on.
164 .TP
165 .BI "\-s " "domainlist"
166 Specify a domainname that should be stripped off before
167 logging.  Multiple domains may be specified using the colon (``:'')
168 separator.
169 Please be advised that no sub-domains may be specified but only entire
170 domains.  For example if
171 .B "\-s north.de"
172 is specified and the host logging resolves to satu.infodrom.north.de
173 no domain would be cut, you will have to specify two domains like:
174 .BR "\-s north.de:infodrom.north.de" .
175 .TP
176 .B "\-v"
177 Print version and exit.
178 .SH SIGNALS
179 .B Syslogd
180 reacts to a set of signals.  You may easily send a signal to
181 .B syslogd
182 using the following:
183 .IP
184 .nf
185 kill -SIGNAL `cat /var/run/syslogd.pid`
186 .fi
187 .PP
188 .TP
189 .B SIGHUP
190 This lets
191 .B syslogd
192 perform a re-initialization.  All open files are closed, the
193 configuration file (default is 
194 .IR /etc/syslog.conf ")"
195 will be reread and the
196 .BR syslog (3)
197 facility is started again.
198 .TP
199 .B SIGTERM
200 The
201 .B syslogd
202 will die.
203 .TP
204 .BR SIGINT ", " SIGQUIT
205 If debugging is enabled these are ignored, otherwise 
206 .B syslogd
207 will die.
208 .TP
209 .B SIGUSR1
210 Switch debugging on/off.  This option can only be used if
211 .B syslogd
212 is started with the
213 .B "\-d"
214 debug option.
215 .TP
216 .B SIGCHLD
217 Wait for childs if some were born, because of wall'ing messages.
218 .SH CONFIGURATION FILE SYNTAX DIFFERENCES
219 .B Syslogd
220 uses a slightly different syntax for its configuration file than
221 the original BSD sources.  Originally all messages of a specific priority
222 and above were forwarded to the log file.
223 .IP
224 For example the following line caused ALL output from daemons using
225 the daemon facilities (debug is the lowest priority, so every higher
226 will also match) to go into 
227 .IR /usr/adm/daemons :
228 .IP
229 .nf
230         # Sample syslog.conf
231         daemon.debug                    /usr/adm/daemons
232 .fi
233 .PP
234 Under the new scheme this behavior remains the same.  The difference
235 is the addition of four new specifiers, the asterisk (\fB*\fR)
236 wildcard, the equation sign (\fB=\fR), the exclamation mark
237 (\fB!\fR), and the minus sign (\fB-\fR).
238
239 The \fB*\fR specifies that all messages for the
240 specified facility are to be directed to the destination.  Note that
241 this behavior is degenerate with specifying a priority level of debug.
242 Users have indicated that the asterisk notation is more intuitive.
243
244 The \fB=\fR wildcard is used to restrict logging to the specified priority
245 class.  This allows, for example, routing only debug messages to a
246 particular logging source.
247 .IP
248 For example the following line in
249 .I syslog.conf
250 would direct debug messages from all sources to the
251 .I /usr/adm/debug
252 file.
253 .IP
254 .nf
255         # Sample syslog.conf
256         *.=debug                        /usr/adm/debug
257 .fi
258 .PP
259 .\" The \fB!\fR as the first character of a priority inverts the above
260 .\" mentioned interpretation.
261 The \fB!\fR is used to exclude logging of the specified
262 priorities.  This affects all (!) possibilities of specifying priorities.
263 .IP
264 For example the following lines would log all messages of the facility
265 mail except those with the priority info to the
266 .I /usr/adm/mail 
267 file.  And all messages from news.info (including) to news.crit
268 (excluding) would be logged to the
269 .I /usr/adm/news
270 file.
271 .IP
272 .nf
273         # Sample syslog.conf
274         mail.*;mail.!=info              /usr/adm/mail
275         news.info;news.!crit    /usr/adm/news
276 .fi
277 .PP
278 You may use it intuitively as an exception specifier.  The above
279 mentioned interpretation is simply inverted.  Doing that you may use
280
281 .nf
282         mail.none
283 .fi
284 or
285 .nf
286         mail.!*
287 .fi
288 or
289 .nf
290         mail.!debug
291 .fi
292
293 to skip every message that comes with a mail facility.  There is much
294 room to play with it. :-)
295
296 The \fB-\fR may only be used to prefix a filename if you want to omit
297 sync'ing the file after every write to it.
298
299 This may take some acclimatization for those individuals used to the
300 pure BSD behavior but testers have indicated that this syntax is
301 somewhat more flexible than the BSD behavior.  Note that these changes
302 should not affect standard
303 .BR syslog.conf (5)
304 files.  You must specifically
305 modify the configuration files to obtain the enhanced behavior.
306 .SH SUPPORT FOR REMOTE LOGGING
307 These modifications provide network support to the syslogd facility.
308 Network support means that messages can be forwarded from one node
309 running syslogd to another node running syslogd where they will be
310 actually logged to a disk file.
311
312 To enable this you have to specify the
313 .B "\-r"
314 option on the command line.  The default behavior is that
315 .B syslogd
316 won't listen to the network.
317
318 The strategy is to have syslogd listen on a unix domain socket for
319 locally generated log messages.  This behavior will allow syslogd to
320 inter-operate with the syslog found in the standard C library.  At the
321 same time syslogd listens on the standard syslog port for messages
322 forwarded from other hosts.  To have this work correctly the
323 .BR services (5)
324 files (typically found in
325 .IR /etc )
326 must have the following
327 entry:
328 .IP
329 .nf
330         syslog          514/udp
331 .fi
332 .PP
333 If this entry is missing
334 .B syslogd
335 neither can receive remote messages nor send them, because the UDP
336 port cant be opened.  Instead 
337 .B syslogd
338 will die immediately, blowing out an error message.
339
340 To cause messages to be forwarded to another host replace
341 the normal file line in the
342 .I syslog.conf
343 file with the name of the host to which the messages is to be sent
344 prepended with an @.
345 .IP
346 For example, to forward
347 .B ALL
348 messages to a remote host use the
349 following
350 .I syslog.conf
351 entry:
352 .IP
353 .nf
354         # Sample syslogd configuration file to
355         # messages to a remote host forward all.
356         *.*                     @hostname
357 .fi
358
359 To forward all \fBkernel\fP messages to a remote host the
360 configuration file would be as follows:
361 .IP
362 .nf
363         # Sample configuration file to forward all kernel
364         # messages to a remote host.
365         kern.*          @hostname
366 .fi
367 .PP
368
369 If the remote hostname cannot be resolved at startup, because the
370 name-server might not be accessible (it may be started after syslogd)
371 you don't have to worry.
372 .B Syslogd
373 will retry to resolve the name ten times and then complain.  Another
374 possibility to avoid this is to place the hostname in
375 .IR /etc/hosts .
376
377 With normal
378 .BR syslogd s
379 you would get syslog-loops if you send out messages that were received
380 from a remote host to the same host (or more complicated to a third
381 host that sends it back to the first one, and so on).  In my domain
382 (Infodrom Oldenburg) we accidently got one and our disks filled up
383 with the same single message. :-(
384
385 To avoid this no messages received from a
386 remote host are sent out to another (or the same) remote host
387 anymore.  If you experience are setup in which you need this behaviour,
388 please use the
389 .B \-h
390 command line switch.
391 However, this option needs to be handled with caution since a syslog
392 loop can fill up hard disks quite fast.
393
394 If the remote host is located in the same domain as the host, 
395 .B syslogd
396 is running on, only the simple hostname will be logged instead of
397 the whole fqdn.
398
399 In a local network you may provide a central log server to have all
400 the important information kept on one machine.  If the network consists
401 of different domains you don't have to complain about logging fully
402 qualified names instead of simple hostnames.  You may want to use the
403 strip-domain feature
404 .B \-s
405 of this server.  You can tell the
406 .B syslogd
407 to strip off several domains other than the one the server is located
408 in and only log simple hostnames.
409
410 Using the
411 .B \-l
412 option there's also a possibility to define single hosts as local
413 machines.  This, too, results in logging only their simple hostnames
414 and not the fqdns.
415
416 The UDP socket used to forward messages to remote hosts or to receive
417 messages from them is only opened when it is needed.  In releases
418 prior to 1.3-23 it was opened every time but not opened for reading or
419 forwarding respectively.
420 .SH OUTPUT TO NAMED PIPES (FIFOs)
421 This version of syslogd has support for logging output to named pipes
422 (fifos).  A fifo or named pipe can be used as a destination for log
423 messages by prepending a pipy symbol (``|'') to the name of the
424 file.  This is handy for debugging.  Note that the fifo must be created
425 with the mkfifo command before syslogd is started.
426 .IP
427 The following configuration file routes debug messages from the
428 kernel to a fifo:
429 .IP
430 .nf
431         # Sample configuration to route kernel debugging
432         # messages ONLY to /usr/adm/debug which is a
433         # named pipe.
434         kern.=debug                     |/usr/adm/debug
435 .fi
436 .LP
437 .SH INSTALLATION CONCERNS
438 There is probably one important consideration when installing this
439 version of syslogd.  This version of syslogd is dependent on proper
440 formatting of messages by the syslog function.  The functioning of the
441 syslog function in the shared libraries changed somewhere in the
442 region of libc.so.4.[2-4].n.  The specific change was to
443 null-terminate the message before transmitting it to the 
444 .I /dev/log
445 socket.  Proper functioning of this version of syslogd is dependent on
446 null-termination of the message.
447
448 This problem will typically manifest itself if old statically linked
449 binaries are being used on the system.  Binaries using old versions of
450 the syslog function will cause empty lines to be logged followed by
451 the message with the first character in the message removed.
452 Relinking these binaries to newer versions of the shared libraries
453 will correct this problem.
454
455 Both the
456 .BR syslogd "(8) and the " klogd (8)
457 can either be run from
458 .BR init (8)
459 or started as part of the rc.*
460 sequence.  If it is started from init the option \fI\-n\fR must be set,
461 otherwise you'll get tons of syslog daemons started.  This is because 
462 .BR init (8)
463 depends on the process ID.
464 .SH SECURITY THREATS
465 There is the potential for the syslogd daemon to be
466 used as a conduit for a denial of service attack.  Thanks go to John
467 Morrison (jmorriso@rflab.ee.ubc.ca) for alerting me to this potential.
468 A rogue program(mer) could very easily flood the syslogd daemon with
469 syslog messages resulting in the log files consuming all the remaining
470 space on the filesystem.  Activating logging over the inet domain
471 sockets will of course expose a system to risks outside of programs or
472 individuals on the local machine.
473
474 There are a number of methods of protecting a machine:
475 .IP 1.
476 Implement kernel firewalling to limit which hosts or networks have
477 access to the 514/UDP socket.
478 .IP 2.
479 Logging can be directed to an isolated or non-root filesystem which,
480 if filled, will not impair the machine.
481 .IP 3.
482 The ext2 filesystem can be used which can be configured to limit a
483 certain percentage of a filesystem to usage by root only.  \fBNOTE\fP
484 that this will require syslogd to be run as a non-root process.
485 \fBALSO NOTE\fP that this will prevent usage of remote logging since
486 syslogd will be unable to bind to the 514/UDP socket.
487 .IP 4.
488 Disabling inet domain sockets will limit risk to the local machine.
489 .IP 5.
490 Use step 4 and if the problem persists and is not secondary to a rogue
491 program/daemon get a 3.5 ft (approx. 1 meter) length of sucker rod*
492 and have a chat with the user in question.
493
494 Sucker rod def. \(em 3/4, 7/8 or 1in. hardened steel rod, male
495 threaded on each end.  Primary use in the oil industry in Western
496 North Dakota and other locations to pump 'suck' oil from oil wells.
497 Secondary uses are for the construction of cattle feed lots and for
498 dealing with the occasional recalcitrant or belligerent individual.
499 .SH DEBUGGING
500 When debugging is turned on using
501 .B "\-d"
502 option then
503 .B syslogd
504 will be very verbose by writing much of what it does on stdout.  Whenever
505 the configuration file is reread and re-parsed you'll see a tabular,
506 corresponding to the internal data structure.  This tabular consists of
507 four fields:
508 .TP
509 .I number
510 This field contains a serial number starting by zero.  This number
511 represents the position in the internal data structure (i.e. the
512 array).  If one number is left out then there might be an error in the
513 corresponding line in
514 .IR /etc/syslog.conf .
515 .TP
516 .I pattern
517 This field is tricky and represents the internal structure
518 exactly.  Every column stands for a facility (refer to
519 .BR syslog (3)).
520 As you can see, there are still some facilities left free for former
521 use, only the left most are used.  Every field in a column represents
522 the priorities (refer to
523 .BR syslog (3)).
524 .TP
525 .I action
526 This field describes the particular action that takes place whenever a
527 message is received that matches the pattern.  Refer to the
528 .BR syslog.conf (5)
529 manpage for all possible actions.
530 .TP
531 .I arguments
532 This field shows additional arguments to the actions in the last
533 field.  For file-logging this is the filename for the logfile; for
534 user-logging this is a list of users; for remote logging this is the
535 hostname of the machine to log to; for console-logging this is the
536 used console; for tty-logging this is the specified tty; wall has no
537 additional arguments.
538 .SH FILES
539 .PD 0
540 .TP
541 .I /etc/syslog.conf
542 Configuration file for
543 .BR syslogd .
544 See
545 .BR syslog.conf (5)
546 for exact information.
547 .TP
548 .I /dev/log
549 The Unix domain socket to from where local syslog messages are read.
550 .TP
551 .I /var/run/syslogd.pid
552 The file containing the process id of 
553 .BR syslogd .
554 .PD
555 .SH BUGS
556 If an error occurs in one line the whole rule is ignored.
557
558 .B Syslogd
559 doesn't change the filemode of opened logfiles at any stage of
560 process.  If a file is created it is world readable.  If you want to
561 avoid this, you have to create it and change permissions on your own.
562 This could be done in combination with rotating logfiles using the 
563 .BR savelog (8)
564 program that is shipped in the 
565 .B smail
566 3.x distribution.  Remember that it might be a security hole if
567 everybody is able to read auth.* messages as these might contain
568 passwords.
569 .SH SEE ALSO
570 .BR syslog.conf (5),
571 .BR klogd (8),
572 .BR logger (1),
573 .BR syslog (2),
574 .BR syslog (3),
575 .BR services (5),
576 .BR savelog (8).
577 .SH AUTHORS
578 The system log daemon
579 .B syslogd
580 is originally  taken from BSD sources, Greg Wettstein <greg@wind.enjellic.com>
581 performed the port to Linux, Martin Schulze <joey@infodrom.org>
582 fixed some bugs, added several new features and took over maintenance.