This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: syslog function: Bad file descriptor


On Aug  6 13:30, D. Boland wrote:
> 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):
> > [...]
> > 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).

Nice.

> 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.

I think this is really old stuff, in the sense that this method has been
used on UNIXoid systems for ages.  It depends on how many open fds
sendmail inherited from its parent process (once typically an rc shell
script) which was questionable back in the days sendmail was young I
guess, and if sendmail forks/execs, it's a way to disallow arbitrary fds
inheritance by the child.

> 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.

Sendmail is not the only one doing this.  There's similar code in
tcsh, for instance, but tcsh doesn't call syslog.  The bug here seems
to be an upstream bug which just hasn't been catched yet because
syslog() works somewhat differently on other systems and hide their
file descriptor usage somehow.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpGQ9a76s8pO.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]