Changeset 740 for vendor/current/source3/smbd/smb2_break.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified vendor/current/source3/smbd/smb2_break.c ¶
r414 r740 4 4 5 5 Copyright (C) Stefan Metzmacher 2009 6 Copyright (C) Jeremy Allison 2010 6 7 7 8 This program is free software; you can redistribute it and/or modify … … 20 21 21 22 #include "includes.h" 23 #include "smbd/smbd.h" 22 24 #include "smbd/globals.h" 23 25 #include "../libcli/smb/smb_common.h" 26 #include "../lib/util/tevent_ntstatus.h" 24 27 25 28 static struct tevent_req *smbd_smb2_oplock_break_send(TALLOC_CTX *mem_ctx, … … 57 60 58 61 in_oplock_level = CVAL(inbody, 0x02); 62 63 if (in_oplock_level != SMB2_OPLOCK_LEVEL_NONE && 64 in_oplock_level != SMB2_OPLOCK_LEVEL_II) { 65 return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); 66 } 67 59 68 /* 0x03 1 bytes reserved */ 60 69 /* 0x04 4 bytes reserved */ … … 64 73 if (req->compat_chain_fsp) { 65 74 /* skip check */ 66 } else if (in_file_id_persistent != 0) {75 } else if (in_file_id_persistent != in_file_id_volatile) { 67 76 return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); 68 77 } … … 124 133 SSVAL(outbody.data, 0x00, 0x18); /* struct size */ 125 134 SCVAL(outbody.data, 0x02, 126 out_oplock_level); /* oplock level */135 out_oplock_level); /* SMB2 oplock level */ 127 136 SCVAL(outbody.data, 0x03, 0); /* reserved */ 128 137 SIVAL(outbody.data, 0x04, 0); /* reserved */ … … 142 151 struct smbd_smb2_oplock_break_state { 143 152 struct smbd_smb2_request *smb2req; 144 uint8_t out_oplock_level; 153 uint8_t out_oplock_level; /* SMB2 oplock level. */ 145 154 }; 146 155 … … 155 164 struct smb_request *smbreq; 156 165 connection_struct *conn = smb2req->tcon->compat_conn; 157 files_struct *fsp; 166 files_struct *fsp = NULL; 167 int oplocklevel = map_smb2_oplock_levels_to_samba(in_oplock_level); 168 bool break_to_none = (oplocklevel == NO_OPLOCK); 169 bool result; 158 170 159 171 req = tevent_req_create(mem_ctx, &state, … … 165 177 state->out_oplock_level = SMB2_OPLOCK_LEVEL_NONE; 166 178 167 DEBUG(10,("smbd_smb2_oplock_break_send: file_id[0x%016llX]\n", 168 (unsigned long long)in_file_id_volatile)); 179 DEBUG(10,("smbd_smb2_oplock_break_send: file_id[0x%016llX] " 180 "samba level %d\n", 181 (unsigned long long)in_file_id_volatile, 182 oplocklevel)); 169 183 170 184 smbreq = smbd_smb2_fake_smb_request(smb2req); … … 187 201 } 188 202 189 tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED); 203 DEBUG(5,("smbd_smb2_oplock_break_send: got SMB2 oplock break (%u) from client " 204 "for file %s fnum = %d\n", 205 (unsigned int)in_oplock_level, 206 fsp_str_dbg(fsp), 207 fsp->fnum )); 208 209 /* Are we awaiting a break message ? */ 210 if (fsp->oplock_timeout == NULL) { 211 tevent_req_nterror(req, NT_STATUS_INVALID_OPLOCK_PROTOCOL); 212 return tevent_req_post(req, ev); 213 } 214 215 if ((fsp->sent_oplock_break == BREAK_TO_NONE_SENT) || 216 (break_to_none)) { 217 result = remove_oplock(fsp); 218 state->out_oplock_level = SMB2_OPLOCK_LEVEL_NONE; 219 } else { 220 result = downgrade_oplock(fsp); 221 state->out_oplock_level = SMB2_OPLOCK_LEVEL_II; 222 } 223 224 if (!result) { 225 DEBUG(0, ("smbd_smb2_oplock_break_send: error in removing " 226 "oplock on file %s\n", fsp_str_dbg(fsp))); 227 /* Hmmm. Is this panic justified? */ 228 smb_panic("internal tdb error"); 229 } 230 231 reply_to_oplock_break_requests(fsp); 232 233 tevent_req_done(req); 190 234 return tevent_req_post(req, ev); 191 235 } … … 209 253 return NT_STATUS_OK; 210 254 } 255 256 /********************************************************* 257 Create and send an asynchronous 258 SMB2 OPLOCK_BREAK_NOTIFICATION. 259 *********************************************************/ 260 261 void send_break_message_smb2(files_struct *fsp, int level) 262 { 263 uint8_t smb2_oplock_level = (level == OPLOCKLEVEL_II) ? 264 SMB2_OPLOCK_LEVEL_II : 265 SMB2_OPLOCK_LEVEL_NONE; 266 NTSTATUS status; 267 268 DEBUG(10,("send_break_message_smb2: sending oplock break " 269 "for file %s, fnum = %d, smb2 level %u\n", 270 fsp_str_dbg(fsp), 271 fsp->fnum, 272 (unsigned int)smb2_oplock_level )); 273 274 status = smbd_smb2_send_oplock_break(fsp->conn->sconn, 275 (uint64_t)fsp->fnum, 276 (uint64_t)fsp->fnum, 277 smb2_oplock_level); 278 if (!NT_STATUS_IS_OK(status)) { 279 smbd_server_connection_terminate(fsp->conn->sconn, 280 nt_errstr(status)); 281 } 282 }
Note:
See TracChangeset
for help on using the changeset viewer.