From 8728bf91471fe044c989b2c8eaf9f5945f347b9b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 23 Apr 2021 16:31:08 +0200 Subject: [PATCH] smbd: Replace call to close_low_fds() with direct calls Check the errors from close_low_fd(). Also, close_low_fds() does not really add a lot of value, for example there's no caller that closes stderr. Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- source3/smbd/server.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 45192464717..468bd21cf75 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -24,6 +24,7 @@ #include "includes.h" #include "system/filesys.h" #include "lib/util/server_id.h" +#include "lib/util/close_low_fd.h" #include "popt_common.h" #include "locking/share_mode_lock.h" #include "smbd/smbd.h" @@ -2159,7 +2160,7 @@ extern void build_options(bool screen); } if (!is_daemon) { - int sock; + int ret, sock; /* inetd mode */ TALLOC_FREE(frame); @@ -2170,7 +2171,19 @@ extern void build_options(bool screen); sock = dup(0); /* close stdin, stdout (if not logging to it), but not stderr */ - close_low_fds(true, !debug_get_output_is_stdout(), false); + ret = close_low_fd(0); + if (ret != 0) { + DBG_ERR("close_low_fd(0) failed: %s\n", strerror(ret)); + return 1; + } + if (!debug_get_output_is_stdout()) { + ret = close_low_fd(1); + if (ret != 0) { + DBG_ERR("close_low_fd(1) failed: %s\n", + strerror(ret)); + return 1; + } + } #ifdef HAVE_ATEXIT atexit(killkids); -- 2.47.3