[PATCH] Fix bug #9166 - Starting smbd or nmbd with stdin from /dev/null results in "EOF on stdin"
jra at samba.org
Wed Jun 19 11:39:15 MDT 2013
On Thu, Jun 20, 2013 at 03:24:24AM +1000, Andrew Bartlett wrote:
> On Wed, 2013-06-19 at 09:23 -0700, Jeremy Allison wrote:
> > On Wed, Jun 19, 2013 at 01:52:43PM +1000, Andrew Bartlett wrote:
> > > On Tue, 2013-06-18 at 11:18 -0700, Jeremy Allison wrote:
> > > > OEM confirms this fixes the issue for them.
> > > >
> > > > Please review and push if you're ok with it.
> > >
> > > The source4/smbd/server.c patch seems to be missing an fstat call.
> > Ok I'll add that. Was fixing nmbd/winbindd/smbd initially.
> > > Also, what happens if the fd is not a file, but a socket or a pipe?
> > That's what the patch does - when it's a socket or pipe
> > the stdin handler is added, not otherwise.
> What made me ask that is that I wondered: does fstat() work for all
> possible inputs here? I could imagine that for those, it could fail due
> to them not being file system FDs (eg from pipe()).
> I'm guessing it works (at least on Linux), as otherwise make test should
> fail spectacularly, but that's what prompted the query. I note our
> 'is_a_socket()' function operates quite differently, instead trying a
> socket call.
According to the open group:
fstat produces a valid st_mode for all types. Note that there is
no valid error code available to return for an fstat on a pipe
(EBADF/EBADFD don't fit as it's a valid fd). So I think this is
pretty safe on all the platforms we run on.
More information about the samba-technical