]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move srv_send_smb/smb2_srv_send to smb2_process.c
authorDavid Mulder <dmulder@suse.com>
Fri, 18 Mar 2022 14:22:31 +0000 (08:22 -0600)
committerJeremy Allison <jra@samba.org>
Thu, 7 Apr 2022 17:37:29 +0000 (17:37 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/smb2_process.c [new file with mode: 0644]
source3/wscript_build

index b56fb4fa6599a67c8d9514d7bf0014dfa626e0c7..93afe531856bf47bd2bb525d454196defc7a00ef 100644 (file)
@@ -281,65 +281,6 @@ out:
        return (ret > 0);
 }
 
-#if !defined(WITH_SMB1SERVER)
-static bool smb2_srv_send(struct smbXsrv_connection *xconn, char *buffer,
-                         bool do_signing, uint32_t seqnum,
-                         bool do_encrypt,
-                         struct smb_perfcount_data *pcd)
-{
-       size_t len = 0;
-       ssize_t ret;
-       char *buf_out = buffer;
-
-       if (!NT_STATUS_IS_OK(xconn->transport.status)) {
-               /*
-                * we're not supposed to do any io
-                */
-               return true;
-       }
-
-       len = smb_len_large(buf_out) + 4;
-
-       ret = write_data(xconn->transport.sock, buf_out, len);
-       if (ret <= 0) {
-               int saved_errno = errno;
-               /*
-                * Try and give an error message saying what
-                * client failed.
-                */
-               DEBUG(1,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
-                        (int)getpid(), (int)len,
-                        smbXsrv_connection_dbg(xconn),
-                        (int)ret, strerror(saved_errno)));
-               errno = saved_errno;
-
-               srv_free_enc_buffer(xconn, buf_out);
-               goto out;
-       }
-
-       SMB_PERFCOUNT_SET_MSGLEN_OUT(pcd, len);
-       srv_free_enc_buffer(xconn, buf_out);
-out:
-       SMB_PERFCOUNT_END(pcd);
-
-       return (ret > 0);
-}
-#endif
-
-bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
-                 bool do_signing, uint32_t seqnum,
-                 bool do_encrypt,
-                 struct smb_perfcount_data *pcd)
-{
-#if !defined(WITH_SMB1SERVER)
-       return smb2_srv_send(xconn, buffer, do_signing, seqnum,
-                            do_encrypt, pcd);
-#else
-       return smb1_srv_send(xconn, buffer, do_signing, seqnum,
-                            do_encrypt, pcd);
-#endif
-}
-
 /*******************************************************************
  Setup the word count and byte count for a smb message.
 ********************************************************************/
index 109c5596f38c20e6f07ba635d69c0b29adf1c57a..cc4efe52672ad2235f5e8537d1704655af06fc4c 100644 (file)
@@ -848,10 +848,6 @@ NTSTATUS make_default_filesystem_acl(
 
 /* The following definitions come from smbd/process.c  */
 
-bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
-                 bool no_signing, uint32_t seqnum,
-                 bool do_encrypt,
-                 struct smb_perfcount_data *pcd);
 bool smb1_srv_send(struct smbXsrv_connection *xconn, char *buffer,
                   bool do_signing, uint32_t seqnum,
                   bool do_encrypt,
@@ -898,6 +894,13 @@ void smbd_process(struct tevent_context *ev_ctx,
                  bool interactive);
 bool fork_echo_handler(struct smbXsrv_connection *xconn);
 
+/* The following definitions come from smbd/smb2_process.c  */
+
+bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
+                 bool no_signing, uint32_t seqnum,
+                 bool do_encrypt,
+                 struct smb_perfcount_data *pcd);
+
 /* The following definitions come from smbd/quotas.c  */
 
 bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c
new file mode 100644 (file)
index 0000000..030b614
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+   Unix SMB/CIFS implementation.
+   process incoming packets - main loop
+   Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Volker Lendecke 2005-2007
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../lib/tsocket/tsocket.h"
+#include "system/filesys.h"
+#include "smbd/smbd.h"
+#include "smbd/globals.h"
+#include "smbd/smbXsrv_open.h"
+#include "librpc/gen_ndr/netlogon.h"
+#include "../lib/async_req/async_sock.h"
+#include "ctdbd_conn.h"
+#include "../lib/util/select.h"
+#include "printing/queue_process.h"
+#include "system/select.h"
+#include "passdb.h"
+#include "auth.h"
+#include "messages.h"
+#include "lib/messages_ctdb.h"
+#include "smbprofile.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "../libcli/security/dom_sid.h"
+#include "../libcli/security/security_token.h"
+#include "lib/id_cache.h"
+#include "lib/util/sys_rw_data.h"
+#include "system/threads.h"
+#include "lib/pthreadpool/pthreadpool_tevent.h"
+#include "util_event.h"
+#include "libcli/smb/smbXcli_base.h"
+#include "lib/util/time_basic.h"
+#include "smb1_utils.h"
+#include "source3/lib/substitute.h"
+
+#if !defined(WITH_SMB1SERVER)
+static bool smb2_srv_send(struct smbXsrv_connection *xconn, char *buffer,
+                         bool do_signing, uint32_t seqnum,
+                         bool do_encrypt,
+                         struct smb_perfcount_data *pcd)
+{
+       size_t len = 0;
+       ssize_t ret;
+       char *buf_out = buffer;
+
+       if (!NT_STATUS_IS_OK(xconn->transport.status)) {
+               /*
+                * we're not supposed to do any io
+                */
+               return true;
+       }
+
+       len = smb_len_large(buf_out) + 4;
+
+       ret = write_data(xconn->transport.sock, buf_out, len);
+       if (ret <= 0) {
+               int saved_errno = errno;
+               /*
+                * Try and give an error message saying what
+                * client failed.
+                */
+               DEBUG(1,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
+                        (int)getpid(), (int)len,
+                        smbXsrv_connection_dbg(xconn),
+                        (int)ret, strerror(saved_errno)));
+               errno = saved_errno;
+
+               srv_free_enc_buffer(xconn, buf_out);
+               goto out;
+       }
+
+       SMB_PERFCOUNT_SET_MSGLEN_OUT(pcd, len);
+       srv_free_enc_buffer(xconn, buf_out);
+out:
+       SMB_PERFCOUNT_END(pcd);
+
+       return (ret > 0);
+}
+#endif
+
+bool srv_send_smb(struct smbXsrv_connection *xconn, char *buffer,
+                 bool do_signing, uint32_t seqnum,
+                 bool do_encrypt,
+                 struct smb_perfcount_data *pcd)
+{
+#if !defined(WITH_SMB1SERVER)
+       return smb2_srv_send(xconn, buffer, do_signing, seqnum,
+                            do_encrypt, pcd);
+#else
+       return smb1_srv_send(xconn, buffer, do_signing, seqnum,
+                            do_encrypt, pcd);
+#endif
+}
index fd1f852b995f8d103a5b37283cc0ef66c8e0abe0..e3f1fe01fb77e25c6ec91dcb776a13a688ea69e3 100644 (file)
@@ -650,6 +650,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
                           smbd/posix_acls.c
                           lib/sysacls.c
                           smbd/process.c
+                          smbd/smb2_process.c
                           smbd/smb2_service.c
                           smbd/error.c
                           printing/printspoolss.c