summaryrefslogtreecommitdiff
path: root/source4/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-06-10 13:33:40 -0700
committerAndrew Bartlett <abartlet@samba.org>2013-06-20 13:41:01 +0200
commitd4091c5809f174b68714fa50fa501c99617c016e (patch)
treebf22be9374d71080945945dc914548a39e57c560 /source4/smbd
parentfc13489c91e790ff8952aff1e7db1e6189894e30 (diff)
downloadsamba-d4091c5809f174b68714fa50fa501c99617c016e.tar.gz
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> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/smbd')
-rw-r--r--source4/smbd/server.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 5fb252e93d2..0ad3e6ba415 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,19 @@ 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 (fstat(0, &st) != 0) {
+ exit(1);
+ }
+
+ 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",