mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
ntlmssp: Add ntlmssp_blob_matches_magic()
This avoids having the same check in 3 different parts of the code Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Wed Aug 3 12:45:04 CEST 2011 on sn-devel-104
This commit is contained in:
parent
d811862b45
commit
fec25c3a62
@ -132,3 +132,13 @@ void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
|
|||||||
ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET;
|
ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Does this blob looks like it could be NTLMSSP? */
|
||||||
|
bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob)
|
||||||
|
{
|
||||||
|
if (blob->length > 8 && memcmp("NTLMSSP\0", blob->data, 8) == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -169,3 +169,5 @@ NTSTATUS ntlmssp_unwrap(struct ntlmssp_state *ntlmssp_stae,
|
|||||||
const DATA_BLOB *in,
|
const DATA_BLOB *in,
|
||||||
DATA_BLOB *out);
|
DATA_BLOB *out);
|
||||||
NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
|
NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
|
||||||
|
|
||||||
|
bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob);
|
||||||
|
@ -1140,7 +1140,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
|
|||||||
* identical regardless. In particular, both rely only on the
|
* identical regardless. In particular, both rely only on the
|
||||||
* status code (not the contents of the packet) and do not
|
* status code (not the contents of the packet) and do not
|
||||||
* wrap the result */
|
* wrap the result */
|
||||||
if (sconn->use_gensec_hook || (blob1.length > 7 && strncmp((char *)(blob1.data), "NTLMSSP", 7) == 0)) {
|
if (sconn->use_gensec_hook || ntlmssp_blob_matches_magic(&blob1)) {
|
||||||
DATA_BLOB chal;
|
DATA_BLOB chal;
|
||||||
|
|
||||||
if (!vuser->auth_ntlmssp_state) {
|
if (!vuser->auth_ntlmssp_state) {
|
||||||
|
@ -753,7 +753,7 @@ static NTSTATUS smbd_smb2_session_setup(struct smbd_smb2_request *smb2req,
|
|||||||
* status code (not the contents of the packet) and do not
|
* status code (not the contents of the packet) and do not
|
||||||
* wrap the result */
|
* wrap the result */
|
||||||
if (session->sconn->use_gensec_hook
|
if (session->sconn->use_gensec_hook
|
||||||
|| (in_security_buffer.length > 7 && strncmp((char *)(in_security_buffer.data), "NTLMSSP", 7) == 0)) {
|
|| ntlmssp_blob_matches_magic(&in_security_buffer)) {
|
||||||
return smbd_smb2_raw_ntlmssp_auth(session,
|
return smbd_smb2_raw_ntlmssp_auth(session,
|
||||||
smb2req,
|
smb2req,
|
||||||
in_security_mode,
|
in_security_mode,
|
||||||
|
@ -63,7 +63,7 @@ static const struct ntlmssp_callbacks {
|
|||||||
static NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
|
static NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
|
||||||
const DATA_BLOB *first_packet)
|
const DATA_BLOB *first_packet)
|
||||||
{
|
{
|
||||||
if (first_packet->length > 8 && memcmp("NTLMSSP\0", first_packet->data, 8) == 0) {
|
if (ntlmssp_blob_matches_magic(first_packet)) {
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
} else {
|
} else {
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user