From d4091c5809f174b68714fa50fa501c99617c016e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Jun 2013 13:33:40 -0700 Subject: Fix bug #9166 - Starting smbd or nmbd with stdin from /dev/null results in "EOF on stdin" Only install the stdin handler if it's a pipe or fifo. Signed-off-by: Jeremy Allison Reviewed-by: Andrew Bartlett --- source3/nmbd/nmbd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source3/nmbd') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 12afb00993..42e2b2f6ff 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -130,8 +130,20 @@ static bool nmbd_setup_stdin_handler(struct messaging_context *msg, bool foregro /* if we are running in the foreground then look for EOF on stdin, and exit if it happens. This allows us to die if the parent process dies + Only do this on a pipe or socket, no other device. */ - tevent_add_fd(nmbd_event_context(), nmbd_event_context(), 0, TEVENT_FD_READ, nmbd_stdin_handler, msg); + struct stat st; + if (fstat(0, &st) != 0) { + return false; + } + if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { + tevent_add_fd(nmbd_event_context(), + nmbd_event_context(), + 0, + TEVENT_FD_READ, + nmbd_stdin_handler, + msg); + } } return true; -- cgit