static int smbd_smb2_session_setup_state_destructor(struct smbd_smb2_session_setup_state *state)
{
/*
- * if state->session is not NULL,
- * we remove the session on failure
+ * If state->session is not NULL,
+ * we move the session from the session table to the request on failure
+ * so that the error response can be correctly signed, but the session
+ * is then really deleted when the request is done.
*/
- TALLOC_FREE(state->session);
+
+ if (state->session == NULL) {
+ return 0;
+ }
+
+ state->session->status = NT_STATUS_USER_SESSION_DELETED;
+ state->smb2req->session = talloc_move(state->smb2req, &state->session);
+
return 0;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
state->out_session_id = state->session->global->session_wire_id;
/* we want to keep the session */
+ state->session = NULL;
TALLOC_FREE(state->pp_self_ref);
tevent_req_nterror(req, status);
return;
return;
}
/* we want to keep the session */
+ state->session = NULL;
TALLOC_FREE(state->pp_self_ref);
tevent_req_done(req);
return;
}
/* we want to keep the session */
+ state->session = NULL;
TALLOC_FREE(state->pp_self_ref);
tevent_req_done(req);
return;
return;
}
/* we want to keep the session */
+ state->session = NULL;
TALLOC_FREE(state->pp_self_ref);
tevent_req_done(req);
return;
}
/* we want to keep the session */
+ state->session = NULL;
TALLOC_FREE(state->pp_self_ref);
tevent_req_done(req);
return;