aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2021-11-30 17:06:25 +0000
committerAlan Somers <asomers@FreeBSD.org>2021-11-30 18:11:43 +0000
commit943c446629e33739d3f72795069a5c944e8f329e (patch)
tree39cbe4eac3d3a81f91ad877571efcd6ed2daf1e3
parent10041e99a0c29c9f99c4148fc173bb12dd26aa8d (diff)
downloadsrc-943c446629e33739d3f72795069a5c944e8f329e.tar.gz
src-943c446629e33739d3f72795069a5c944e8f329e.zip
Revert "libc: Some enhancements to syslog(3)"
This reverts commit 2886c93d1bca231260ebc01d4205743ca781f3c7. The original commit has two problems: * It sets SO_SNDBUF to be as large as MAXLINE. But for unix domain sockets, the send buffer is bypassed. Packets go directly to the peer's receive buffer, so setting and querying SO_SNDBUF is ineffective. To ensure that the socket can accept messages of a certain size, it would be necessary to add a SO_PEERRCVBUF socket option that could query the connected peer's receive buffer size. * It sets MAXLINE to 8 kB, which is larger than the default sockbuf size of 4 kB. That's ok for the builtin syslogd, which sets its recvbuf to 80 kB, but not ok for alternative sysloggers, like rsyslogd, which use the default size. As a consequence, writing messages of more than 4 kB with syslog() as a non-root user while running rsyslogd would cause the logging application to spin indefinitely within syslog(). PR: 260126 MFC: 2 weeks Sponsored by: Axcient Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D33199
-rw-r--r--lib/libc/gen/syslog.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 797c7389d1a2..19d44db0075a 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
-/* Maximum number of characters of syslog message */
-#define MAXLINE 8192
-
static int LogFile = -1; /* fd for log */
static int status; /* connection status */
static int opened; /* have done openlog() */
@@ -144,7 +141,7 @@ vsyslog1(int pri, const char *fmt, va_list ap)
char ch, *p;
long tz_offset;
int cnt, fd, saved_errno;
- char hostname[MAXHOSTNAMELEN], *stdp, tbuf[MAXLINE], fmt_cpy[MAXLINE],
+ char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024],
errstr[64], tz_sign;
FILE *fp, *fmt_fp;
struct bufcookie tbuf_cookie;
@@ -399,19 +396,9 @@ connectlog(void)
struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
if (LogFile == -1) {
- socklen_t len;
-
if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC,
0)) == -1)
return;
- if (_getsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, &len,
- &(socklen_t){sizeof(len)}) == 0) {
- if (len < MAXLINE) {
- len = MAXLINE;
- (void)_setsockopt(LogFile, SOL_SOCKET, SO_SNDBUF,
- &len, sizeof(len));
- }
- }
}
if (LogFile != -1 && status == NOCONN) {
SyslogAddr.sun_len = sizeof(SyslogAddr);