From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12086 Path: news.gmane.org!.POSTED!not-for-mail From: "Laurent Bercot" Newsgroups: gmane.linux.lib.musl.general Subject: Re: Add SOCK_STREAM support for syslog Date: Sat, 11 Nov 2017 01:29:06 +0000 Message-ID: References: <1510319851.23177.3.camel@mittwald.de> <20171110140749.GC15263@port70.net> <20171110171406.GQ1627@brightrain.aerifal.cx> <20171111004131.GU1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1510363759 28460 195.159.176.226 (11 Nov 2017 01:29:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Nov 2017 01:29:19 +0000 (UTC) User-Agent: eM_Client/7.1.30794.0 To: musl@lists.openwall.com Original-X-From: musl-return-12102-gllmg-musl=m.gmane.org@lists.openwall.com Sat Nov 11 02:29:15 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eDKbh-00077t-0Y for gllmg-musl@m.gmane.org; Sat, 11 Nov 2017 02:29:13 +0100 Original-Received: (qmail 26560 invoked by uid 550); 11 Nov 2017 01:29:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 26533 invoked from network); 11 Nov 2017 01:29:17 -0000 In-Reply-To: <20171111004131.GU1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12086 Archived-At: >If your primary goal is that no log data be lost, blocking SOCK_STREAM >might be preferable to you. Generally I consider "critical services >can't get delayed or deadlocked because of a problem with the logging >system" as a higher priority requirement. If you can't ssh in to fix a >problem because sshd is blocking in syslog() when you connect, you >have a big problem. But how can you tell the difference? The syslog() API does not allow a process to specify what policy it wants: block or drop logs. Relying on a system-wide setting, and an obscure one as that (is /dev/log SOCK_STREAM or SOCK_DGRAM?), is a terrible way to implement that policy. The right thing in this case is to always do the reliable thing by default (don't drop data), and if a process cannot afford to block when logging, then it should be using other mechanisms to log. Like, for instance, writing to a non-blocking file descriptor, with a call to poll() beforehand and giving up after some timeout. syslog() is just the wrong API for this. (It's the wrong API for pretty much everything.) skarnet.org programs always give the user an option to time out when they may block. It's the only way to be safe. If sshd does not do this, it's a design failure. >Datagram send succeeds or fails atomically -- either the full packet >is sent or nothing is. This is a good argument, but is only as important as the integrity of records. Between losing an entire log line and conflating a partial one with the next, I'm not sure what's worse; syslog data is text, which is easily recoverable, and it can be argued that some info is better than no info. it is, again, a policy decision, one that the libc shouldn't have to make. >Datagram sockets are also nicer from a standpoint of being able to >restart the logging daemon while there are chrooted clients. As long >as a supervisor owns the socket and keeps it open, it just works to >kill the logging daemon and start a new one receiving on the socket. >But with streams, the logging daemon has to accept connections, and >there's no simple way to hand them off to a new/restarted daemon. And >if you can't do that, you cut off logging in all chrooted clients when >restarting the logging daemon. This implies a monolithic syslogd. My argument for SOCK_STREAM is precisely that it allows syslogd to be implemented via a super-server, inetd-like, with a "syslogd" program only handling one client connection; in that case you can easily restart the server without impacting existing clients. And to me, doing away with a monolithic syslogd is the whole point of using SOCK_STREAM, so this argument holds no water. -- Laurent