From nobody Fri Dec 31 18:09:19 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 084B419236E3; Fri, 31 Dec 2021 18:09:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JQY7M57hCz3j0g; Fri, 31 Dec 2021 18:09:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3EA921059A; Fri, 31 Dec 2021 18:09:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BVI9JdE035154; Fri, 31 Dec 2021 18:09:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BVI9Jjt035153; Fri, 31 Dec 2021 18:09:19 GMT (envelope-from git) Date: Fri, 31 Dec 2021 18:09:19 GMT Message-Id: <202112311809.1BVI9Jjt035153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 881059955a5d - main - libc: Some enhancements to syslog(3) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 881059955a5d83fc173f40f266d93ddd91255291 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640974159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kOBF8CKL/nMQSIH9VwL5M0sLi6a4Fs+dHo6Iba0zyAE=; b=KUT6RvTcz2vmRfvY3lbM/ditLhm+Svy9878NEpWG4cBngfK6wflK9Ah72X1V5lcAUpNjYq dNp88hdacK9jaGAu1ClvJbh0eLjOU01jPvaVYq+J0Xfs44tJo63DVpzoJjL4lPA/dtgnm6 e5eDpQJ/R6n0z4ONs/ITjS3h8Ce9TRoplKCK78sRLZrdAZ4jc2Aszwmz61FakgxU3N39x/ 3OYiT3nrs2qep9j7qDcF0gsSxE8mPLrFipMb/IyYeaQnp4UbFfZeCoatVxdq6xN4jzSPf9 2Y1zlgKC674urocRzUP1hUxNWqsmjAu5f7k4u5YeR4ofxNDbQlNlpbJS2B/rtA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640974159; a=rsa-sha256; cv=none; b=I1jhMnAlRyD6SiCjEHCte7Ka25JUtzBSt7NgLfYzd9LwOd+m04mG+LWX+uhKybTsbgcEpb J8Rwejcz+oS1YnYSnOfvp2hedSq7OU6P2rBaPbtTxWuUnzpNQqJTXX3jQxmGlaRU3snB/4 dn/4+wBcAIwRI9qfQTDUbF6vERsaU7GMsiTDUj6rQHRI89hfhbQrdm0sH/WxTRXNjrxhHy gS+ekJZckHiwDbShHv/Prfbe6HTpEWkcjsICKIW7UuM5ac+MSuojdtF2oLU1qot++fw2oe 5UB5pUBGJ8gcn7WqtVw6BGd/kz/n6GC/SkV+u4P+87dZTmhayePO+sLFTMYAyQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=881059955a5d83fc173f40f266d93ddd91255291 commit 881059955a5d83fc173f40f266d93ddd91255291 Author: Dmitry Wagin AuthorDate: 2021-03-23 16:01:15 +0000 Commit: Mark Johnston CommitDate: 2021-12-31 17:57:01 +0000 libc: Some enhancements to syslog(3) This is a re-application of commit 2d82b47a5b4ef18550565dd55628d51f54d0af2e, which was reverted since it broke with syslog daemons that don't adjust the /dev/log recv buffer size. Now that the default is large enough to accomodate 8KB messages, restore support for large messages. PR: 260126 --- lib/libc/gen/syslog.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 19d44db0075a..797c7389d1a2 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -57,6 +57,9 @@ __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() */ @@ -141,7 +144,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[2048], fmt_cpy[1024], + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[MAXLINE], fmt_cpy[MAXLINE], errstr[64], tz_sign; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; @@ -396,9 +399,19 @@ 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);