SYSKLOGD(8) Linux System Administration SYSKLOGD(8)
NAME
sysklogd - Linux system logging utilities.
linux系统登录功能
SYNOPSIS
syslogd [ -a socket ] [ -d ] [ -f config file ] [ -h ] [ -l hostlist ]
[ -m interval ] [ -n ] [ -p socket ] [ -r ] [ -s domainlist ] [ -v ] [
-x ]
DESCRIPTION
Sysklogd provides two system utilities which provide support for system
logging and kernel message trapping. Support of both internet and unix
domain sockets enables this utility package to support both local and
remote logging.
Sysklogd提供了两个系统功用。一个支持系统登录。另一个捕捉内核信息。支持因特网和unix域名套接字能使这项功用支持本地和远端登录。
System logging is provided by a version of syslogd(8) derived from the
stock BSD sources. Support for kernel logging is provided by the
klogd(8) utility which allows kernel logging to be conducted in either
a standalone fashion or as a client of syslogd.
某个版本的syslogd(8)支持记录系统登录是起源于BSD源代码的常备功能。支持内核登录信息的是klogd(8)功用,klogd(8)功用引导内核登录信息到标准样式或者是作为syslogd的客户端。
Syslogd provides a kind of logging that many modern programs use.
Every logged message contains at least a time and a hostname field,
normally a program name field, too, but that depends on how trusty the
logging program is.
Syslogd提供一种记录登录的机制,这种机制被许多现代的程序所使用。 每一个登录信息包含至少登录时间和登录的主机名字。正常情况下,也记录程序的名字,但是这要依赖程序的可信任程度。
While the syslogd sources have been heavily modified a couple of notes
are in order. First of all there has been a systematic attempt to
insure that syslogd follows its default, standard BSD behavior. The
second important concept to note is that this version of syslogd interacts transparently with the version of syslog found in the standard
libraries. If a binary linked to the standard shared libraries fails
to function correctly we would like an example of the anomalous behav-
ior.
当syslogd的源代码被严重的修改过后,应该按顺序的注意几个地方。首先系统尝试确保syslogd的默认设置,标准的BSD行为。其次,一个重要的概念是,注意这个版本的syslogd要和在标准库里的其他syslogd配合,找到标准库。如果一个二进制文件连接到一个标准共享库未能保证功能正确的运行。我们希望得到一个不规则运行的例子。
The main configuration file /etc/syslog.conf or an alternative file,
given with the -f option, is read at startup. Any lines that begin
with the hash mark (‘‘#’’) and empty lines are ignored. If an er
ror occurs during parsing the whole line is ignored.
主配置文件是/etc/syslog.conf,或是一个非常规的文件,程序开始的时候使用-f参数。忽略以#开头的行和空白行,如果发生错误,忽略全部分析的行。
OPTIONS
-a socket
Using this argument you can specify additional sockets from that
syslogd has to listen to. This is needed if you’re going to let
some daemon run within a chroot() environment. You can use up
to 19 additional sockets. If your environment needs even more,
you have to increase the symbol MAXFUNIX within the syslogd.c
source file. An example for a chroot() daemon is described by
the people from OpenBSD at
使用这个参数,你可以为syslogd定义额外的套接字来进行端口监听。如果你让一些服务运行在一个chroot环境里,这是必须的。你可以使用19个额外的套接字,如果你的环境需要更多的端口,你必须在源文件里增大symbol MAXFUNIX。
-d Turns on debug mode. Using this the daemon will not proceed a
fork(2) to set itself in the background, but opposite to that
stay in the foreground and write much debug information on the
current tty. See the DEBUGGING section for more information.
-f config file
Specify an alternative configuration file instead of /etc/sys-
log.conf, which is the default.
-h By default syslogd will not forward messages it receives from
remote hosts. Specifying this switch on the command line will
cause the log daemon to forward any remote messages it receives
to forwarding hosts which have been defined.
-l hostlist
Specify a hostname that should be logged only with its simple
hostname and not the fqdn. Multiple hosts may be specified
using the colon (‘‘:’’) separator.
-m interval
The syslogd logs a mark timestamp regularly. The default inter-
val between two -- MARK -- lines is 20 minutes. This can be
changed with this option. Setting the interval to zero turns it
off entirely.
-n Avoid auto-backgrounding. This is needed especially if the sys-
logd is started and controlled by init(8).
-p socket
You can specify an alternative unix domain socket instead of
/dev/log.
-r This option will enable the facility to receive message from the
network using an internet domain socket with the syslog service
(see services(5)). The default is to not receive any messages
from the network.
This option is introduced in version 1.3 of the sysklogd pack-
age. Please note that the default behavior is the opposite of
how older versions behave, so you might have to turn this on.
-s domainlist
Specify a domainname that should be stripped off before logging.
Multiple domains may be specified using the colon (‘‘:’’) se
pa-
rator. Please be advised that no sub-domains may be specified
but only entire domains. For example if -s north.de is speci-
fied and the host logging resolves to satu.infodrom.north.de no
domain would be cut, you will have to specify two domains like:
-s north.de:infodrom.north.de.
-v Print version and exit.
-x Disable name lookups when receiving remote messages. This
avoids deadlocks when the nameserver is running on the same
machine that runs the syslog daemon.
SIGNALS
Syslogd reacts to a set of signals. You may easily send a signal to
syslogd using the following:
kill -SIGNAL ‘cat /var/run/syslogd.pid‘
SIGHUP This lets syslogd perform a re-initialization. All open files
are closed, the configuration file (default is /etc/syslog.conf)
will be reread and the syslog(3) facility is started again.
将使syslogd执行重新初始化的行为,关闭所有打开的文件,重新读配置文件,syslog(3)重新开始。
SIGTERM
The syslogd will die.
SIGINT, SIGQUIT
If debugging is enabled these are ignored, otherwise syslogd
will die.
SIGUSR1
Switch debugging on/off. This option can only be used if sys-
logd is started with the -d debug option.
SIGCHLD
Wait for childs if some were born, because of wall’ing messages.
CONFIGURATION FILE SYNTAX DIFFERENCES 文件构造语句的差别
Syslogd uses a slightly different syntax for its configuration file
than the original BSD sources. Originally all messages of a specific
priority and above were forwarded to the log file.
syslogd的配置文件和BSD源代码的配置文件有些微的差别。默认的,所有指定的优先权,并包括高于此优先权的信息传送到log文件里去。
For example the following line caused ALL output from daemons
using the daemon facilities (debug is the lowest priority, so
every higher will also match) to go into /usr/adm/daemons:
举个例子来说,下列行能让所有使用daemons设备的daemons输出。(debug是最低级的优先权,所以每一个比debug高的优先权将被整合。)输出到/usr/adm/daemons里去。
# Sample syslog.conf
daemon.debug /usr/adm/daemons
Under the new scheme this behavior remains the same. The difference is
the addition of four new specifiers, the asterisk (*) wildcard, the
equation sign (=), the exclamation mark (!), and the minus sign (-).
在新的规划下,这种行为保留各个级别中重复的信息。有区别的时候是使用四个定义符号的时候,这四个定义符号是:通配符星号*,等号=,感叹号!,和减号-。
The * specifies that all messages for the specified facility are to be
directed to the destination. Note that this behavior is degenerate
with specifying a priority level of debug. Users have indicated that
the asterisk notation is more intuitive.
星号*定义了所有指定设备的信息,并且传送到目的地。注意这种行为对定义debug级别的优先权是一种退步。但是用户指出使用星号更加直观。
The = wildcard is used to restrict logging to the specified priority
class. This allows, for example, routing only debug messages to a par-
ticular logging source.
等号通配符用来表示指定的优先权,比如,允许只传送debug优先权的信息到特定的log文件。
For example the following line in syslog.conf would direct debug
messages from all sources to the /usr/adm/debug file.
比如在syslog.conf中的下面这一行将从所有的来源中传送debug信息到/usr/adm/debug文件中。
# Sample syslog.conf
*.=debug /usr/adm/debug
The ! is used to exclude logging of the specified priorities. This
affects all (!) possibilities of specifying priorities.
感叹号!排除指定优先权的log信息。会影响到所有可能的定义优先权。
For example the following lines would log all messages of the
facility mail except those with the priority info to the
/usr/adm/mail file. And all messages from news.info (including)
to news.crit (excluding) would be logged to the /usr/adm/news
file.
举个例子来说,下面这几行将记录所有除info之外的mail设备的信息到/usr/adm/mail文件里。第二行,将记录所有从news.info(包括info级别)到news.crit(不包括crit)的信息,这些信息记录在/usr/adm/news里。
# Sample syslog.conf
mail.*;mail.!=info /usr/adm/mail
news.info;news.!crit /usr/adm/news
You may use it intuitively as an exception specifier. The above men-
tioned interpretation is simply inverted. Doing that you may use
你可以直观的使用排除法的定义,就是上面提及的简单的逆转的意思,要这样做你可以使用
mail.none
或者
mail.!*
或者
mail.!debug
to skip every message that comes with a mail facility. There is much
room to play with it. :-)
来跳过来自mail设备的每一个信息。有足够的空间来这样做。
The - may only be used to prefix a filename if you want to omit
sync’ing the file after every write to it.
-用在文件的前缀中,如果你想在每一次写完文件后,忽略文件的同步,你可以使用 - 。
日志文件记录设备和服务的信息,但是记录的信息却不是立即写到硬盘中去,使用-,可以使信息先写到log文件中,暂时不写到硬盘中去。
This may take some acclimatization for those individuals used to the
pure BSD behavior but testers have indicated that this syntax is some-
what more flexible than the BSD behavior. Note that these changes
should not affect standard syslog.conf(5) files. You must specifically
modify the configuration files to obtain the enhanced behavior.
这可以解决为单独的文件提供环境适应性。单独的文件被单纯BSD的行为使用,但是试验者指出这个语句比BSD行为有点弹性。注意这些变化不会影响到标准的syslog.conf(5)文件。必须特别修改配置文件以获得增强的行为。
SUPPORT FOR REMOTE LOGGING 对远端登录的支持。
These modifications provide network support to the syslogd facility.
Network support means that messages can be forwarded from one node run-
ning syslogd to another node running syslogd where they will be actu-
ally logged to a disk file.
这项修改为syslogd设备提供网络支持。网络支持意味着信息能从一个节点的syslogd传送到另一个正在运行的syslogd节点上,另一个节点的syslogd将实际将登录信息记录到硬盘上。
To enable this you have to specify the -r option on the command line.
The default behavior is that syslogd won’t listen to the network.
使用这项功能你必须在命令行里使用-r参数,默认的行为是syslogd不开通网络。
The strategy is to have syslogd listen on a unix domain socket for
locally generated log messages. This behavior will allow syslogd to
inter-operate with the syslog found in the standard C library. At the
same time syslogd listens on the standard syslog port for messages for-
warded from other hosts. To have this work correctly the services(5)
files (typically found in /etc) must have the following entry:
这个策略让syslogd监听另一个unix主机域名套接字,为本地产生log信息。这个行为允许syslogd使用在c函数库里的syslog在内部操作。同时syslogd监听标准syslog端口产生的信息,这些信息来自于其他主机。为使这项工作正常进行,services文件里必须有下面这一行。
syslog 514/udp
If this entry is missing syslogd neither can receive remote messages
nor send them, because the UDP port cant be opened. Instead syslogd
will die immediately, blowing out an error message.
如果这一行丢失,syslogd将不能接受来自远端的信息,也不能发送信息,因为UDP端口没有打开。替代syslogd的程序将消失,错误信息不再保留。
To cause messages to be forwarded to another host replace the normal
file line in the syslog.conf file with the name of the host to which
the messages is to be sent prepended with an @.
要让信息发送到另一台主机,来替代在syslog.conf中定义的正常文件行,通过主机的
名字来实现 ,使用@符号来决定哪些信息被发送了。
For example, to forward ALL messages to a remote host use the
following syslog.conf entry:
举例来说,发送所有信息到远端主机使用下面的配置文件格式。
# Sample syslogd configuration file to
# messages to a remote host forward all.
*.* @hostname
To forward all kernel messages to a remote host the configura-
tion file would be as follows:
发送所有内核信息到远端主机,在配置文件中应该这样写:
# Sample configuration file to forward all kernel
# messages to a remote host.
kern.* @hostname
If the remote hostname cannot be resolved at startup, because the name-
server might not be accessible (it may be started after syslogd) you
don’t have to worry. Syslogd will retry to resolve the name ten times
and then complain. Another possibility to avoid this is to place the
hostname in /etc/hosts.
如果远端主机名字在启动的时候未被解析,是因为没有开启域名服务。(可能域名服务在syslogd服务之后开启)。不要担心,Syslogd将重新解析域名十次才结束。另一个避免此种情况的方法是在/etc/hosts里放置主机名。
With normal syslogds you would get syslog-loops if you send out mes-
sages that were received from a remote host to the same host (or more
complicated to a third host that sends it back to the first one, and so
on). In my domain (Infodrom Oldenburg) we accidently got one and our
disks filled up with the same single message. :-(
通过正常的syslogd,如果你发送出的信息来自于远端主机接受的信息,你可以获得syslog-loops。(或者你接受的信息来自于更复杂一些的第三方主机,这第三方主机向第一个主机发回信息。)。在本地的主机域名里,我们偶尔可以充满一个或四个磁盘的信息。
To avoid this in further times no messages that were received from a
remote host are sent out to another (or the same) remote host anymore.
If there are scenarios where this doesn’t make sense, please drop me
(Joey) a line.
为了避免在以后没有信息,从远端主机接受的信息再被发送到另一个远端主机,如果这样规划是不明智的,那么删除一行。
If the remote host is located in the same domain as the host, syslogd
is running on, only the simple hostname will be logged instead of the
whole fqdn.
如果远端主机在同一个域名系统里,syslogd就进行工作,只是记录相同的主机名,以代替全部的正式域名。
In a local network you may provide a central log server to have all the
important information kept on one machine. If the network consists of
different domains you don’t have to complain about logging fully quali-
fied names instead of simple hostnames. You may want to use the strip-
domain feature -s of this server. You can tell the syslogd to strip
off several domains other than the one the server is located in and
only log simple hostnames.
在本地网络上,你可以准备一个中心log服务器以便让所有的重要信息都保留在一台机器上。如果本地网络包含有不同的域名,你没必要抱怨登录是全部有限制的名字来代替简单的主机名。你可能想使用服务器的域名剥离功能-s。你可以告诉syslogd剥离比一个多一些的其他一系列的域名,在本地只记录一下简单的主机名。
Using the -l option there’s also a possibility to define single hosts
as local machines. This, too, results in logging only their simple
hostnames and not the fqdns.
使用-l选项也是一种可能,来定义简单的主机和本地机器。这也是在登录里解析简单的主机名,而不是在解析正式域名。
The UDP socket used to forward messages to remote hosts or to receive
messages from them is only opened when it is needed. In releases prior
to 1.3-23 it was opened every time but not opened for reading or for-
warding respectively.
UDP套接字被用来传送信息到远端主机,或者从远端主机接受信息,在需要的时候打开套接字,在较早发行的版本1.3-23里,每次都打开套接字,但是不仅仅为读和传送打开。
OUTPUT TO NAMED PIPES (FIFOs) 输出到管道。
This version of syslogd has support for logging output to named pipes
(fifos). A fifo or named pipe can be used as a destination for log
messages by prepending a pipy symbol (‘‘|’’) to the name of the file.
This is handy for debugging. Note that the fifo must be created with
the mkfifo command before syslogd is started.
本版本的syslogd支持将登录信息输出到命名管道(fifos)。通过为文件的名字预先定义管道符号(‘‘|’’)可以将一个fifo或者是一个命名管道作为登录信息的目的地,这为测试syslogd提供了方便。注意fifo必须在syslogd开启之前,在mkfifo命令行里定义。
The following configuration file routes debug messages from the
kernel to a fifo:
下面的配置文件将从内核里传送出的debug信息传送到fifo里。
# Sample configuration to route kernel debugging
# messages ONLY to /usr/adm/debug which is a
# named pipe.
kern.=debug |/usr/adm/debug
INSTALLATION CONCERNS 设置重点
There is probably one important consideration when installing this ver-
sion of syslogd. This version of syslogd is dependent on proper for-
matting of messages by the syslog function. The functioning of the
syslog function in the shared libraries changed somewhere in the region
of libc.so.4.[2-4].n. The specific change was to null-terminate the
message before transmitting it to the /dev/log socket. Proper func-
tioning of this version of syslogd is dependent on null-termination of
the message.
本节讲述安装这个版本的syslogd设置的重点,这个版本的syslogd依赖由syslog功能产生的有恰当的格式信息。在共享库里的syslog功能改变了libc.so.4.[2-4].n.文件的一些区域。明确的改变是传送信息给/dev/log套接字之前对null-terminate的改变。这个版本的syslogd严格意义上的功能依赖于信息的null-terminate。
This problem will typically manifest itself if old statically linked
binaries are being used on the system. Binaries using old versions of
the syslog function will cause empty lines to be logged followed by the
message with the first character in the message removed. Relinking
these binaries to newer versions of the shared libraries will correct
this problem.
如果静态链接库使用在系统上,这个程序的代表性明白的是她自己。二进制使用旧版本的syslog功能将导致空行通过跟随的信息被登录,跟随信息的第一个字符被删除。重新连接这些二进制文件到共享库的新版本将正确的执行。
Both the syslogd(8) and the klogd(8) can either be run from init(8) or
started as part of the rc.* sequence. If it is started from init the
option -n must be set, otherwise you’ll get tons of syslog daemons
started. This is because init(8) depends on the process ID.
syslogd(8)和klogd(8)都被init(8)或者是rc.* 级别中的一个级别所启动。如果从init启动,则-n选项必须被设置,否则,大量的syslog守护进程开启。这是因为init(8)依赖于进程ID。
SECURITY THREATS 安全威胁
There is the potential for the syslogd daemon to be used as a conduit
for a denial of service attack. Thanks go to John Morrison (jmor-
riso@rflab.ee.ubc.ca) for alerting me to this potential. A rogue pro-
gram(mer) could very easily flood the syslogd daemon with syslog mes-
sages resulting in the log files consuming all the remaining space on
the filesystem. Activating logging over the inet domain sockets will
of course expose a system to risks outside of programs or individuals
on the local machine.
守护进程可作为拒绝服务攻击的一个管道,syslog服务潜在的有这种危险。感谢你发信息到jmorriso@rflab.ee.ubc.ca来报告这种危险。一个调皮捣蛋的人可以使用syslog信息非常容易的搞鬼。域名套接字当然可以暴露系统的危险。
There are a number of methods of protecting a machine:
1. Implement kernel firewalling to limit which hosts or networks
have access to the 514/UDP socket.
2. Logging can be directed to an isolated or non-root filesystem
which, if filled, will not impair the machine.
3. The ext2 filesystem can be used which can be configured to limit
a certain percentage of a filesystem to usage by root only.
NOTE that this will require syslogd to be run as a non-root pro-
cess. ALSO NOTE that this will prevent usage of remote logging
since syslogd will be unable to bind to the 514/UDP socket.
4. Disabling inet domain sockets will limit risk to the local
machine.
5. Use step 4 and if the problem persists and is not secondary to a
rogue program/daemon get a 3.5 ft (approx. 1 meter) length of
sucker rod* and have a chat with the user in question.
Sucker rod def. — 3/4, 7/8 or 1in. hardened steel rod, male
threaded on each end. Primary use in the oil industry in West-
ern North Dakota and other locations to pump ’suck’ oil from oi
l
wells. Secondary uses are for the construction of cattle feed
lots and for dealing with the occasional recalcitrant or bel-
ligerent individual.
DEBUGGING
When debugging is turned on using -d option then syslogd will be very
verbose by writing much of what it does on stdout. Whenever the con-
figuration file is reread and re-parsed you’ll see a tabular, corre-
sponding to the internal data structure. This tabular consists of four
fields:
number This field contains a serial number starting by zero. This num-
ber represents the position in the internal data structure (i.e.
the array). If one number is left out then there might be an
error in the corresponding line in /etc/syslog.conf.
pattern
This field is tricky and represents the internal structure
exactly. Every column stands for a facility (refer to sys-
log(3)). As you can see, there are still some facilities left
free for former use, only the left most are used. Every field
in a column represents the priorities (refer to syslog(3)).
action This field describes the particular action that takes place
whenever a message is received that matches the pattern. Refer
to the syslog.conf(5) manpage for all possible actions.
arguments
This field shows additional arguments to the actions in the last
field. For file-logging this is the filename for the logfile;
for user-logging this is a list of users; for remote logging
this is the hostname of the machine to log to; for console-log-
ging this is the used console; for tty-logging this is the spec-
ified tty; wall has no additional arguments.
阅读(14736) | 评论(0) | 转发(1) |