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 | /* some GetInfo responses set STATUS_BUFFER_OVERFLOW and return partial,
|
---|
152 | but valid data */
|
---|
153 | if (!(NT_STATUS_IS_OK(call_status) ||
|
---|
154 | NT_STATUS_EQUAL(call_status, STATUS_BUFFER_OVERFLOW))) {
|
---|
155 | /* Return a specific error with data. */
|
---|
156 | error = smbd_smb2_request_error_ex(req,
|
---|
157 | call_status,
|
---|
158 | &out_output_buffer,
|
---|
159 | __location__);
|
---|
160 | if (!NT_STATUS_IS_OK(error)) {
|
---|
161 | smbd_server_connection_terminate(req->sconn,
|
---|
162 | nt_errstr(error));
|
---|
163 | return;
|
---|
164 | }
|
---|
165 | return;
|
---|
166 | }
|
---|
167 |
|
---|
168 | out_output_buffer_offset = SMB2_HDR_BODY + 0x08;
|
---|
169 |
|
---|
170 | outhdr = (uint8_t *)req->out.vector[i].iov_base;
|
---|
171 |
|
---|
172 | outbody = data_blob_talloc(req->out.vector, NULL, 0x08);
|
---|
173 | if (outbody.data == NULL) {
|
---|
174 | error = smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
|
---|
175 | if (!NT_STATUS_IS_OK(error)) {
|
---|
176 | smbd_server_connection_terminate(req->sconn,
|
---|
177 | nt_errstr(error));
|
---|
178 | return;
|
---|
179 | }
|
---|
180 | return;
|
---|
181 | }
|
---|
182 |
|
---|
183 | SSVAL(outbody.data, 0x00, 0x08 + 1); /* struct size */
|
---|
184 | SSVAL(outbody.data, 0x02,
|
---|
185 | out_output_buffer_offset); /* output buffer offset */
|
---|
186 | SIVAL(outbody.data, 0x04,
|
---|
187 | out_output_buffer.length); /* output buffer length */
|
---|
188 |
|
---|
189 | outdyn = out_output_buffer;
|
---|
190 |
|
---|
191 | error = smbd_smb2_request_done_ex(req, call_status, outbody, &outdyn, __location__);
|
---|
192 | if (!NT_STATUS_IS_OK(error)) {
|
---|
193 | smbd_server_connection_terminate(req->sconn,
|
---|
194 | nt_errstr(error));
|
---|
195 | return;
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | struct smbd_smb2_getinfo_state {
|
---|
200 | struct smbd_smb2_request *smb2req;
|
---|
201 | NTSTATUS status;
|
---|
202 | DATA_BLOB out_output_buffer;
|
---|
203 | };
|
---|
204 |
|
---|
205 | static void smb2_ipc_getinfo(struct tevent_req *req,
|
---|
206 | struct smbd_smb2_getinfo_state *state,
|
---|
207 | struct tevent_context *ev,
|
---|
208 | uint8_t in_info_type,
|
---|
209 | uint8_t in_file_info_class)
|
---|
210 | {
|
---|
211 | /* We want to reply to SMB2_GETINFO_FILE
|
---|
212 | with a class of SMB2_FILE_STANDARD_INFO as
|
---|
213 | otherwise a Win7 client issues this request
|
---|
214 | twice (2xroundtrips) if we return NOT_SUPPORTED.
|
---|
215 | NB. We do the same for SMB1 in call_trans2qpipeinfo() */
|
---|
216 |
|
---|
217 | if (in_info_type == 0x01 && /* SMB2_GETINFO_FILE */
|
---|
218 | in_file_info_class == 0x05) { /* SMB2_FILE_STANDARD_INFO */
|
---|
219 | state->out_output_buffer = data_blob_talloc(state,
|
---|
220 | NULL, 24);
|
---|
221 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
---|
222 | return;
|
---|
223 | }
|
---|
224 |
|
---|
225 | memset(state->out_output_buffer.data,0,24);
|
---|
226 | SOFF_T(state->out_output_buffer.data,0,4096LL);
|
---|
227 | SIVAL(state->out_output_buffer.data,16,1);
|
---|
228 | SIVAL(state->out_output_buffer.data,20,1);
|
---|
229 | tevent_req_done(req);
|
---|
230 | } else {
|
---|
231 | tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
|
---|
232 | }
|
---|
233 | }
|
---|
234 |
|
---|
235 | static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
|
---|
236 | struct tevent_context *ev,
|
---|
237 | struct smbd_smb2_request *smb2req,
|
---|
238 | struct files_struct *fsp,
|
---|
239 | uint8_t in_info_type,
|
---|
240 | uint8_t in_file_info_class,
|
---|
241 | uint32_t in_output_buffer_length,
|
---|
242 | DATA_BLOB in_input_buffer,
|
---|
243 | uint32_t in_additional_information,
|
---|
244 | uint32_t in_flags)
|
---|
245 | {
|
---|
246 | struct tevent_req *req;
|
---|
247 | struct smbd_smb2_getinfo_state *state;
|
---|
248 | struct smb_request *smbreq;
|
---|
249 | connection_struct *conn = smb2req->tcon->compat_conn;
|
---|
250 | NTSTATUS status;
|
---|
251 |
|
---|
252 | req = tevent_req_create(mem_ctx, &state,
|
---|
253 | struct smbd_smb2_getinfo_state);
|
---|
254 | if (req == NULL) {
|
---|
255 | return NULL;
|
---|
256 | }
|
---|
257 | state->smb2req = smb2req;
|
---|
258 | state->status = NT_STATUS_OK;
|
---|
259 | state->out_output_buffer = data_blob_null;
|
---|
260 |
|
---|
261 | DEBUG(10,("smbd_smb2_getinfo_send: %s - fnum[%d]\n",
|
---|
262 | fsp_str_dbg(fsp), fsp->fnum));
|
---|
263 |
|
---|
264 | smbreq = smbd_smb2_fake_smb_request(smb2req);
|
---|
265 | if (tevent_req_nomem(smbreq, req)) {
|
---|
266 | return tevent_req_post(req, ev);
|
---|
267 | }
|
---|
268 |
|
---|
269 | if (IS_IPC(conn)) {
|
---|
270 | smb2_ipc_getinfo(req, state, ev,
|
---|
271 | in_info_type, in_file_info_class);
|
---|
272 | return tevent_req_post(req, ev);
|
---|
273 | }
|
---|
274 |
|
---|
275 | switch (in_info_type) {
|
---|
276 | case SMB2_GETINFO_FILE:
|
---|
277 | {
|
---|
278 | uint16_t file_info_level;
|
---|
279 | char *data = NULL;
|
---|
280 | unsigned int data_size = 0;
|
---|
281 | bool delete_pending = false;
|
---|
282 | struct timespec write_time_ts;
|
---|
283 | struct file_id fileid;
|
---|
284 | struct ea_list *ea_list = NULL;
|
---|
285 | int lock_data_count = 0;
|
---|
286 | char *lock_data = NULL;
|
---|
287 | size_t fixed_portion;
|
---|
288 |
|
---|
289 | ZERO_STRUCT(write_time_ts);
|
---|
290 |
|
---|
291 | switch (in_file_info_class) {
|
---|
292 | case 0x0F:/* RAW_FILEINFO_SMB2_ALL_EAS */
|
---|
293 | file_info_level = 0xFF00 | in_file_info_class;
|
---|
294 | break;
|
---|
295 |
|
---|
296 | case 0x12:/* RAW_FILEINFO_SMB2_ALL_INFORMATION */
|
---|
297 | file_info_level = 0xFF00 | in_file_info_class;
|
---|
298 | break;
|
---|
299 |
|
---|
300 | default:
|
---|
301 | /* the levels directly map to the passthru levels */
|
---|
302 | file_info_level = in_file_info_class + 1000;
|
---|
303 | break;
|
---|
304 | }
|
---|
305 |
|
---|
306 | if (fsp->fake_file_handle) {
|
---|
307 | /*
|
---|
308 | * This is actually for the QUOTA_FAKE_FILE --metze
|
---|
309 | */
|
---|
310 |
|
---|
311 | /* We know this name is ok, it's already passed the checks. */
|
---|
312 |
|
---|
313 | } else if (fsp && fsp->fh->fd == -1) {
|
---|
314 | /*
|
---|
315 | * This is actually a QFILEINFO on a directory
|
---|
316 | * handle (returned from an NT SMB). NT5.0 seems
|
---|
317 | * to do this call. JRA.
|
---|
318 | */
|
---|
319 |
|
---|
320 | if (INFO_LEVEL_IS_UNIX(file_info_level)) {
|
---|
321 | /* Always do lstat for UNIX calls. */
|
---|
322 | if (SMB_VFS_LSTAT(conn, fsp->fsp_name)) {
|
---|
323 | DEBUG(3,("smbd_smb2_getinfo_send: "
|
---|
324 | "SMB_VFS_LSTAT of %s failed "
|
---|
325 | "(%s)\n", fsp_str_dbg(fsp),
|
---|
326 | strerror(errno)));
|
---|
327 | status = map_nt_error_from_unix(errno);
|
---|
328 | tevent_req_nterror(req, status);
|
---|
329 | return tevent_req_post(req, ev);
|
---|
330 | }
|
---|
331 | } else if (SMB_VFS_STAT(conn, fsp->fsp_name)) {
|
---|
332 | DEBUG(3,("smbd_smb2_getinfo_send: "
|
---|
333 | "SMB_VFS_STAT of %s failed (%s)\n",
|
---|
334 | fsp_str_dbg(fsp),
|
---|
335 | strerror(errno)));
|
---|
336 | status = map_nt_error_from_unix(errno);
|
---|
337 | tevent_req_nterror(req, status);
|
---|
338 | return tevent_req_post(req, ev);
|
---|
339 | }
|
---|
340 |
|
---|
341 | fileid = vfs_file_id_from_sbuf(conn,
|
---|
342 | &fsp->fsp_name->st);
|
---|
343 | get_file_infos(fileid, fsp->name_hash,
|
---|
344 | &delete_pending, &write_time_ts);
|
---|
345 | } else {
|
---|
346 | /*
|
---|
347 | * Original code - this is an open file.
|
---|
348 | */
|
---|
349 |
|
---|
350 | if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) {
|
---|
351 | DEBUG(3, ("smbd_smb2_getinfo_send: "
|
---|
352 | "fstat of fnum %d failed (%s)\n",
|
---|
353 | fsp->fnum, strerror(errno)));
|
---|
354 | status = map_nt_error_from_unix(errno);
|
---|
355 | tevent_req_nterror(req, status);
|
---|
356 | return tevent_req_post(req, ev);
|
---|
357 | }
|
---|
358 | fileid = vfs_file_id_from_sbuf(conn,
|
---|
359 | &fsp->fsp_name->st);
|
---|
360 | get_file_infos(fileid, fsp->name_hash,
|
---|
361 | &delete_pending, &write_time_ts);
|
---|
362 | }
|
---|
363 |
|
---|
364 | status = smbd_do_qfilepathinfo(conn, state,
|
---|
365 | file_info_level,
|
---|
366 | fsp,
|
---|
367 | fsp->fsp_name,
|
---|
368 | delete_pending,
|
---|
369 | write_time_ts,
|
---|
370 | ea_list,
|
---|
371 | lock_data_count,
|
---|
372 | lock_data,
|
---|
373 | STR_UNICODE,
|
---|
374 | in_output_buffer_length,
|
---|
375 | &fixed_portion,
|
---|
376 | &data,
|
---|
377 | &data_size);
|
---|
378 | if (!NT_STATUS_IS_OK(status)) {
|
---|
379 | SAFE_FREE(data);
|
---|
380 | if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
|
---|
381 | status = NT_STATUS_INVALID_INFO_CLASS;
|
---|
382 | }
|
---|
383 | tevent_req_nterror(req, status);
|
---|
384 | return tevent_req_post(req, ev);
|
---|
385 | }
|
---|
386 | if (in_output_buffer_length < fixed_portion) {
|
---|
387 | SAFE_FREE(data);
|
---|
388 | tevent_req_nterror(
|
---|
389 | req, NT_STATUS_INFO_LENGTH_MISMATCH);
|
---|
390 | return tevent_req_post(req, ev);
|
---|
391 | }
|
---|
392 | if (data_size > 0) {
|
---|
393 | state->out_output_buffer = data_blob_talloc(state,
|
---|
394 | data,
|
---|
395 | data_size);
|
---|
396 | SAFE_FREE(data);
|
---|
397 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
---|
398 | return tevent_req_post(req, ev);
|
---|
399 | }
|
---|
400 | if (data_size > in_output_buffer_length) {
|
---|
401 | state->out_output_buffer.length =
|
---|
402 | in_output_buffer_length;
|
---|
403 | status = STATUS_BUFFER_OVERFLOW;
|
---|
404 | }
|
---|
405 | }
|
---|
406 | SAFE_FREE(data);
|
---|
407 | break;
|
---|
408 | }
|
---|
409 |
|
---|
410 | case SMB2_GETINFO_FS:
|
---|
411 | {
|
---|
412 | uint16_t file_info_level;
|
---|
413 | char *data = NULL;
|
---|
414 | int data_size = 0;
|
---|
415 | size_t fixed_portion;
|
---|
416 |
|
---|
417 | /* the levels directly map to the passthru levels */
|
---|
418 | file_info_level = in_file_info_class + 1000;
|
---|
419 |
|
---|
420 | status = smbd_do_qfsinfo(conn, state,
|
---|
421 | file_info_level,
|
---|
422 | STR_UNICODE,
|
---|
423 | in_output_buffer_length,
|
---|
424 | &fixed_portion,
|
---|
425 | fsp->fsp_name,
|
---|
426 | &data,
|
---|
427 | &data_size);
|
---|
428 | /* some responses set STATUS_BUFFER_OVERFLOW and return
|
---|
429 | partial, but valid data */
|
---|
430 | if (!(NT_STATUS_IS_OK(status) ||
|
---|
431 | NT_STATUS_EQUAL(status, STATUS_BUFFER_OVERFLOW))) {
|
---|
432 | SAFE_FREE(data);
|
---|
433 | if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
|
---|
434 | status = NT_STATUS_INVALID_INFO_CLASS;
|
---|
435 | }
|
---|
436 | tevent_req_nterror(req, status);
|
---|
437 | return tevent_req_post(req, ev);
|
---|
438 | }
|
---|
439 | if (in_output_buffer_length < fixed_portion) {
|
---|
440 | SAFE_FREE(data);
|
---|
441 | tevent_req_nterror(
|
---|
442 | req, NT_STATUS_INFO_LENGTH_MISMATCH);
|
---|
443 | return tevent_req_post(req, ev);
|
---|
444 | }
|
---|
445 | if (data_size > 0) {
|
---|
446 | state->out_output_buffer = data_blob_talloc(state,
|
---|
447 | data,
|
---|
448 | data_size);
|
---|
449 | SAFE_FREE(data);
|
---|
450 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
---|
451 | return tevent_req_post(req, ev);
|
---|
452 | }
|
---|
453 | if (data_size > in_output_buffer_length) {
|
---|
454 | state->out_output_buffer.length =
|
---|
455 | in_output_buffer_length;
|
---|
456 | status = STATUS_BUFFER_OVERFLOW;
|
---|
457 | }
|
---|
458 | }
|
---|
459 | SAFE_FREE(data);
|
---|
460 | break;
|
---|
461 | }
|
---|
462 |
|
---|
463 | case SMB2_GETINFO_SECURITY:
|
---|
464 | {
|
---|
465 | uint8_t *p_marshalled_sd = NULL;
|
---|
466 | size_t sd_size = 0;
|
---|
467 |
|
---|
468 | status = smbd_do_query_security_desc(conn,
|
---|
469 | state,
|
---|
470 | fsp,
|
---|
471 | /* Security info wanted. */
|
---|
472 | in_additional_information,
|
---|
473 | in_output_buffer_length,
|
---|
474 | &p_marshalled_sd,
|
---|
475 | &sd_size);
|
---|
476 |
|
---|
477 | if (NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL)) {
|
---|
478 | /* Return needed size. */
|
---|
479 | state->out_output_buffer = data_blob_talloc(state,
|
---|
480 | NULL,
|
---|
481 | 4);
|
---|
482 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
---|
483 | return tevent_req_post(req, ev);
|
---|
484 | }
|
---|
485 | SIVAL(state->out_output_buffer.data,0,(uint32_t)sd_size);
|
---|
486 | state->status = NT_STATUS_BUFFER_TOO_SMALL;
|
---|
487 | break;
|
---|
488 | }
|
---|
489 | if (!NT_STATUS_IS_OK(status)) {
|
---|
490 | DEBUG(10,("smbd_smb2_getinfo_send: "
|
---|
491 | "smbd_do_query_security_desc of %s failed "
|
---|
492 | "(%s)\n", fsp_str_dbg(fsp),
|
---|
493 | nt_errstr(status)));
|
---|
494 | tevent_req_nterror(req, status);
|
---|
495 | return tevent_req_post(req, ev);
|
---|
496 | }
|
---|
497 |
|
---|
498 | if (sd_size > 0) {
|
---|
499 | state->out_output_buffer = data_blob_talloc(state,
|
---|
500 | p_marshalled_sd,
|
---|
501 | sd_size);
|
---|
502 | if (tevent_req_nomem(state->out_output_buffer.data, req)) {
|
---|
503 | return tevent_req_post(req, ev);
|
---|
504 | }
|
---|
505 | }
|
---|
506 | break;
|
---|
507 | }
|
---|
508 |
|
---|
509 | default:
|
---|
510 | DEBUG(10,("smbd_smb2_getinfo_send: "
|
---|
511 | "unknown in_info_type of %u "
|
---|
512 | " for file %s\n",
|
---|
513 | (unsigned int)in_info_type,
|
---|
514 | fsp_str_dbg(fsp) ));
|
---|
515 |
|
---|
516 | tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
---|
517 | return tevent_req_post(req, ev);
|
---|
518 | }
|
---|
519 |
|
---|
520 | state->status = status;
|
---|
521 | tevent_req_done(req);
|
---|
522 | return tevent_req_post(req, ev);
|
---|
523 | }
|
---|
524 |
|
---|
525 | static NTSTATUS smbd_smb2_getinfo_recv(struct tevent_req *req,
|
---|
526 | TALLOC_CTX *mem_ctx,
|
---|
527 | DATA_BLOB *out_output_buffer,
|
---|
528 | NTSTATUS *pstatus)
|
---|
529 | {
|
---|
530 | NTSTATUS status;
|
---|
531 | struct smbd_smb2_getinfo_state *state = tevent_req_data(req,
|
---|
532 | struct smbd_smb2_getinfo_state);
|
---|
533 |
|
---|
534 | if (tevent_req_is_nterror(req, &status)) {
|
---|
535 | tevent_req_received(req);
|
---|
536 | return status;
|
---|
537 | }
|
---|
538 |
|
---|
539 | *out_output_buffer = state->out_output_buffer;
|
---|
540 | talloc_steal(mem_ctx, out_output_buffer->data);
|
---|
541 | *pstatus = state->status;
|
---|
542 |
|
---|
543 | tevent_req_received(req);
|
---|
544 | return NT_STATUS_OK;
|
---|
545 | }
|
---|