From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14329 invoked from network); 6 Nov 2020 21:44:36 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 6 Nov 2020 21:44:36 -0000 Received: (qmail 4090 invoked by uid 550); 6 Nov 2020 21:44:34 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 4064 invoked from network); 6 Nov 2020 21:44:33 -0000 Date: Fri, 6 Nov 2020 16:44:20 -0500 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20201106214420.GZ534@brightrain.aerifal.cx> References: <20201106193050.GB2009@voyager> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201106193050.GB2009@voyager> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Why connect() in syslog? On Fri, Nov 06, 2020 at 08:30:50PM +0100, Markus Wichmann wrote: > Hi all, > > I was reading musl's syslog source code today for unrelated reasons, and > saw that it is using connect() to set the destination. And it has some > code to deal with connection failures. But why? I see the syslog socket > is a datagram socket, so I thought sendto() with destination address > means the same thing as connect() and send(), with the difference that > it is one less syscall that can fail and no connection errors to handle. > I tried finding information about the semantics of connect() on a UNIX > datagram socket, but failed to find anything useful. It's there so the process can chroot, move into a namespace/container, etc. after calling openlog without losing the ability to do logging. Rich