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 08/06/2014 05:30 AM, D. Boland wrote:

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

Maybe.  There's two schools of thoughts about preventing unintended
actions due to accidentally leaked fds: 1. any time a parent forks an
unknown child, the parent does an orgy close() between fork() and exec()
so that the child starts life clean. 2. any time a child starts from an
unknown parent, the child starts with an orgy close() to ensure it
starts life clean.  [More recently, there is the addition of O_CLOEXEC
to open() and other APIs to allow atomic FD_CLOEXEC setting, and then
you can avoid the orgy close() in style 1; but that still doesn't stop
style 2 paranoid children]

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

Other programs that I know do an orgy close() on startup: bash, tcsh.
So it's not uncommon.  But if you do it first, it MUST be first - before
you open any fds that must not be accidentally closed.  sendmail is
indeed buggy for trying to use syslog() (which uses an fd) prior to
doing the orgy close.

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

Just because the problem hasn't tripped other platforms does not make it
any less of an upstream sendmail bug.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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