delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/08/06/07:26:30

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type:content-transfer-encoding; q=dns; s=
default; b=Sio28iTwrwTQzXxTji1hkzYNUzpNwJlfNxjRc1IHwLvfVFWnqoXnY
oO03D8W0KrLIrkgX1gl5LuTuZDD6KlRgC4W2pn1sP1yMYTFLyH9XsDOJjRy4/F0Z
xAe/bKJFiqpzFCbGcDGfW6ZXxRSzRGxs4c/mFsGW8F4cW16nKZfxT4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type:content-transfer-encoding; s=default;
bh=qPI7ECVuZKAPil/RqGNphIac3+4=; b=gjAhnT9bwzPFmtkjUlk0V70O28Qk
E1ZaNADmKGYusG9A59y0QwRUjU8GhSvmQvGygUBWuyOAaNOKsA64mF/fxFYYXwgJ
lpqyVfGEgaGd9xDbGBWYismWGc9pln7ZBAm6sSlkEh7zBl+TXvSejzqfXUmwBAh+
VpmPy1iOaeI5YvA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: plane.gmane.org
To: cygwin AT cygwin DOT com
From: "D. Boland" <daniel AT boland DOT nl>
Subject: Re: syslog function: Bad file descriptor
Date: Wed, 06 Aug 2014 13:30:37 +0200
Lines: 79
Message-ID: <53E211DD.12F8D5C8@boland.nl>
References: <53E10628 DOT 3C42FD6F AT boland DOT nl> <20140805164842 DOT GA13601 AT calimero DOT vinschen DOT de> <53E117B7 DOT 4C81186A AT boland DOT nl> <20140805190014 DOT GD13601 AT calimero DOT vinschen DOT de> <53E13FFE DOT E7A33C0D AT boland DOT nl> <20140806091941 DOT GK13601 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
X-IsSubscribed: yes

Hi Corinna,

Corinna Vinschen wrote:
> 
> On Aug  5 22:35, D. Boland wrote:
> > Corinna Vinschen wrote:
> > >
> > > Can you produce another strace for the overwriting case (non-R/O aliases)
> > > for comparison?  Also, can you do the same strace with no syslogd running?
> > >
> > > It might be necessary to create a few test versions of Cygwin with more
> > > debug output, but let's please see these straces first.
> >
> > I attached all three of them in a zipped file.
> 
> Thanks.  I got it now.  AFAICS it's a bug in sendmail.  Take a look
> into your newaliases.strace.txt file.  Start at line 260 (stripping
> off timestamp, thread and process info):
> 
>   260:  normalize_posix_path: src /dev/log
> 
> Here the syslog() function tries to open a connection to a syslogd
> listening on /dev/log.
> 
>   282:  cygwin_socket: 3 = socket(1, 2 (flags 0x0), 0)
> 
> Socket created, file descriptor is 3.
> 
>   296:  connect_syslogd: found /dev/log, fd = 3, type = DGRAM
> 
> Yes, there's a listener on /dev/log.  Now Cygwin stores the info that fd
> 3 is the connection to the syslog daemon.
> 
>   332:  close: close(3)
> 
> And at line 332, a file descriptor close orgy starts.  sendmail closes
> all descriptors from 3 to 255.  This obviously closes fd 3, but how's
> Cygwin's syslog() function to know?
> 
>  2263:  open: 3 = open(/etc/mail/aliases, 0x8000)
> 
> Uh oh!  Now fd 3 is reused for the aliases file.  Things certainly go
> downhill.
> 
>  2651:  writev: -1 = writev(3, 0x2287F0, 2), errno 9
> 
> This is syslog trying to write the log to the descriptor it knows
> is connected to /dev/log.  Fortunately the aliases file is R/O at
> this point, but it's pretty much working as designed.  Syslog()
> doesn't know the application broke its connection to the syslog
> daemon.  It dutyfully writes to the syslog descriptor it knows
> about.
> 
> As for using a file descriptor inside of syslog, that's perfectly
> valid behaviour, see
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/closelog.html:
> 
>   "The openlog() and syslog() functions may allocate a file descriptor."
> 
> Without looking into the sources, I'd assume there's a closelog()
> call missing prior to the descriptor close orgy.  This closelog()
> call should fix the problem.

It is exactly as you say. I found the close() orgy and put a closelog() prior to it.
Now it works perfectly without corrupting the aliases file (writable to sendmail).

I'm asking myself if this closing of 253 file descriptors is a sensible thing to do.
What would Sendmail be trying to accomplish there? It comments "Be shure we have
enough file descriptors". And: "in 4.4BSD, the table ([of fd's]) can be huge; impose
a reasonable limit". Bizarre.

Could it be that incoming e-mail is such a volatile process that previous opened
file descriptors are not closed quick enough? This feels like a crude hack.

Can you give your opinion on this?

Thanks for the quick response & the time you put into this.

Daniel


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019