[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for glibc 2.3.2 misc/syslog.c

From: Bjorn Andersson
Subject: Patch for glibc 2.3.2 misc/syslog.c
Date: Mon, 1 Dec 2003 16:27:38 +0200


I think there are two bugs in misc/syslog.c:

1) syslog first tries to create a UNIX datagram socket. If connect()
fails with EPROTOTYPE it will try again with a stream socket.
If the stream socket fails later on, the datagram socket will not be
retried, and logging will never succeed. I discovered this problem
on RedHat while restarting syslogd while another program was logging
using syslog(). Logging stopped completely. The following describes
the problem sequence:
- syslogd is started
- the program, progfoobar, logs to syslog
- progfoobar/syslog() successfully connects to a datagram socket on /dev/log
- syslogd is stopped with RedHat's /etc/init.d/syslog script
- syslogd exits and removes /dev/log
- /etc/init.d/syslog calls the program initlog
- initlog notices that /dev/log does not exist and forks minilogd
- minilogd creates a stream socket on /dev/log
- progfoobar tries to log with syslog(), but syslog receives EPROTOTYPE
  and opens a stream socket. This succeeds.
- minilogd exits
- progfoobar logs again and syslog receives SIGPIPE.
- syslogd is started, which creates a datagram socket on /dev/log
- progfoobar tries to log, and syslog tries to connect() with a stream
  socket, which fails with EPROTOTYPE. A datagram socket is never

Attached a filtered strace demonstrating the problem.

2) While looking at misc/syslog.c it looks to me as if the old errno
value is not restored if connect() fails for any other reason than
EPROTOTYPE and only when LogType is SOCK_DGRAM. This is probably a bug?

Attached is a patch against glibc 2.3.2 solving both problems. Note
however that the patch has not been tested.

Bjorn Andersson <address@hidden>
PGP id 5AFC144B
Mobile +358 40 7723074

Attachment: syslog.strace
Description: Text document

Attachment: syslog.c.patch
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]