2 Unix SMB/CIFS implementation.
5 Copyright (C) Stefan Metzmacher 2009
6 Copyright (C) Jeremy Allison 2010
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.
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.
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/>.
23 #include "smbd/smbd.h"
24 #include "smbd/globals.h"
25 #include "../libcli/smb/smb_common.h"
26 #include "../libcli/auth/spnego.h"
27 #include "../libcli/auth/ntlmssp.h"
28 #include "../auth/gensec/gensec.h"
29 #include "ntlmssp_wrap.h"
30 #include "../librpc/gen_ndr/krb5pac.h"
31 #include "libads/kerberos_proto.h"
32 #include "../lib/util/asn1.h"
34 #include "../lib/tsocket/tsocket.h"
35 #include "../libcli/security/security.h"
37 static NTSTATUS smbd_smb2_session_setup(struct smbd_smb2_request *smb2req,
38 uint64_t in_session_id,
39 uint8_t in_security_mode,
40 DATA_BLOB in_security_buffer,
41 uint16_t *out_session_flags,
42 DATA_BLOB *out_security_buffer,
43 uint64_t *out_session_id);
45 NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *smb2req)
48 const uint8_t *inbody;
49 int i = smb2req->current_idx;
53 size_t expected_body_size = 0x19;
55 uint64_t in_session_id;
56 uint8_t in_security_mode;
57 uint16_t in_security_offset;
58 uint16_t in_security_length;
59 DATA_BLOB in_security_buffer;
60 uint16_t out_session_flags;
61 uint64_t out_session_id;
62 uint16_t out_security_offset;
63 DATA_BLOB out_security_buffer;
66 inhdr = (const uint8_t *)smb2req->in.vector[i+0].iov_base;
68 if (smb2req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
69 return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER);
72 inbody = (const uint8_t *)smb2req->in.vector[i+1].iov_base;
74 body_size = SVAL(inbody, 0x00);
75 if (body_size != expected_body_size) {
76 return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER);
79 in_security_offset = SVAL(inbody, 0x0C);
80 in_security_length = SVAL(inbody, 0x0E);
82 if (in_security_offset != (SMB2_HDR_BODY + (body_size & 0xFFFFFFFE))) {
83 return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER);
86 if (in_security_length > smb2req->in.vector[i+2].iov_len) {
87 return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER);
90 in_session_id = BVAL(inhdr, SMB2_HDR_SESSION_ID);
91 in_security_mode = CVAL(inbody, 0x03);
92 in_security_buffer.data = (uint8_t *)smb2req->in.vector[i+2].iov_base;
93 in_security_buffer.length = in_security_length;
95 status = smbd_smb2_session_setup(smb2req,
100 &out_security_buffer,
102 if (!NT_STATUS_IS_OK(status) &&
103 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
104 status = nt_status_squash(status);
105 return smbd_smb2_request_error(smb2req, status);
108 out_security_offset = SMB2_HDR_BODY + 0x08;
110 outhdr = (uint8_t *)smb2req->out.vector[i].iov_base;
112 outbody = data_blob_talloc(smb2req->out.vector, NULL, 0x08);
113 if (outbody.data == NULL) {
114 return smbd_smb2_request_error(smb2req, NT_STATUS_NO_MEMORY);
117 SBVAL(outhdr, SMB2_HDR_SESSION_ID, out_session_id);
119 SSVAL(outbody.data, 0x00, 0x08 + 1); /* struct size */
120 SSVAL(outbody.data, 0x02,
121 out_session_flags); /* session flags */
122 SSVAL(outbody.data, 0x04,
123 out_security_offset); /* security buffer offset */
124 SSVAL(outbody.data, 0x06,
125 out_security_buffer.length); /* security buffer length */
127 outdyn = out_security_buffer;
129 return smbd_smb2_request_done_ex(smb2req, status, outbody, &outdyn,
133 static int smbd_smb2_session_destructor(struct smbd_smb2_session *session)
135 if (session->sconn == NULL) {
139 /* first free all tcons */
140 while (session->tcons.list) {
141 talloc_free(session->tcons.list);
144 idr_remove(session->sconn->smb2.sessions.idtree, session->vuid);
145 DLIST_REMOVE(session->sconn->smb2.sessions.list, session);
146 invalidate_vuid(session->sconn, session->vuid);
149 session->status = NT_STATUS_USER_SESSION_DELETED;
150 session->sconn = NULL;
156 static NTSTATUS smbd_smb2_session_setup_krb5(struct smbd_smb2_session *session,
157 struct smbd_smb2_request *smb2req,
158 uint8_t in_security_mode,
159 const DATA_BLOB *secblob,
161 uint16_t *out_session_flags,
162 DATA_BLOB *out_security_buffer,
163 uint64_t *out_session_id)
165 DATA_BLOB ap_rep = data_blob_null;
166 DATA_BLOB ap_rep_wrapped = data_blob_null;
167 DATA_BLOB ticket = data_blob_null;
168 DATA_BLOB session_key = data_blob_null;
169 DATA_BLOB secblob_out = data_blob_null;
171 struct PAC_LOGON_INFO *logon_info = NULL;
172 char *principal = NULL;
175 struct passwd *pw = NULL;
178 bool username_was_mapped = false;
179 bool map_domainuser_to_guest = false;
181 if (!spnego_parse_krb5_wrap(talloc_tos(), *secblob, &ticket, tok_id)) {
182 status = NT_STATUS_LOGON_FAILURE;
186 status = ads_verify_ticket(smb2req, lp_realm(), 0, &ticket,
187 &principal, &logon_info, &ap_rep,
190 if (!NT_STATUS_IS_OK(status)) {
191 DEBUG(1,("smb2: Failed to verify incoming ticket with error %s!\n",
193 if (!NT_STATUS_EQUAL(status, NT_STATUS_TIME_DIFFERENCE_AT_DC)) {
194 status = NT_STATUS_LOGON_FAILURE;
199 status = get_user_from_kerberos_info(talloc_tos(),
200 session->sconn->remote_hostname,
201 principal, logon_info,
202 &username_was_mapped,
203 &map_domainuser_to_guest,
205 &real_username, &pw);
206 if (!NT_STATUS_IS_OK(status)) {
210 /* save the PAC data if we have it */
212 netsamlogon_cache_store(user, &logon_info->info3);
215 /* setup the string used by %U */
216 sub_set_smb_name(real_username);
218 /* reload services so that the new %U is taken into account */
219 reload_services(smb2req->sconn->msg_ctx, smb2req->sconn->sock, true);
221 status = make_session_info_krb5(session,
222 user, domain, real_username, pw,
223 logon_info, map_domainuser_to_guest,
226 &session->session_info);
227 if (!NT_STATUS_IS_OK(status)) {
228 DEBUG(1, ("smb2: make_server_info_krb5 failed\n"));
232 if ((in_security_mode & SMB2_NEGOTIATE_SIGNING_REQUIRED) ||
233 lp_server_signing() == Required) {
234 session->do_signing = true;
237 if (security_session_user_level(session->session_info, NULL) < SECURITY_USER) {
238 /* we map anonymous to guest internally */
239 *out_session_flags |= SMB2_SESSION_FLAG_IS_GUEST;
240 *out_session_flags |= SMB2_SESSION_FLAG_IS_NULL;
241 /* force no signing */
242 session->do_signing = false;
245 session->session_key = session->session_info->session_key;
247 session->compat_vuser = talloc_zero(session, user_struct);
248 if (session->compat_vuser == NULL) {
249 status = NT_STATUS_NO_MEMORY;
252 session->compat_vuser->auth_ntlmssp_state = NULL;
253 session->compat_vuser->homes_snum = -1;
254 session->compat_vuser->session_info = session->session_info;
255 session->compat_vuser->session_keystr = NULL;
256 session->compat_vuser->vuid = session->vuid;
257 DLIST_ADD(session->sconn->smb1.sessions.validated_users, session->compat_vuser);
259 if (security_session_user_level(session->session_info, NULL) >= SECURITY_USER) {
260 session->compat_vuser->homes_snum =
261 register_homes_share(session->session_info->unix_info->unix_name);
264 if (!session_claim(session->sconn, session->compat_vuser)) {
265 DEBUG(1, ("smb2: Failed to claim session "
267 session->compat_vuser->vuid));
271 session->status = NT_STATUS_OK;
274 * we attach the session to the request
275 * so that the response can be signed
277 smb2req->session = session;
278 if (session->do_signing) {
279 smb2req->do_signing = true;
282 global_client_caps |= (CAP_LEVEL_II_OPLOCKS|CAP_STATUS32);
283 status = NT_STATUS_OK;
285 /* wrap that up in a nice GSS-API wrapping */
286 ap_rep_wrapped = spnego_gen_krb5_wrap(talloc_tos(), ap_rep,
289 secblob_out = spnego_gen_auth_response(
295 *out_security_buffer = data_blob_talloc(smb2req,
298 if (secblob_out.data && out_security_buffer->data == NULL) {
299 status = NT_STATUS_NO_MEMORY;
303 data_blob_free(&ap_rep);
304 data_blob_free(&ap_rep_wrapped);
305 data_blob_free(&ticket);
306 data_blob_free(&session_key);
307 data_blob_free(&secblob_out);
309 *out_session_id = session->vuid;
315 data_blob_free(&ap_rep);
316 data_blob_free(&ap_rep_wrapped);
317 data_blob_free(&ticket);
318 data_blob_free(&session_key);
319 data_blob_free(&secblob_out);
321 ap_rep_wrapped = data_blob_null;
322 secblob_out = spnego_gen_auth_response(
328 *out_security_buffer = data_blob_talloc(smb2req,
331 data_blob_free(&secblob_out);
336 static NTSTATUS smbd_smb2_spnego_negotiate(struct smbd_smb2_session *session,
337 struct smbd_smb2_request *smb2req,
338 uint8_t in_security_mode,
339 DATA_BLOB in_security_buffer,
340 uint16_t *out_session_flags,
341 DATA_BLOB *out_security_buffer,
342 uint64_t *out_session_id)
344 DATA_BLOB secblob_in = data_blob_null;
345 DATA_BLOB chal_out = data_blob_null;
346 char *kerb_mech = NULL;
349 /* Ensure we have no old NTLM state around. */
350 TALLOC_FREE(session->auth_ntlmssp_state);
352 status = parse_spnego_mechanisms(talloc_tos(), in_security_buffer,
353 &secblob_in, &kerb_mech);
354 if (!NT_STATUS_IS_OK(status)) {
359 if (kerb_mech && ((lp_security()==SEC_ADS) ||
360 USE_KERBEROS_KEYTAB) ) {
361 status = smbd_smb2_session_setup_krb5(session,
375 /* The mechtoken is a krb5 ticket, but
376 * we need to fall back to NTLM. */
378 DEBUG(3,("smb2: Got krb5 ticket in SPNEGO "
379 "but set to downgrade to NTLMSSP\n"));
381 status = NT_STATUS_MORE_PROCESSING_REQUIRED;
383 /* Fall back to NTLMSSP. */
384 status = auth_ntlmssp_prepare(session->sconn->remote_address,
385 &session->auth_ntlmssp_state);
386 if (!NT_STATUS_IS_OK(status)) {
390 auth_ntlmssp_want_feature(session->auth_ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
392 status = auth_ntlmssp_start(session->auth_ntlmssp_state);
393 if (!NT_STATUS_IS_OK(status)) {
397 status = auth_ntlmssp_update(session->auth_ntlmssp_state,
403 if (!NT_STATUS_IS_OK(status) &&
404 !NT_STATUS_EQUAL(status,
405 NT_STATUS_MORE_PROCESSING_REQUIRED)) {
409 *out_security_buffer = spnego_gen_auth_response(smb2req,
413 if (out_security_buffer->data == NULL) {
414 status = NT_STATUS_NO_MEMORY;
417 *out_session_id = session->vuid;
421 data_blob_free(&secblob_in);
422 data_blob_free(&chal_out);
423 TALLOC_FREE(kerb_mech);
424 if (!NT_STATUS_IS_OK(status) &&
425 !NT_STATUS_EQUAL(status,
426 NT_STATUS_MORE_PROCESSING_REQUIRED)) {
427 TALLOC_FREE(session->auth_ntlmssp_state);
428 TALLOC_FREE(session);
433 static NTSTATUS smbd_smb2_common_ntlmssp_auth_return(struct smbd_smb2_session *session,
434 struct smbd_smb2_request *smb2req,
435 uint8_t in_security_mode,
436 DATA_BLOB in_security_buffer,
437 uint16_t *out_session_flags,
438 uint64_t *out_session_id)
440 if ((in_security_mode & SMB2_NEGOTIATE_SIGNING_REQUIRED) ||
441 lp_server_signing() == Required) {
442 session->do_signing = true;
445 if (security_session_user_level(session->session_info, NULL) < SECURITY_USER) {
446 /* we map anonymous to guest internally */
447 *out_session_flags |= SMB2_SESSION_FLAG_IS_GUEST;
448 *out_session_flags |= SMB2_SESSION_FLAG_IS_NULL;
449 /* force no signing */
450 session->do_signing = false;
453 session->session_key = session->session_info->session_key;
455 session->compat_vuser = talloc_zero(session, user_struct);
456 if (session->compat_vuser == NULL) {
457 TALLOC_FREE(session->auth_ntlmssp_state);
458 TALLOC_FREE(session);
459 return NT_STATUS_NO_MEMORY;
461 session->compat_vuser->auth_ntlmssp_state = session->auth_ntlmssp_state;
462 session->compat_vuser->homes_snum = -1;
463 session->compat_vuser->session_info = session->session_info;
464 session->compat_vuser->session_keystr = NULL;
465 session->compat_vuser->vuid = session->vuid;
466 DLIST_ADD(session->sconn->smb1.sessions.validated_users, session->compat_vuser);
468 if (security_session_user_level(session->session_info, NULL) >= SECURITY_USER) {
469 session->compat_vuser->homes_snum =
470 register_homes_share(session->session_info->unix_info->unix_name);
473 if (!session_claim(session->sconn, session->compat_vuser)) {
474 DEBUG(1, ("smb2: Failed to claim session "
476 session->compat_vuser->vuid));
477 TALLOC_FREE(session->auth_ntlmssp_state);
478 TALLOC_FREE(session);
479 return NT_STATUS_LOGON_FAILURE;
483 session->status = NT_STATUS_OK;
486 * we attach the session to the request
487 * so that the response can be signed
489 smb2req->session = session;
490 if (session->do_signing) {
491 smb2req->do_signing = true;
494 global_client_caps |= (CAP_LEVEL_II_OPLOCKS|CAP_STATUS32);
496 *out_session_id = session->vuid;
501 static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
502 struct smbd_smb2_request *smb2req,
503 uint8_t in_security_mode,
504 DATA_BLOB in_security_buffer,
505 uint16_t *out_session_flags,
506 DATA_BLOB *out_security_buffer,
507 uint64_t *out_session_id)
509 DATA_BLOB auth = data_blob_null;
510 DATA_BLOB auth_out = data_blob_null;
513 if (!spnego_parse_auth(talloc_tos(), in_security_buffer, &auth)) {
514 TALLOC_FREE(session);
515 return NT_STATUS_LOGON_FAILURE;
518 if (auth.data[0] == ASN1_APPLICATION(0)) {
519 /* Might be a second negTokenTarg packet */
520 DATA_BLOB secblob_in = data_blob_null;
521 char *kerb_mech = NULL;
523 status = parse_spnego_mechanisms(talloc_tos(),
525 &secblob_in, &kerb_mech);
526 if (!NT_STATUS_IS_OK(status)) {
527 TALLOC_FREE(session);
532 if (kerb_mech && ((lp_security()==SEC_ADS) ||
533 USE_KERBEROS_KEYTAB) ) {
534 status = smbd_smb2_session_setup_krb5(session,
543 data_blob_free(&secblob_in);
544 TALLOC_FREE(kerb_mech);
545 if (!NT_STATUS_IS_OK(status)) {
546 TALLOC_FREE(session);
552 /* Can't blunder into NTLMSSP auth if we have
556 DEBUG(3,("smb2: network "
557 "misconfiguration, client sent us a "
558 "krb5 ticket and kerberos security "
560 TALLOC_FREE(session);
561 data_blob_free(&secblob_in);
562 TALLOC_FREE(kerb_mech);
563 return NT_STATUS_LOGON_FAILURE;
566 data_blob_free(&secblob_in);
569 if (session->auth_ntlmssp_state == NULL) {
570 status = auth_ntlmssp_prepare(session->sconn->remote_address,
571 &session->auth_ntlmssp_state);
572 if (!NT_STATUS_IS_OK(status)) {
573 data_blob_free(&auth);
574 TALLOC_FREE(session);
578 auth_ntlmssp_want_feature(session->auth_ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
580 status = auth_ntlmssp_start(session->auth_ntlmssp_state);
581 if (!NT_STATUS_IS_OK(status)) {
582 data_blob_free(&auth);
583 TALLOC_FREE(session);
588 status = auth_ntlmssp_update(session->auth_ntlmssp_state,
591 /* If status is NT_STATUS_OK then we need to get the token.
592 * Map to guest is now internal to auth_ntlmssp */
593 if (NT_STATUS_IS_OK(status)) {
594 status = auth_ntlmssp_steal_session_info(session,
595 session->auth_ntlmssp_state,
596 &session->session_info);
599 if (!NT_STATUS_IS_OK(status) &&
600 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
601 TALLOC_FREE(session->auth_ntlmssp_state);
602 data_blob_free(&auth);
603 TALLOC_FREE(session);
607 data_blob_free(&auth);
609 *out_security_buffer = spnego_gen_auth_response(smb2req,
610 &auth_out, status, NULL);
612 if (out_security_buffer->data == NULL) {
613 TALLOC_FREE(session->auth_ntlmssp_state);
614 TALLOC_FREE(session);
615 return NT_STATUS_NO_MEMORY;
618 *out_session_id = session->vuid;
620 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
621 return NT_STATUS_MORE_PROCESSING_REQUIRED;
624 /* We're done - claim the session. */
625 return smbd_smb2_common_ntlmssp_auth_return(session,
633 static NTSTATUS smbd_smb2_raw_ntlmssp_auth(struct smbd_smb2_session *session,
634 struct smbd_smb2_request *smb2req,
635 uint8_t in_security_mode,
636 DATA_BLOB in_security_buffer,
637 uint16_t *out_session_flags,
638 DATA_BLOB *out_security_buffer,
639 uint64_t *out_session_id)
643 if (session->auth_ntlmssp_state == NULL) {
644 status = auth_ntlmssp_prepare(session->sconn->remote_address,
645 &session->auth_ntlmssp_state);
646 if (!NT_STATUS_IS_OK(status)) {
647 TALLOC_FREE(session);
651 auth_ntlmssp_want_feature(session->auth_ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
653 if (session->sconn->use_gensec_hook) {
654 status = auth_generic_start(session->auth_ntlmssp_state, GENSEC_OID_SPNEGO);
656 status = auth_ntlmssp_start(session->auth_ntlmssp_state);
658 if (!NT_STATUS_IS_OK(status)) {
659 TALLOC_FREE(session);
665 status = auth_ntlmssp_update(session->auth_ntlmssp_state,
668 out_security_buffer);
670 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
671 *out_session_id = session->vuid;
675 status = auth_ntlmssp_steal_session_info(session,
676 session->auth_ntlmssp_state,
677 &session->session_info);
679 if (!NT_STATUS_IS_OK(status)) {
680 TALLOC_FREE(session->auth_ntlmssp_state);
681 TALLOC_FREE(session);
684 *out_session_id = session->vuid;
686 return smbd_smb2_common_ntlmssp_auth_return(session,
694 static NTSTATUS smbd_smb2_session_setup(struct smbd_smb2_request *smb2req,
695 uint64_t in_session_id,
696 uint8_t in_security_mode,
697 DATA_BLOB in_security_buffer,
698 uint16_t *out_session_flags,
699 DATA_BLOB *out_security_buffer,
700 uint64_t *out_session_id)
702 struct smbd_smb2_session *session;
704 *out_session_flags = 0;
707 if (in_session_id == 0) {
710 /* create a new session */
711 session = talloc_zero(smb2req->sconn, struct smbd_smb2_session);
712 if (session == NULL) {
713 return NT_STATUS_NO_MEMORY;
715 session->status = NT_STATUS_MORE_PROCESSING_REQUIRED;
716 id = idr_get_new_random(smb2req->sconn->smb2.sessions.idtree,
718 smb2req->sconn->smb2.sessions.limit);
720 return NT_STATUS_INSUFFICIENT_RESOURCES;
724 session->tcons.idtree = idr_init(session);
725 if (session->tcons.idtree == NULL) {
726 return NT_STATUS_NO_MEMORY;
728 session->tcons.limit = 0x0000FFFE;
729 session->tcons.list = NULL;
731 DLIST_ADD_END(smb2req->sconn->smb2.sessions.list, session,
732 struct smbd_smb2_session *);
733 session->sconn = smb2req->sconn;
734 talloc_set_destructor(session, smbd_smb2_session_destructor);
738 /* lookup an existing session */
739 p = idr_find(smb2req->sconn->smb2.sessions.idtree, in_session_id);
741 return NT_STATUS_USER_SESSION_DELETED;
743 session = talloc_get_type_abort(p, struct smbd_smb2_session);
746 if (NT_STATUS_IS_OK(session->status)) {
747 return NT_STATUS_REQUEST_NOT_ACCEPTED;
750 /* Handle either raw NTLMSSP or hand off the whole blob to
751 * GENSEC. The processing at this layer is essentially
752 * identical regardless. In particular, both rely only on the
753 * status code (not the contents of the packet) and do not
755 if (session->sconn->use_gensec_hook
756 || (in_security_buffer.length > 7 && strncmp((char *)(in_security_buffer.data), "NTLMSSP", 7) == 0)) {
757 return smbd_smb2_raw_ntlmssp_auth(session,
764 } else if (in_security_buffer.data[0] == ASN1_APPLICATION(0)) {
765 return smbd_smb2_spnego_negotiate(session,
772 } else if (in_security_buffer.data[0] == ASN1_CONTEXT(1)) {
773 return smbd_smb2_spnego_auth(session,
782 /* Unknown packet type. */
783 DEBUG(1,("Unknown packet type %u in smb2 sessionsetup\n",
784 (unsigned int)in_security_buffer.data[0] ));
785 TALLOC_FREE(session->auth_ntlmssp_state);
786 TALLOC_FREE(session);
787 return NT_STATUS_LOGON_FAILURE;
790 NTSTATUS smbd_smb2_request_process_logoff(struct smbd_smb2_request *req)
792 const uint8_t *inbody;
793 int i = req->current_idx;
795 size_t expected_body_size = 0x04;
798 if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
799 return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
802 inbody = (const uint8_t *)req->in.vector[i+1].iov_base;
804 body_size = SVAL(inbody, 0x00);
805 if (body_size != expected_body_size) {
806 return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
810 * TODO: cancel all outstanding requests on the session
811 * and delete all tree connections.
813 smbd_smb2_session_destructor(req->session);
815 * we may need to sign the response, so we need to keep
816 * the session until the response is sent to the wire.
818 talloc_steal(req, req->session);
820 outbody = data_blob_talloc(req->out.vector, NULL, 0x04);
821 if (outbody.data == NULL) {
822 return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
825 SSVAL(outbody.data, 0x00, 0x04); /* struct size */
826 SSVAL(outbody.data, 0x02, 0); /* reserved */
828 return smbd_smb2_request_done(req, outbody, NULL);