s3:smbd: add smbd_smb2_fake_smb_request()
authorStefan Metzmacher <metze@samba.org>
Tue, 2 Jun 2009 09:54:00 +0000 (11:54 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Jun 2009 15:54:39 +0000 (17:54 +0200)
metze

source3/Makefile.in
source3/smbd/globals.h
source3/smbd/smb2_glue.c [new file with mode: 0644]

index e82a0aff35cda9f78ce3a1bd4835cf4b31fb4249..eb3761d49c62c060c7bba0a193f77af7713650d4 100644 (file)
@@ -751,7 +751,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
               smbd/file_access.o \
               smbd/dnsregister.o smbd/globals.o \
               smbd/smb2_server.o smbd/smb2_negprot.o \
-              smbd/smb2_sesssetup.o smbd/smb2_tcon.o \
+              smbd/smb2_sesssetup.o smbd/smb2_tcon.o smbd/smb2_glue.o \
               smbd/smb2_keepalive.o smbd/smb2_signing.o \
               $(MANGLE_OBJ) @VFS_STATIC@
 
index e8821d71a4b855af5057b07cee49b6c7d89aaeca..6cf5439a3fa30ac5a320fd51b623b8e743d8175d 100644 (file)
@@ -189,6 +189,8 @@ NTSTATUS smbd_smb2_request_done(struct smbd_smb2_request *req,
 NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req);
 NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req);
 
+struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req);
+
 NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req);
 NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *req);
 NTSTATUS smbd_smb2_request_process_logoff(struct smbd_smb2_request *req);
diff --git a/source3/smbd/smb2_glue.c b/source3/smbd/smb2_glue.c
new file mode 100644 (file)
index 0000000..c3c3854
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+   Unix SMB/CIFS implementation.
+   Core SMB2 server
+
+   Copyright (C) Stefan Metzmacher 2009
+
+   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 "smbd/globals.h"
+#include "../source4/libcli/smb2/smb2_constants.h"
+
+struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
+{
+       struct smb_request *smbreq;
+       const uint8_t *inhdr;
+       int i = req->current_idx;
+
+       inhdr = (const uint8_t *)req->in.vector[i+0].iov_base;
+
+       smbreq = talloc_zero(req, struct smb_request);
+       if (smbreq == NULL) {
+               return NULL;
+       }
+
+       smbreq->vuid = req->session->compat_vuser->vuid;
+       smbreq->tid = req->tcon->compat_conn->cnum;
+       smbreq->conn = req->tcon->compat_conn;
+       smbreq->smbpid = (uint16_t)IVAL(inhdr, SMB2_HDR_PID);
+       smbreq->flags2 = FLAGS2_UNICODE_STRINGS |
+                        FLAGS2_32_BIT_ERROR_CODES |
+                        FLAGS2_LONG_PATH_COMPONENTS |
+                        FLAGS2_IS_LONG_NAME;
+       if (IVAL(inhdr, SMB2_HDR_FLAGS) & SMB2_HDR_FLAG_DFS) {
+               smbreq->flags2 |= FLAGS2_DFS_PATHNAMES;
+       }
+
+       return smbreq;
+}