s3: smbd: Cleanup - don't set the FLAGS2_DFS_PATHNAMES in flags2 in the glue struct...
[Samba.git] / source3 / smbd / smb2_glue.c
blob543c0a0b9e6b1d444548da9a4e826eb1c9dc95b9
1 /*
2 Unix SMB/CIFS implementation.
3 Core SMB2 server
5 Copyright (C) Stefan Metzmacher 2009
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "smbd/smbd.h"
23 #include "smbd/globals.h"
24 #include "../libcli/smb/smb_common.h"
26 #undef DBGC_CLASS
27 #define DBGC_CLASS DBGC_SMB2
29 struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
31 struct smb_request *smbreq;
32 const uint8_t *inhdr = SMBD_SMB2_IN_HDR_PTR(req);
34 if (req->smb1req) {
35 smbreq = req->smb1req;
36 } else {
37 smbreq = talloc_zero(req, struct smb_request);
38 if (smbreq == NULL) {
39 return NULL;
43 smbreq->request_time = req->request_time;
44 if (req->session != NULL) {
45 smbreq->vuid = req->session->global->session_wire_id;
47 if (req->tcon != NULL) {
48 smbreq->tid = req->tcon->compat->cnum;
49 smbreq->conn = req->tcon->compat;
51 smbreq->sconn = req->sconn;
52 smbreq->xconn = req->xconn;
53 smbreq->session = req->session;
54 smbreq->smbpid = (uint16_t)IVAL(inhdr, SMB2_HDR_PID);
55 smbreq->flags2 = FLAGS2_UNICODE_STRINGS |
56 FLAGS2_32_BIT_ERROR_CODES |
57 FLAGS2_LONG_PATH_COMPONENTS |
58 FLAGS2_IS_LONG_NAME;
60 /* Only set FLAGS2_DFS_PATHNAMES if it's really a DFS share */
61 if (smbreq->conn != NULL &&
62 lp_host_msdfs() &&
63 lp_msdfs_root(SNUM(smbreq->conn))) {
64 if (IVAL(inhdr, SMB2_HDR_FLAGS) & SMB2_HDR_FLAG_DFS) {
65 smbreq->flags2 |= FLAGS2_DFS_PATHNAMES;
68 smbreq->mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID);
69 smbreq->chain_fsp = req->compat_chain_fsp;
70 smbreq->smb2req = req;
71 req->smb1req = smbreq;
73 return smbreq;
76 /*********************************************************
77 Are there unread bytes for recvfile ?
78 *********************************************************/
80 size_t smbd_smb2_unread_bytes(struct smbd_smb2_request *req)
82 if (req->smb1req) {
83 return req->smb1req->unread_bytes;
85 return 0;
88 /*********************************************************
89 Called from file_free() to remove any chained fsp pointers.
90 *********************************************************/
92 void remove_smb2_chained_fsp(files_struct *fsp)
94 struct smbd_server_connection *sconn = fsp->conn->sconn;
95 struct smbXsrv_connection *xconn = NULL;
97 if (sconn->client != NULL) {
98 xconn = sconn->client->connections;
101 for (; xconn != NULL; xconn = xconn->next) {
102 struct smbd_smb2_request *smb2req;
104 for (smb2req = xconn->smb2.requests; smb2req; smb2req = smb2req->next) {
105 if (smb2req->compat_chain_fsp == fsp) {
106 smb2req->compat_chain_fsp = NULL;
108 if (smb2req->smb1req && smb2req->smb1req->chain_fsp == fsp) {
109 smb2req->smb1req->chain_fsp = NULL;