The Samba-Bugzilla – Attachment 9162 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]
Proposed patch for v4-0-test
0001-Fix-bug-9166-Starting-smbd-or-nmbd-with-stdin-from-d_v2.patch (text/plain), 5.74 KB, created by
Karolin Seeger
on 2013-08-27 07:33:43 UTC
(
hide
)
Description:
Proposed patch for v4-0-test
Filename:
MIME Type:
Creator:
Karolin Seeger
Created:
2013-08-27 07:33:43 UTC
Size:
5.74 KB
patch
obsolete
>From 7e20715a93b760ccb48269db6b83ae102ac26889 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Wed, 26 Sep 2012 16:53:48 -0700 >Subject: [PATCH 1/2] s3: Fix some blank line endings > >Autobuild-User(master): Volker Lendecke <vl@samba.org> >Autobuild-Date(master): Thu Sep 27 07:57:03 CEST 2012 on sn-devel-104 >(cherry picked from commit aad669b53eca99f86c2e630bf3f2e9f594fed9c1) >--- > source3/winbindd/winbindd.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c >index eab62a7..eba5b09 100644 >--- a/source3/winbindd/winbindd.c >+++ b/source3/winbindd/winbindd.c >@@ -1,4 +1,4 @@ >-/* >+/* > Unix SMB/CIFS implementation. > > Winbind daemon for ntdom nss module >@@ -216,7 +216,7 @@ static void winbindd_stdin_handler(struct tevent_context *ev, > char c; > if (read(0, &c, 1) != 1) { > bool *is_parent = talloc_get_type_abort(private_data, bool); >- >+ > /* we have reached EOF on stdin, which means the > parent has exited. Shutdown the server */ > DEBUG(0,("EOF on stdin (is_parent=%d)\n", >@@ -282,7 +282,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) > if (!is_parent) { > return false; > } >- >+ > *is_parent = parent; > > /* if we are running in the foreground then look for >@@ -291,7 +291,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) > */ > tevent_add_fd(winbind_event_context(), is_parent, 0, TEVENT_FD_READ, winbindd_stdin_handler, is_parent); > } >- >+ > return true; > } > >-- >1.7.10.4 > > >From 436c632125f45c5a844636e35caf2be0aa9f3019 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Mon, 10 Jun 2013 13:33:40 -0700 >Subject: [PATCH 2/2] 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 d4df202..196b582 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 e9bf9c9..a86fa48 100644 >--- a/source3/smbd/server.c >+++ b/source3/smbd/server.c >@@ -1561,8 +1561,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 eba5b09..21cc5f2 100644 >--- a/source3/winbindd/winbindd.c >+++ b/source3/winbindd/winbindd.c >@@ -278,6 +278,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; >@@ -288,8 +290,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 17b6ce5..8a9de48 100644 >--- a/source4/smbd/server.c >+++ b/source4/smbd/server.c >@@ -303,6 +303,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, >@@ -447,9 +448,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.7.10.4 >
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
Flags:
jra
:
review+
Actions:
View
Attachments on
bug 9166
:
8959
| 9162