]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Replace call to close_low_fds() with direct calls
authorVolker Lendecke <vl@samba.org>
Fri, 23 Apr 2021 14:31:08 +0000 (16:31 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 27 Apr 2021 13:24:35 +0000 (13:24 +0000)
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 <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/smbd/server.c

index 45192464717d5f743b09203a2c17feff3818354c..468bd21cf75400beb1fe6cbbf6df51899f94d59f 100644 (file)
@@ -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);