| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Core SMB2 server
|
|---|
| 4 |
|
|---|
| 5 | Copyright (C) Stefan Metzmacher 2009
|
|---|
| 6 | Copyright (C) Jeremy Allison 2010
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #include "includes.h"
|
|---|
| 23 | #include "smbd/smbd.h"
|
|---|
| 24 | #include "smbd/globals.h"
|
|---|
| 25 | #include "../libcli/smb/smb_common.h"
|
|---|
| 26 | #include "trans2.h"
|
|---|
| 27 | #include "../lib/util/tevent_ntstatus.h"
|
|---|
| 28 |
|
|---|
| 29 | static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
|
|---|
| 30 | struct tevent_context *ev,
|
|---|
| 31 | struct smbd_smb2_request *smb2req,
|
|---|
| 32 | struct files_struct *in_fsp,
|
|---|
| 33 | uint8_t in_info_type,
|
|---|
| 34 | uint8_t in_file_info_class,
|
|---|
| 35 | uint32_t in_output_buffer_length,
|
|---|
| 36 | DATA_BLOB in_input_buffer,
|
|---|
| 37 | uint32_t in_additional_information,
|
|---|
| 38 | uint32_t in_flags);
|
|---|
| 39 | static NTSTATUS smbd_smb2_getinfo_recv(struct tevent_req *req,
|
|---|
| 40 | TALLOC_CTX *mem_ctx,
|
|---|
| 41 | DATA_BLOB *out_output_buffer,
|
|---|
| 42 | NTSTATUS *p_call_status);
|
|---|
| 43 |
|
|---|
| 44 | static void smbd_smb2_request_getinfo_done(struct tevent_req *subreq);
|
|---|
| 45 | NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req)
|
|---|
| 46 | {
|
|---|
| 47 | NTSTATUS status;
|
|---|
| 48 | const uint8_t *inbody;
|
|---|
| 49 | int i = req->current_idx;
|
|---|
| 50 | uint8_t in_info_type;
|
|---|
| 51 | uint8_t in_file_info_class;
|
|---|
| 52 | uint32_t in_output_buffer_length;
|
|---|
| 53 | uint16_t in_input_buffer_offset;
|
|---|
| 54 | uint32_t in_input_buffer_length;
|
|---|
| 55 | DATA_BLOB in_input_buffer;
|
|---|
| 56 | uint32_t in_additional_information;
|
|---|
| 57 | uint32_t in_flags;
|
|---|
| 58 | uint64_t in_file_id_persistent;
|
|---|
| 59 | uint64_t in_file_id_volatile;
|
|---|
| 60 | struct files_struct *in_fsp;
|
|---|
| 61 | struct tevent_req *subreq;
|
|---|
| 62 |
|
|---|
| 63 | status = smbd_smb2_request_verify_sizes(req, 0x29);
|
|---|
| 64 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 65 | return smbd_smb2_request_error(req, status);
|
|---|
| 66 | }
|
|---|
| 67 | inbody = (const uint8_t *)req->in.vector[i+1].iov_base;
|
|---|
| 68 |
|
|---|
| 69 | in_info_type = CVAL(inbody, 0x02);
|
|---|
| 70 | in_file_info_class = CVAL(inbody, 0x03);
|
|---|
| 71 | in_output_buffer_length = IVAL(inbody, 0x04);
|
|---|
| 72 | in_input_buffer_offset = SVAL(inbody, 0x08);
|
|---|
| 73 | /* 0x0A 2 bytes reserved */
|
|---|
| 74 | in_input_buffer_length = IVAL(inbody, 0x0C);
|
|---|
| 75 | in_additional_information = IVAL(inbody, 0x10);
|
|---|
| 76 | in_flags = IVAL(inbody, 0x14);
|
|---|
| 77 | in_file_id_persistent = BVAL(inbody, 0x18);
|
|---|
| 78 | in_file_id_volatile = BVAL(inbody, 0x20);
|
|---|
| 79 |
|
|---|
| 80 | if (in_input_buffer_offset == 0 && in_input_buffer_length == 0) {
|
|---|
| 81 | /* This is ok */
|
|---|
| 82 | } else if (in_input_buffer_offset !=
|
|---|
| 83 | (SMB2_HDR_BODY + req->in.vector[i+1].iov_len)) {
|
|---|
| 84 | return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | if (in_input_buffer_length > req->in.vector[i+2].iov_len) {
|
|---|
| 88 | return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | in_input_buffer.data = (uint8_t *)req->in.vector[i+2].iov_base;
|
|---|
| 92 | in_input_buffer.length = in_input_buffer_length;
|
|---|
| 93 |
|
|---|
| 94 | if (in_input_buffer.length > req->sconn->smb2.max_trans) {
|
|---|
| 95 | return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 96 | }
|
|---|
| 97 | if (in_output_buffer_length > req->sconn->smb2.max_trans) {
|
|---|
| 98 | return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile);
|
|---|
| 102 | if (in_fsp == NULL) {
|
|---|
| 103 | return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | subreq = smbd_smb2_getinfo_send(req, req->sconn->smb2.event_ctx,
|
|---|
| 107 | req, in_fsp,
|
|---|
| 108 | in_info_type,
|
|---|
| 109 | in_file_info_class,
|
|---|
| 110 | in_output_buffer_length,
|
|---|
| 111 | in_input_buffer,
|
|---|
| 112 | in_additional_information,
|
|---|
| 113 | in_flags);
|
|---|
| 114 | if (subreq == NULL) {
|
|---|
| 115 | return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
|
|---|
| 116 | }
|
|---|
| 117 | tevent_req_set_callback(subreq, smbd_smb2_request_getinfo_done, req);
|
|---|
| 118 |
|
|---|
| 119 | return smbd_smb2_request_pending_queue(req, subreq);
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | static void smbd_smb2_request_getinfo_done(struct tevent_req *subreq)
|
|---|
| 123 | {
|
|---|
| 124 | struct smbd_smb2_request *req = tevent_req_callback_data(subreq,
|
|---|
| 125 | struct smbd_smb2_request);
|
|---|
| 126 | int i = req->current_idx;
|
|---|
| 127 | uint8_t *outhdr;
|
|---|
| 128 | DATA_BLOB outbody;
|
|---|
| 129 | DATA_BLOB outdyn;
|
|---|
| 130 | uint16_t out_output_buffer_offset;
|
|---|
| 131 | DATA_BLOB out_output_buffer = data_blob_null;
|
|---|
| 132 | NTSTATUS status;
|
|---|
| 133 | NTSTATUS call_status = NT_STATUS_OK;
|
|---|
| 134 | NTSTATUS error; /* transport error */
|
|---|
| 135 |
|
|---|
| 136 | status = smbd_smb2_getinfo_recv(subreq,
|
|---|
| 137 | req,
|
|---|
| 138 | &out_output_buffer,
|
|---|
| 139 | &call_status);
|
|---|
| 140 | TALLOC_FREE(subreq);
|
|---|
| 141 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 142 | error = smbd_smb2_request_error(req, status);
|
|---|
| 143 | if (!NT_STATUS_IS_OK(error)) {
|
|---|
| 144 | smbd_server_connection_terminate(req->sconn,
|
|---|
| 145 | nt_errstr(error));
|
|---|
| 146 | return;
|
|---|
| 147 | }
|
|---|
| 148 | return;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | if (!NT_STATUS_IS_OK(call_status)) {
|
|---|
| 152 | /* Return a specific error with data. */
|
|---|
| 153 | error = smbd_smb2_request_error_ex(req,
|
|---|
| 154 | call_status,
|
|---|
| 155 | &out_output_buffer,
|
|---|
| 156 | __location__);
|
|---|
| 157 | if (!NT_STATUS_IS_OK(error)) {
|
|---|
| 158 | smbd_server_connection_terminate(req->sconn,
|
|---|
| 159 | nt_errstr(error));
|
|---|
| 160 | return;
|
|---|
| 161 | }
|
|---|
| 162 | return;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | out_output_buffer_offset = SMB2_HDR_BODY + 0x08;
|
|---|
| 166 |
|
|---|
| 167 | outhdr = (uint8_t *)req->out.vector[i].iov_base;
|
|---|
| 168 |
|
|---|
| 169 | outbody = data_blob_talloc(req->out.vector, NULL, 0x08);
|
|---|
| 170 | if (outbody.data == NULL) {
|
|---|
| 171 | error = smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
|
|---|
| 172 | if (!NT_STATUS_IS_OK(error)) {
|
|---|
| 173 | smbd_server_connection_terminate(req->sconn,
|
|---|
| 174 | nt_errstr(error));
|
|---|
| 175 | return;
|
|---|
| 176 | }
|
|---|
| 177 | return;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | SSVAL(outbody.data, 0x00, 0x08 + 1); /* struct size */
|
|---|
| 181 | SSVAL(outbody.data, 0x02,
|
|---|
| 182 | out_output_buffer_offset); /* output buffer offset */
|
|---|
| 183 | SIVAL(outbody.data, 0x04,
|
|---|
| 184 | out_output_buffer.length); /* output buffer length */
|
|---|
| 185 |
|
|---|
| 186 | outdyn = out_output_buffer;
|
|---|
| 187 |
|
|---|
| 188 | error = smbd_smb2_request_done(req, outbody, &outdyn);
|
|---|
| 189 | if (!NT_STATUS_IS_OK(error)) {
|
|---|
| 190 | smbd_server_connection_terminate(req->sconn,
|
|---|
| 191 | nt_errstr(error));
|
|---|
| 192 | return;
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | struct smbd_smb2_getinfo_state {
|
|---|
| 197 | struct smbd_smb2_request *smb2req;
|
|---|
| 198 | NTSTATUS status;
|
|---|
| 199 | DATA_BLOB out_output_buffer;
|
|---|
| 200 | };
|
|---|
| 201 |
|
|---|
| 202 | static void smb2_ipc_getinfo(struct tevent_req *req,
|
|---|
| 203 | struct smbd_smb2_getinfo_state *state,
|
|---|
| 204 | struct tevent_context *ev,
|
|---|
| 205 | uint8_t in_info_type,
|
|---|
| 206 | uint8_t in_file_info_class)
|
|---|
| 207 | {
|
|---|
| 208 | /* We want to reply to SMB2_GETINFO_FILE
|
|---|
| 209 | with a class of SMB2_FILE_STANDARD_INFO as
|
|---|
| 210 | otherwise a Win7 client issues this request
|
|---|
| 211 | twice (2xroundtrips) if we return NOT_SUPPORTED.
|
|---|
| 212 | NB. We do the same for SMB1 in call_trans2qpipeinfo() */
|
|---|
| 213 |
|
|---|
| 214 | if (in_info_type == 0x01 && /* SMB2_GETINFO_FILE */
|
|---|
| 215 | in_file_info_class == 0x05) { /* SMB2_FILE_STANDARD_INFO */
|
|---|
| 216 | state->out_output_buffer = data_blob_talloc(state,
|
|---|
| 217 | NULL, 24);
|
|---|
| 218 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
|---|
| 219 | return;
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | memset(state->out_output_buffer.data,0,24);
|
|---|
| 223 | SOFF_T(state->out_output_buffer.data,0,4096LL);
|
|---|
| 224 | SIVAL(state->out_output_buffer.data,16,1);
|
|---|
| 225 | SIVAL(state->out_output_buffer.data,20,1);
|
|---|
| 226 | tevent_req_done(req);
|
|---|
| 227 | } else {
|
|---|
| 228 | tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
|
|---|
| 233 | struct tevent_context *ev,
|
|---|
| 234 | struct smbd_smb2_request *smb2req,
|
|---|
| 235 | struct files_struct *fsp,
|
|---|
| 236 | uint8_t in_info_type,
|
|---|
| 237 | uint8_t in_file_info_class,
|
|---|
| 238 | uint32_t in_output_buffer_length,
|
|---|
| 239 | DATA_BLOB in_input_buffer,
|
|---|
| 240 | uint32_t in_additional_information,
|
|---|
| 241 | uint32_t in_flags)
|
|---|
| 242 | {
|
|---|
| 243 | struct tevent_req *req;
|
|---|
| 244 | struct smbd_smb2_getinfo_state *state;
|
|---|
| 245 | struct smb_request *smbreq;
|
|---|
| 246 | connection_struct *conn = smb2req->tcon->compat_conn;
|
|---|
| 247 | NTSTATUS status;
|
|---|
| 248 |
|
|---|
| 249 | req = tevent_req_create(mem_ctx, &state,
|
|---|
| 250 | struct smbd_smb2_getinfo_state);
|
|---|
| 251 | if (req == NULL) {
|
|---|
| 252 | return NULL;
|
|---|
| 253 | }
|
|---|
| 254 | state->smb2req = smb2req;
|
|---|
| 255 | state->status = NT_STATUS_OK;
|
|---|
| 256 | state->out_output_buffer = data_blob_null;
|
|---|
| 257 |
|
|---|
| 258 | DEBUG(10,("smbd_smb2_getinfo_send: %s - fnum[%d]\n",
|
|---|
| 259 | fsp_str_dbg(fsp), fsp->fnum));
|
|---|
| 260 |
|
|---|
| 261 | smbreq = smbd_smb2_fake_smb_request(smb2req);
|
|---|
| 262 | if (tevent_req_nomem(smbreq, req)) {
|
|---|
| 263 | return tevent_req_post(req, ev);
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | if (IS_IPC(conn)) {
|
|---|
| 267 | smb2_ipc_getinfo(req, state, ev,
|
|---|
| 268 | in_info_type, in_file_info_class);
|
|---|
| 269 | return tevent_req_post(req, ev);
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | switch (in_info_type) {
|
|---|
| 273 | case 0x01:/* SMB2_GETINFO_FILE */
|
|---|
| 274 | {
|
|---|
| 275 | uint16_t file_info_level;
|
|---|
| 276 | char *data = NULL;
|
|---|
| 277 | unsigned int data_size = 0;
|
|---|
| 278 | bool delete_pending = false;
|
|---|
| 279 | struct timespec write_time_ts;
|
|---|
| 280 | struct file_id fileid;
|
|---|
| 281 | struct ea_list *ea_list = NULL;
|
|---|
| 282 | int lock_data_count = 0;
|
|---|
| 283 | char *lock_data = NULL;
|
|---|
| 284 |
|
|---|
| 285 | ZERO_STRUCT(write_time_ts);
|
|---|
| 286 |
|
|---|
| 287 | switch (in_file_info_class) {
|
|---|
| 288 | case 0x0F:/* RAW_FILEINFO_SMB2_ALL_EAS */
|
|---|
| 289 | file_info_level = 0xFF00 | in_file_info_class;
|
|---|
| 290 | break;
|
|---|
| 291 |
|
|---|
| 292 | case 0x12:/* RAW_FILEINFO_SMB2_ALL_INFORMATION */
|
|---|
| 293 | file_info_level = 0xFF00 | in_file_info_class;
|
|---|
| 294 | break;
|
|---|
| 295 |
|
|---|
| 296 | default:
|
|---|
| 297 | /* the levels directly map to the passthru levels */
|
|---|
| 298 | file_info_level = in_file_info_class + 1000;
|
|---|
| 299 | break;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | if (fsp->fake_file_handle) {
|
|---|
| 303 | /*
|
|---|
| 304 | * This is actually for the QUOTA_FAKE_FILE --metze
|
|---|
| 305 | */
|
|---|
| 306 |
|
|---|
| 307 | /* We know this name is ok, it's already passed the checks. */
|
|---|
| 308 |
|
|---|
| 309 | } else if (fsp && fsp->fh->fd == -1) {
|
|---|
| 310 | /*
|
|---|
| 311 | * This is actually a QFILEINFO on a directory
|
|---|
| 312 | * handle (returned from an NT SMB). NT5.0 seems
|
|---|
| 313 | * to do this call. JRA.
|
|---|
| 314 | */
|
|---|
| 315 |
|
|---|
| 316 | if (INFO_LEVEL_IS_UNIX(file_info_level)) {
|
|---|
| 317 | /* Always do lstat for UNIX calls. */
|
|---|
| 318 | if (SMB_VFS_LSTAT(conn, fsp->fsp_name)) {
|
|---|
| 319 | DEBUG(3,("smbd_smb2_getinfo_send: "
|
|---|
| 320 | "SMB_VFS_LSTAT of %s failed "
|
|---|
| 321 | "(%s)\n", fsp_str_dbg(fsp),
|
|---|
| 322 | strerror(errno)));
|
|---|
| 323 | status = map_nt_error_from_unix(errno);
|
|---|
| 324 | tevent_req_nterror(req, status);
|
|---|
| 325 | return tevent_req_post(req, ev);
|
|---|
| 326 | }
|
|---|
| 327 | } else if (SMB_VFS_STAT(conn, fsp->fsp_name)) {
|
|---|
| 328 | DEBUG(3,("smbd_smb2_getinfo_send: "
|
|---|
| 329 | "SMB_VFS_STAT of %s failed (%s)\n",
|
|---|
| 330 | fsp_str_dbg(fsp),
|
|---|
| 331 | strerror(errno)));
|
|---|
| 332 | status = map_nt_error_from_unix(errno);
|
|---|
| 333 | tevent_req_nterror(req, status);
|
|---|
| 334 | return tevent_req_post(req, ev);
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | fileid = vfs_file_id_from_sbuf(conn,
|
|---|
| 338 | &fsp->fsp_name->st);
|
|---|
| 339 | get_file_infos(fileid, fsp->name_hash,
|
|---|
| 340 | &delete_pending, &write_time_ts);
|
|---|
| 341 | } else {
|
|---|
| 342 | /*
|
|---|
| 343 | * Original code - this is an open file.
|
|---|
| 344 | */
|
|---|
| 345 |
|
|---|
| 346 | if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) {
|
|---|
| 347 | DEBUG(3, ("smbd_smb2_getinfo_send: "
|
|---|
| 348 | "fstat of fnum %d failed (%s)\n",
|
|---|
| 349 | fsp->fnum, strerror(errno)));
|
|---|
| 350 | status = map_nt_error_from_unix(errno);
|
|---|
| 351 | tevent_req_nterror(req, status);
|
|---|
| 352 | return tevent_req_post(req, ev);
|
|---|
| 353 | }
|
|---|
| 354 | fileid = vfs_file_id_from_sbuf(conn,
|
|---|
| 355 | &fsp->fsp_name->st);
|
|---|
| 356 | get_file_infos(fileid, fsp->name_hash,
|
|---|
| 357 | &delete_pending, &write_time_ts);
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | status = smbd_do_qfilepathinfo(conn, state,
|
|---|
| 361 | file_info_level,
|
|---|
| 362 | fsp,
|
|---|
| 363 | fsp->fsp_name,
|
|---|
| 364 | delete_pending,
|
|---|
| 365 | write_time_ts,
|
|---|
| 366 | ea_list,
|
|---|
| 367 | lock_data_count,
|
|---|
| 368 | lock_data,
|
|---|
| 369 | STR_UNICODE,
|
|---|
| 370 | in_output_buffer_length,
|
|---|
| 371 | &data,
|
|---|
| 372 | &data_size);
|
|---|
| 373 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 374 | SAFE_FREE(data);
|
|---|
| 375 | if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
|
|---|
| 376 | status = NT_STATUS_INVALID_INFO_CLASS;
|
|---|
| 377 | }
|
|---|
| 378 | tevent_req_nterror(req, status);
|
|---|
| 379 | return tevent_req_post(req, ev);
|
|---|
| 380 | }
|
|---|
| 381 | if (data_size > 0) {
|
|---|
| 382 | state->out_output_buffer = data_blob_talloc(state,
|
|---|
| 383 | data,
|
|---|
| 384 | data_size);
|
|---|
| 385 | SAFE_FREE(data);
|
|---|
| 386 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
|---|
| 387 | return tevent_req_post(req, ev);
|
|---|
| 388 | }
|
|---|
| 389 | }
|
|---|
| 390 | SAFE_FREE(data);
|
|---|
| 391 | break;
|
|---|
| 392 | }
|
|---|
| 393 |
|
|---|
| 394 | case 0x02:/* SMB2_GETINFO_FS */
|
|---|
| 395 | {
|
|---|
| 396 | uint16_t file_info_level;
|
|---|
| 397 | char *data = NULL;
|
|---|
| 398 | int data_size = 0;
|
|---|
| 399 |
|
|---|
| 400 | /* the levels directly map to the passthru levels */
|
|---|
| 401 | file_info_level = in_file_info_class + 1000;
|
|---|
| 402 |
|
|---|
| 403 | status = smbd_do_qfsinfo(conn, state,
|
|---|
| 404 | file_info_level,
|
|---|
| 405 | STR_UNICODE,
|
|---|
| 406 | in_output_buffer_length,
|
|---|
| 407 | &data,
|
|---|
| 408 | &data_size);
|
|---|
| 409 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 410 | SAFE_FREE(data);
|
|---|
| 411 | if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
|
|---|
| 412 | status = NT_STATUS_INVALID_INFO_CLASS;
|
|---|
| 413 | }
|
|---|
| 414 | tevent_req_nterror(req, status);
|
|---|
| 415 | return tevent_req_post(req, ev);
|
|---|
| 416 | }
|
|---|
| 417 | if (data_size > 0) {
|
|---|
| 418 | state->out_output_buffer = data_blob_talloc(state,
|
|---|
| 419 | data,
|
|---|
| 420 | data_size);
|
|---|
| 421 | SAFE_FREE(data);
|
|---|
| 422 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
|---|
| 423 | return tevent_req_post(req, ev);
|
|---|
| 424 | }
|
|---|
| 425 | }
|
|---|
| 426 | SAFE_FREE(data);
|
|---|
| 427 | break;
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | case 0x03:/* SMB2_GETINFO_SEC */
|
|---|
| 431 | {
|
|---|
| 432 | uint8_t *p_marshalled_sd = NULL;
|
|---|
| 433 | size_t sd_size = 0;
|
|---|
| 434 |
|
|---|
| 435 | status = smbd_do_query_security_desc(conn,
|
|---|
| 436 | state,
|
|---|
| 437 | fsp,
|
|---|
| 438 | /* Security info wanted. */
|
|---|
| 439 | in_additional_information,
|
|---|
| 440 | in_output_buffer_length,
|
|---|
| 441 | &p_marshalled_sd,
|
|---|
| 442 | &sd_size);
|
|---|
| 443 |
|
|---|
| 444 | if (NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL)) {
|
|---|
| 445 | /* Return needed size. */
|
|---|
| 446 | state->out_output_buffer = data_blob_talloc(state,
|
|---|
| 447 | NULL,
|
|---|
| 448 | 4);
|
|---|
| 449 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
|---|
| 450 | return tevent_req_post(req, ev);
|
|---|
| 451 | }
|
|---|
| 452 | SIVAL(state->out_output_buffer.data,0,(uint32_t)sd_size);
|
|---|
| 453 | state->status = NT_STATUS_BUFFER_TOO_SMALL;
|
|---|
| 454 | break;
|
|---|
| 455 | }
|
|---|
| 456 | if (!NT_STATUS_IS_OK(status)) {
|
|---|
| 457 | DEBUG(10,("smbd_smb2_getinfo_send: "
|
|---|
| 458 | "smbd_do_query_security_desc of %s failed "
|
|---|
| 459 | "(%s)\n", fsp_str_dbg(fsp),
|
|---|
| 460 | nt_errstr(status)));
|
|---|
| 461 | tevent_req_nterror(req, status);
|
|---|
| 462 | return tevent_req_post(req, ev);
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | if (sd_size > 0) {
|
|---|
| 466 | state->out_output_buffer = data_blob_talloc(state,
|
|---|
| 467 | p_marshalled_sd,
|
|---|
| 468 | sd_size);
|
|---|
| 469 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
|---|
| 470 | return tevent_req_post(req, ev);
|
|---|
| 471 | }
|
|---|
| 472 | }
|
|---|
| 473 | break;
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | default:
|
|---|
| 477 | DEBUG(10,("smbd_smb2_getinfo_send: "
|
|---|
| 478 | "unknown in_info_type of %u "
|
|---|
| 479 | " for file %s\n",
|
|---|
| 480 | (unsigned int)in_info_type,
|
|---|
| 481 | fsp_str_dbg(fsp) ));
|
|---|
| 482 |
|
|---|
| 483 | tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
|---|
| 484 | return tevent_req_post(req, ev);
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | tevent_req_done(req);
|
|---|
| 488 | return tevent_req_post(req, ev);
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | static NTSTATUS smbd_smb2_getinfo_recv(struct tevent_req *req,
|
|---|
| 492 | TALLOC_CTX *mem_ctx,
|
|---|
| 493 | DATA_BLOB *out_output_buffer,
|
|---|
| 494 | NTSTATUS *pstatus)
|
|---|
| 495 | {
|
|---|
| 496 | NTSTATUS status;
|
|---|
| 497 | struct smbd_smb2_getinfo_state *state = tevent_req_data(req,
|
|---|
| 498 | struct smbd_smb2_getinfo_state);
|
|---|
| 499 |
|
|---|
| 500 | if (tevent_req_is_nterror(req, &status)) {
|
|---|
| 501 | tevent_req_received(req);
|
|---|
| 502 | return status;
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | *out_output_buffer = state->out_output_buffer;
|
|---|
| 506 | talloc_steal(mem_ctx, out_output_buffer->data);
|
|---|
| 507 | *pstatus = state->status;
|
|---|
| 508 |
|
|---|
| 509 | tevent_req_received(req);
|
|---|
| 510 | return NT_STATUS_OK;
|
|---|
| 511 | }
|
|---|