mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Laurent Bercot" <ska-dietlibc@skarnet.org>
To: musl@lists.openwall.com
Subject: Re: Add SOCK_STREAM support for syslog
Date: Sat, 11 Nov 2017 01:29:06 +0000	[thread overview]
Message-ID: <emb4563acc-aeee-49da-9e9a-bbb48d323025@elzian> (raw)
In-Reply-To: <20171111004131.GU1627@brightrain.aerifal.cx>

>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



      reply	other threads:[~2017-11-11  1:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 13:17 Jan Horstmann
2017-11-10 14:07 ` Szabolcs Nagy
2017-11-10 17:14   ` Rich Felker
2017-11-11  0:29     ` Laurent Bercot
2017-11-11  0:41       ` Rich Felker
2017-11-11  1:29         ` Laurent Bercot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=emb4563acc-aeee-49da-9e9a-bbb48d323025@elzian \
    --to=ska-dietlibc@skarnet.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).