The Samba-Bugzilla – Attachment 8959 Details for
Bug 9166
Starting smbd or nmbd with stdin from /dev/null results in "EOF on stdin"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am fix for master and 4.0.next.
0001-Fix-bug-9166-Starting-smbd-or-nmbd-with-stdin-from-d.patch (text/plain), 4.20 KB, created by
Jeremy Allison
on 2013-06-10 22:40:06 UTC
(
hide
)
Description:
git-am fix for master and 4.0.next.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2013-06-10 22:40:06 UTC
Size:
4.20 KB
patch
obsolete
>From 7a8227ee584814c1791edb22b2440283b31a7018 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Mon, 10 Jun 2013 13:33:40 -0700 >Subject: [PATCH] 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 <jra@samba.org> >--- > source3/nmbd/nmbd.c | 14 +++++++++++++- > source3/smbd/server.c | 14 +++++++++++++- > source3/winbindd/winbindd.c | 15 ++++++++++++++- > source4/smbd/server.c | 13 ++++++++++--- > 4 files changed, 50 insertions(+), 6 deletions(-) > >diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c >index 12afb00..42e2b2f 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; >diff --git a/source3/smbd/server.c b/source3/smbd/server.c >index f07bd28..d3cd33e 100644 >--- a/source3/smbd/server.c >+++ b/source3/smbd/server.c >@@ -1558,8 +1558,20 @@ extern void build_options(bool screen); > /* 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(ev_ctx, parent, 0, TEVENT_FD_READ, smbd_stdin_handler, NULL); >+ struct stat st; >+ if (fstat(0, &st) != 0) { >+ return false; >+ } >+ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { >+ tevent_add_fd(ev_ctx, >+ parent, >+ 0, >+ TEVENT_FD_READ, >+ smbd_stdin_handler, >+ NULL); >+ } > } > > smbd_parent_loop(ev_ctx, parent); >diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c >index 7a0700d..141ca5c 100644 >--- a/source3/winbindd/winbindd.c >+++ b/source3/winbindd/winbindd.c >@@ -308,6 +308,8 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) > bool *is_parent; > > if (foreground) { >+ struct stat st; >+ > is_parent = talloc(winbind_event_context(), bool); > if (!is_parent) { > return false; >@@ -318,8 +320,19 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) > /* 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(winbind_event_context(), is_parent, 0, TEVENT_FD_READ, winbindd_stdin_handler, is_parent); >+ if (fstat(0, &st) != 0) { >+ return false; >+ } >+ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { >+ tevent_add_fd(winbind_event_context(), >+ is_parent, >+ 0, >+ TEVENT_FD_READ, >+ winbindd_stdin_handler, >+ is_parent); >+ } > } > > return true; >diff --git a/source4/smbd/server.c b/source4/smbd/server.c >index 5fb252e..f6d65c7 100644 >--- a/source4/smbd/server.c >+++ b/source4/smbd/server.c >@@ -301,6 +301,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ > NTSTATUS status; > const char *model = "standard"; > int max_runtime = 0; >+ struct stat st; > enum { > OPT_DAEMON = 1000, > OPT_INTERACTIVE, >@@ -439,9 +440,15 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ > #ifdef SIGTTIN > signal(SIGTTIN, SIG_IGN); > #endif >- tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags, >- server_stdin_handler, >- discard_const(binary_name)); >+ >+ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { >+ tevent_add_fd(event_ctx, >+ event_ctx, >+ 0, >+ stdin_event_flags, >+ server_stdin_handler, >+ discard_const(binary_name)); >+ } > > if (max_runtime) { > DEBUG(0,("Called with maxruntime %d - current ts %llu\n", >-- >1.8.1.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 9166
: 8959 |
9162