2003-11-26 01:16:41 +00:00
/*
Unix SMB / CIFS implementation .
2004-06-20 00:58:09 +00:00
Generic Authentication Interface
2003-11-26 01:16:41 +00:00
Copyright ( C ) Andrew Tridgell 2003
2004-06-20 00:58:09 +00:00
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2004
2003-11-26 01:16:41 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
/*
do a non - athenticated dcerpc bind
*/
NTSTATUS dcerpc_bind_auth_none ( struct dcerpc_pipe * p ,
2004-06-01 10:12:52 +00:00
const char * uuid , uint_t version )
2003-11-26 01:16:41 +00:00
{
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
mem_ctx = talloc_init ( " dcerpc_bind_auth_ntlm " ) ;
if ( ! mem_ctx ) {
return NT_STATUS_NO_MEMORY ;
}
status = dcerpc_bind_byuuid ( p , mem_ctx , uuid , version ) ;
talloc_destroy ( mem_ctx ) ;
return status ;
}
2004-06-07 12:30:22 +00:00
2004-08-25 02:25:20 +00:00
NTSTATUS dcerpc_bind_auth3 ( struct dcerpc_pipe * p , uint8_t auth_type , uint8_t auth_level ,
2004-06-20 00:58:09 +00:00
const char * uuid , uint_t version )
2004-06-07 12:30:22 +00:00
{
NTSTATUS status ;
TALLOC_CTX * mem_ctx ;
DATA_BLOB credentials ;
2004-07-06 02:20:45 +00:00
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
2004-06-07 12:30:22 +00:00
mem_ctx = talloc_init ( " dcerpc_bind_auth " ) ;
if ( ! mem_ctx ) {
return NT_STATUS_NO_MEMORY ;
}
2004-06-20 00:58:09 +00:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
if ( ! p - > security_state . generic_state ) {
status = gensec_client_start ( & p - > security_state . generic_state ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2004-06-20 00:58:09 +00:00
}
2004-08-25 02:25:20 +00:00
status = gensec_start_mech_by_authtype ( p - > security_state . generic_state , auth_type , auth_level ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
2004-06-20 00:58:09 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2004-06-07 12:30:22 +00:00
}
p - > security_state . auth_info = talloc ( p - > mem_ctx , sizeof ( * p - > security_state . auth_info ) ) ;
if ( ! p - > security_state . auth_info ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
p - > security_state . auth_info - > auth_type = auth_type ;
2004-08-25 02:25:20 +00:00
p - > security_state . auth_info - > auth_level = auth_level ;
2004-06-07 12:30:22 +00:00
p - > security_state . auth_info - > auth_pad_length = 0 ;
p - > security_state . auth_info - > auth_reserved = 0 ;
p - > security_state . auth_info - > auth_context_id = random ( ) ;
2004-07-06 02:20:45 +00:00
p - > security_state . auth_info - > credentials = null_data_blob ;
2004-06-07 12:30:22 +00:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
status = gensec_update ( p - > security_state . generic_state , mem_ctx ,
2004-07-06 02:20:45 +00:00
null_data_blob ,
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
& credentials ) ;
2004-06-07 12:30:22 +00:00
if ( ! NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
goto done ;
}
p - > security_state . auth_info - > credentials = credentials ;
status = dcerpc_bind_byuuid ( p , mem_ctx , uuid , version ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
status = gensec_update ( p - > security_state . generic_state , mem_ctx ,
p - > security_state . auth_info - > credentials ,
& credentials ) ;
2004-06-07 12:30:22 +00:00
if ( ! NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
goto done ;
}
p - > security_state . auth_info - > credentials = credentials ;
status = dcerpc_auth3 ( p , mem_ctx ) ;
done :
talloc_destroy ( mem_ctx ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
ZERO_STRUCT ( p - > security_state ) ;
}
return status ;
}
2004-06-20 00:58:09 +00:00
2004-08-25 02:25:20 +00:00
NTSTATUS dcerpc_bind_alter ( struct dcerpc_pipe * p , uint8_t auth_type , uint8_t auth_level ,
2004-07-09 12:26:34 +00:00
const char * uuid , uint_t version )
{
NTSTATUS status ;
TALLOC_CTX * mem_ctx ;
DATA_BLOB credentials ;
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
mem_ctx = talloc_init ( " dcerpc_bind_auth " ) ;
if ( ! mem_ctx ) {
return NT_STATUS_NO_MEMORY ;
}
if ( ! p - > security_state . generic_state ) {
status = gensec_client_start ( & p - > security_state . generic_state ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2004-08-25 02:25:20 +00:00
status = gensec_start_mech_by_authtype ( p - > security_state . generic_state ,
auth_type , auth_level ) ;
2004-07-09 12:26:34 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
}
p - > security_state . auth_info = talloc ( p - > mem_ctx , sizeof ( * p - > security_state . auth_info ) ) ;
if ( ! p - > security_state . auth_info ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
p - > security_state . auth_info - > auth_type = auth_type ;
2004-08-25 02:25:20 +00:00
p - > security_state . auth_info - > auth_level = auth_level ;
2004-07-09 12:26:34 +00:00
p - > security_state . auth_info - > auth_pad_length = 0 ;
p - > security_state . auth_info - > auth_reserved = 0 ;
p - > security_state . auth_info - > auth_context_id = random ( ) ;
p - > security_state . auth_info - > credentials = null_data_blob ;
status = gensec_update ( p - > security_state . generic_state , mem_ctx ,
null_data_blob ,
& credentials ) ;
if ( ! NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
goto done ;
}
p - > security_state . auth_info - > credentials = credentials ;
status = dcerpc_bind_byuuid ( p , mem_ctx , uuid , version ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2004-06-20 00:58:09 +00:00
2004-07-09 12:26:34 +00:00
while ( 1 ) {
status = gensec_update ( p - > security_state . generic_state , mem_ctx ,
p - > security_state . auth_info - > credentials ,
& credentials ) ;
if ( ! NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
goto done ;
}
p - > security_state . auth_info - > credentials = credentials ;
status = dcerpc_alter ( p , mem_ctx ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
}
done :
talloc_destroy ( mem_ctx ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
ZERO_STRUCT ( p - > security_state ) ;
}
return status ;
}