2004-06-19 12:15:41 +04:00
/*
Unix SMB / CIFS implementation .
RFC2478 Compliant SPNEGO implementation
2012-09-18 21:34:48 +04:00
2004-06-20 04:58:09 +04:00
Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2003
2005-09-02 03:23:22 +04:00
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2004 - 2005
2008-08-12 16:26:21 +04:00
Copyright ( C ) Stefan Metzmacher < metze @ samba . org > 2004 - 2008
2004-06-19 12:15:41 +04: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
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2004-06-19 12:15:41 +04:00
( at your option ) any later version .
2012-09-18 21:34:48 +04:00
2004-06-19 12:15:41 +04:00
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 .
2012-09-18 21:34:48 +04:00
2004-06-19 12:15:41 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2004-06-19 12:15:41 +04:00
*/
# include "includes.h"
2009-09-17 02:21:01 +04:00
# include "../libcli/auth/spnego.h"
2006-03-18 18:42:57 +03:00
# include "librpc/gen_ndr/ndr_dcerpc.h"
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials.h"
# include "auth/gensec/gensec.h"
2010-05-13 01:59:41 +04:00
# include "param/param.h"
2011-12-24 03:27:45 +04:00
# include "lib/util/asn1.h"
2004-06-19 12:15:41 +04:00
2012-01-12 18:42:08 +04:00
# undef strcasecmp
2011-03-19 02:44:20 +03:00
_PUBLIC_ NTSTATUS gensec_spnego_init ( void ) ;
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 13:40:10 +04:00
enum spnego_state_position {
SPNEGO_SERVER_START ,
2004-07-06 07:02:33 +04:00
SPNEGO_CLIENT_START ,
2004-07-06 21:53:44 +04:00
SPNEGO_SERVER_TARG ,
SPNEGO_CLIENT_TARG ,
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 13:40:10 +04:00
SPNEGO_FALLBACK ,
SPNEGO_DONE
} ;
struct spnego_state {
enum spnego_message_type expected_packet ;
2004-07-07 03:20:23 +04:00
enum spnego_state_position state_position ;
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 13:40:10 +04:00
struct gensec_security * sub_sec_security ;
2007-10-07 02:16:19 +04:00
bool no_response_expected ;
2005-05-16 03:42:11 +04:00
const char * neg_oid ;
2008-08-12 16:26:21 +04:00
DATA_BLOB mech_types ;
2011-12-24 03:27:45 +04:00
/*
* The following is used to implement
* the update token fragmentation
*/
size_t in_needed ;
DATA_BLOB in_frag ;
size_t out_max_length ;
DATA_BLOB out_frag ;
NTSTATUS out_status ;
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 13:40:10 +04:00
} ;
2004-12-24 12:54:23 +03:00
2007-12-03 19:41:50 +03:00
static NTSTATUS gensec_spnego_client_start ( struct gensec_security * gensec_security )
2004-06-19 12:15:41 +04:00
{
2004-06-20 04:58:09 +04:00
struct spnego_state * spnego_state ;
2004-09-26 06:16:25 +04:00
2011-12-24 03:27:45 +04:00
spnego_state = talloc_zero ( gensec_security , struct spnego_state ) ;
2004-06-20 04:58:09 +04:00
if ( ! spnego_state ) {
return NT_STATUS_NO_MEMORY ;
2004-06-19 12:15:41 +04:00
}
2004-06-20 04:58:09 +04:00
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_INIT ;
2004-07-06 07:02:33 +04:00
spnego_state - > state_position = SPNEGO_CLIENT_START ;
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 13:40:10 +04:00
spnego_state - > sub_sec_security = NULL ;
2007-10-07 02:16:19 +04:00
spnego_state - > no_response_expected = false ;
2008-08-12 16:26:21 +04:00
spnego_state - > mech_types = data_blob ( NULL , 0 ) ;
2011-12-24 03:27:45 +04:00
spnego_state - > out_max_length = gensec_max_update_size ( gensec_security ) ;
spnego_state - > out_status = NT_STATUS_MORE_PROCESSING_REQUIRED ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
gensec_security - > private_data = spnego_state ;
return NT_STATUS_OK ;
2004-06-19 12:15:41 +04:00
}
2004-08-11 22:09:40 +04:00
static NTSTATUS gensec_spnego_server_start ( struct gensec_security * gensec_security )
{
struct spnego_state * spnego_state ;
2004-09-26 06:16:25 +04:00
2011-12-24 03:27:45 +04:00
spnego_state = talloc_zero ( gensec_security , struct spnego_state ) ;
2004-08-11 22:09:40 +04:00
if ( ! spnego_state ) {
return NT_STATUS_NO_MEMORY ;
}
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_INIT ;
spnego_state - > state_position = SPNEGO_SERVER_START ;
spnego_state - > sub_sec_security = NULL ;
2007-10-07 02:16:19 +04:00
spnego_state - > no_response_expected = false ;
2008-08-12 16:26:21 +04:00
spnego_state - > mech_types = data_blob ( NULL , 0 ) ;
2011-12-24 03:27:45 +04:00
spnego_state - > out_max_length = gensec_max_update_size ( gensec_security ) ;
spnego_state - > out_status = NT_STATUS_MORE_PROCESSING_REQUIRED ;
2004-08-11 22:09:40 +04:00
gensec_security - > private_data = spnego_state ;
return NT_STATUS_OK ;
}
2004-06-20 04:58:09 +04:00
/*
wrappers for the spnego_ * ( ) functions
*/
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 13:40:10 +04:00
static NTSTATUS gensec_spnego_unseal_packet ( struct gensec_security * gensec_security ,
2004-09-11 19:11:36 +04:00
uint8_t * data , size_t length ,
const uint8_t * whole_pdu , size_t pdu_length ,
2005-05-04 10:24:53 +04:00
const DATA_BLOB * sig )
2004-06-19 12:15:41 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2012-09-18 21:34:48 +04: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 13:40:10 +04:00
return gensec_unseal_packet ( spnego_state - > sub_sec_security ,
2004-09-11 19:11:36 +04:00
data , length ,
whole_pdu , pdu_length ,
sig ) ;
2004-06-20 04:58:09 +04:00
}
2004-06-19 12:15:41 +04: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 13:40:10 +04:00
static NTSTATUS gensec_spnego_check_packet ( struct gensec_security * gensec_security ,
2004-09-11 19:11:36 +04:00
const uint8_t * data , size_t length ,
const uint8_t * whole_pdu , size_t pdu_length ,
const DATA_BLOB * sig )
2004-06-20 04:58:09 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2012-09-18 21:34:48 +04: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 13:40:10 +04:00
return gensec_check_packet ( spnego_state - > sub_sec_security ,
2004-09-11 19:11:36 +04:00
data , length ,
whole_pdu , pdu_length ,
sig ) ;
2004-06-20 04:58:09 +04:00
}
2004-06-19 12:15:41 +04: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 13:40:10 +04:00
static NTSTATUS gensec_spnego_seal_packet ( struct gensec_security * gensec_security ,
2004-09-11 19:11:36 +04:00
TALLOC_CTX * mem_ctx ,
uint8_t * data , size_t length ,
const uint8_t * whole_pdu , size_t pdu_length ,
DATA_BLOB * sig )
2004-06-20 04:58:09 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2012-09-18 21:34:48 +04: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 13:40:10 +04:00
return gensec_seal_packet ( spnego_state - > sub_sec_security ,
2004-09-11 19:11:36 +04:00
mem_ctx ,
data , length ,
whole_pdu , pdu_length ,
sig ) ;
2004-06-20 04:58:09 +04:00
}
2004-06-19 12:15:41 +04: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 13:40:10 +04:00
static NTSTATUS gensec_spnego_sign_packet ( struct gensec_security * gensec_security ,
2004-09-11 19:11:36 +04:00
TALLOC_CTX * mem_ctx ,
const uint8_t * data , size_t length ,
const uint8_t * whole_pdu , size_t pdu_length ,
DATA_BLOB * sig )
2004-06-20 04:58:09 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04: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 13:40:10 +04:00
return gensec_sign_packet ( spnego_state - > sub_sec_security ,
2004-09-11 19:11:36 +04:00
mem_ctx ,
data , length ,
whole_pdu , pdu_length ,
sig ) ;
}
2005-01-01 01:45:11 +03:00
static NTSTATUS gensec_spnego_wrap ( struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const DATA_BLOB * in ,
DATA_BLOB * out )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2005-01-01 01:45:11 +03:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
DEBUG ( 1 , ( " gensec_spnego_wrap: wrong state for wrap \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2005-01-01 01:45:11 +03:00
return gensec_wrap ( spnego_state - > sub_sec_security ,
mem_ctx , in , out ) ;
}
static NTSTATUS gensec_spnego_unwrap ( struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const DATA_BLOB * in ,
DATA_BLOB * out )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2005-01-01 01:45:11 +03:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
DEBUG ( 1 , ( " gensec_spnego_unwrap: wrong state for unwrap \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2005-01-01 01:45:11 +03:00
return gensec_unwrap ( spnego_state - > sub_sec_security ,
mem_ctx , in , out ) ;
}
2006-09-05 13:42:54 +04:00
static NTSTATUS gensec_spnego_wrap_packets ( struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const DATA_BLOB * in ,
DATA_BLOB * out ,
size_t * len_processed )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2006-09-05 13:42:54 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
DEBUG ( 1 , ( " gensec_spnego_wrap: wrong state for wrap \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2006-09-05 13:42:54 +04:00
return gensec_wrap_packets ( spnego_state - > sub_sec_security ,
mem_ctx , in , out ,
len_processed ) ;
}
static NTSTATUS gensec_spnego_packet_full_request ( struct gensec_security * gensec_security ,
DATA_BLOB blob , size_t * size )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2006-09-05 13:42:54 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
DEBUG ( 1 , ( " gensec_spnego_unwrap: wrong state for unwrap \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2006-09-05 13:42:54 +04:00
return gensec_packet_full_request ( spnego_state - > sub_sec_security ,
blob , size ) ;
}
static NTSTATUS gensec_spnego_unwrap_packets ( struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const DATA_BLOB * in ,
DATA_BLOB * out ,
size_t * len_processed )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2006-09-05 13:42:54 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
DEBUG ( 1 , ( " gensec_spnego_unwrap: wrong state for unwrap \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2006-09-05 13:42:54 +04:00
return gensec_unwrap_packets ( spnego_state - > sub_sec_security ,
mem_ctx , in , out ,
len_processed ) ;
}
2005-09-11 15:19:02 +04:00
static size_t gensec_spnego_sig_size ( struct gensec_security * gensec_security , size_t data_size )
2004-09-11 19:11:36 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-09-11 19:11:36 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return 0 ;
}
2012-09-18 21:34:48 +04:00
2005-09-11 15:19:02 +04:00
return gensec_sig_size ( spnego_state - > sub_sec_security , data_size ) ;
2004-06-19 12:15:41 +04:00
}
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
static size_t gensec_spnego_max_input_size ( struct gensec_security * gensec_security )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return 0 ;
}
2012-09-18 21:34:48 +04:00
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
return gensec_max_input_size ( spnego_state - > sub_sec_security ) ;
}
static size_t gensec_spnego_max_wrapped_size ( struct gensec_security * gensec_security )
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
if ( spnego_state - > state_position ! = SPNEGO_DONE
& & spnego_state - > state_position ! = SPNEGO_FALLBACK ) {
return 0 ;
}
2012-09-18 21:34:48 +04:00
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
return gensec_max_wrapped_size ( spnego_state - > sub_sec_security ) ;
}
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 13:40:10 +04:00
static NTSTATUS gensec_spnego_session_key ( struct gensec_security * gensec_security ,
2011-08-01 09:39:01 +04:00
TALLOC_CTX * mem_ctx ,
2004-09-11 19:11:36 +04:00
DATA_BLOB * session_key )
2004-06-19 12:15:41 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-07-16 06:54:57 +04:00
if ( ! spnego_state - > sub_sec_security ) {
2004-06-20 04:58:09 +04:00
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2012-09-18 21:34:48 +04: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 13:40:10 +04:00
return gensec_session_key ( spnego_state - > sub_sec_security ,
2011-08-01 09:39:01 +04:00
mem_ctx ,
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 13:40:10 +04:00
session_key ) ;
2004-06-19 12:15:41 +04:00
}
2004-08-11 22:09:40 +04:00
static NTSTATUS gensec_spnego_session_info ( struct gensec_security * gensec_security ,
2011-08-01 09:39:01 +04:00
TALLOC_CTX * mem_ctx ,
struct auth_session_info * * session_info )
2004-08-11 22:09:40 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-08-11 22:09:40 +04:00
if ( ! spnego_state - > sub_sec_security ) {
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-08-11 22:09:40 +04:00
return gensec_session_info ( spnego_state - > sub_sec_security ,
2011-08-01 09:39:01 +04:00
mem_ctx ,
2004-08-11 22:09:40 +04:00
session_info ) ;
}
2004-07-06 07:02:33 +04:00
/** Fallback to another GENSEC mechanism, based on magic strings
*
2004-07-12 13:11:13 +04:00
* This is the ' fallback ' case , where we don ' t get SPNEGO , and have to
2004-07-06 07:02:33 +04:00
* try all the other options ( and hope they all have a magic string
* they check )
*/
2004-07-12 13:11:13 +04:00
static NTSTATUS gensec_spnego_server_try_fallback ( struct gensec_security * gensec_security ,
2004-07-06 07:02:33 +04:00
struct spnego_state * spnego_state ,
2011-10-17 11:22:33 +04:00
struct tevent_context * ev ,
2004-07-06 07:02:33 +04:00
TALLOC_CTX * out_mem_ctx ,
const DATA_BLOB in , DATA_BLOB * out )
{
2005-05-16 03:42:11 +04:00
int i , j ;
2006-01-28 15:15:24 +03:00
struct gensec_security_ops * * all_ops
= gensec_security_mechs ( gensec_security , out_mem_ctx ) ;
2005-12-05 06:20:40 +03:00
for ( i = 0 ; all_ops [ i ] ; i + + ) {
2007-10-07 02:16:19 +04:00
bool is_spnego ;
2004-07-06 07:02:33 +04:00
NTSTATUS nt_status ;
2008-11-02 21:28:17 +03:00
2008-11-03 01:58:49 +03:00
if ( gensec_security ! = NULL & &
2009-09-26 22:55:18 +04:00
! gensec_security_ops_enabled ( all_ops [ i ] , gensec_security ) )
2008-11-02 21:28:17 +03:00
continue ;
2004-07-06 07:02:33 +04:00
if ( ! all_ops [ i ] - > oid ) {
continue ;
}
2005-05-16 03:42:11 +04:00
2007-10-07 02:16:19 +04:00
is_spnego = false ;
2005-05-16 03:42:11 +04:00
for ( j = 0 ; all_ops [ i ] - > oid [ j ] ; j + + ) {
if ( strcasecmp ( GENSEC_OID_SPNEGO , all_ops [ i ] - > oid [ j ] ) = = 0 ) {
2007-10-07 02:16:19 +04:00
is_spnego = true ;
2005-05-16 03:42:11 +04:00
}
}
if ( is_spnego ) {
2004-11-15 23:31:12 +03:00
continue ;
}
2005-06-22 06:12:26 +04:00
if ( ! all_ops [ i ] - > magic ) {
continue ;
}
nt_status = all_ops [ i ] - > magic ( gensec_security , & in ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
continue ;
}
spnego_state - > state_position = SPNEGO_FALLBACK ;
2004-12-24 12:54:23 +03:00
nt_status = gensec_subcontext_start ( spnego_state ,
gensec_security ,
2004-07-06 07:02:33 +04:00
& spnego_state - > sub_sec_security ) ;
2005-06-22 06:12:26 +04:00
2004-07-06 07:02:33 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
return nt_status ;
}
/* select the sub context */
2005-05-16 03:42:11 +04:00
nt_status = gensec_start_mech_by_ops ( spnego_state - > sub_sec_security ,
all_ops [ i ] ) ;
2004-07-06 07:02:33 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2005-06-22 06:12:26 +04:00
return nt_status ;
2004-07-06 07:02:33 +04:00
}
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
2011-10-17 11:22:33 +04:00
ev , out_mem_ctx , in , out ) ;
2005-06-22 06:12:26 +04:00
return nt_status ;
2004-07-06 07:02:33 +04:00
}
2004-07-12 13:11:13 +04:00
DEBUG ( 1 , ( " Failed to parse SPNEGO request \n " ) ) ;
2004-07-06 07:02:33 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2005-01-21 14:10:03 +03:00
/*
2005-05-16 03:42:11 +04:00
Parse the netTokenInit , either from the client , to the server , or
from the server to the client .
2005-01-21 14:10:03 +03:00
*/
2005-05-16 03:42:11 +04:00
static NTSTATUS gensec_spnego_parse_negTokenInit ( struct gensec_security * gensec_security ,
struct spnego_state * spnego_state ,
TALLOC_CTX * out_mem_ctx ,
2011-10-17 11:22:33 +04:00
struct tevent_context * ev ,
2005-05-16 03:42:11 +04:00
const char * * mechType ,
const DATA_BLOB unwrapped_in , DATA_BLOB * unwrapped_out )
2004-08-11 22:09:40 +04:00
{
int i ;
2005-05-16 03:42:11 +04:00
NTSTATUS nt_status = NT_STATUS_INVALID_PARAMETER ;
2004-08-11 22:09:40 +04:00
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
2008-08-12 16:26:21 +04:00
bool ok ;
2004-08-11 22:09:40 +04:00
2005-05-16 03:42:11 +04:00
const struct gensec_security_ops_wrapper * all_sec
2005-12-05 06:20:40 +03:00
= gensec_security_by_oid_list ( gensec_security ,
out_mem_ctx ,
2005-05-16 03:42:11 +04:00
mechType ,
GENSEC_OID_SPNEGO ) ;
2008-08-12 16:26:21 +04:00
ok = spnego_write_mech_types ( spnego_state ,
mechType ,
& spnego_state - > mech_types ) ;
if ( ! ok ) {
DEBUG ( 1 , ( " SPNEGO: Failed to write mechTypes \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
2005-12-22 23:34:00 +03:00
if ( spnego_state - > state_position = = SPNEGO_SERVER_START ) {
2010-12-01 09:02:15 +03:00
uint32_t j ;
for ( j = 0 ; mechType & & mechType [ j ] ; j + + ) {
for ( i = 0 ; all_sec & & all_sec [ i ] . op ; i + + ) {
2011-11-30 18:17:05 +04:00
if ( strcmp ( mechType [ j ] , all_sec [ i ] . oid ) ! = 0 ) {
continue ;
}
2005-12-22 23:34:00 +03:00
nt_status = gensec_subcontext_start ( spnego_state ,
gensec_security ,
& spnego_state - > sub_sec_security ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
return nt_status ;
}
/* select the sub context */
nt_status = gensec_start_mech_by_ops ( spnego_state - > sub_sec_security ,
all_sec [ i ] . op ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
break ;
}
2010-12-01 09:02:15 +03:00
if ( j > 0 ) {
/* no optimistic token */
spnego_state - > neg_oid = all_sec [ i ] . oid ;
* unwrapped_out = data_blob_null ;
nt_status = NT_STATUS_MORE_PROCESSING_REQUIRED ;
break ;
}
2005-12-22 23:34:00 +03:00
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
out_mem_ctx ,
2011-10-17 11:22:33 +04:00
ev ,
2005-12-22 23:34:00 +03:00
unwrapped_in ,
unwrapped_out ) ;
2006-01-28 15:15:24 +03:00
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_INVALID_PARAMETER ) | |
NT_STATUS_EQUAL ( nt_status , NT_STATUS_CANT_ACCESS_DOMAIN_INFO ) ) {
2005-12-22 23:34:00 +03:00
/* Pretend we never started it (lets the first run find some incompatible demand) */
2012-09-18 21:34:48 +04:00
2007-04-17 07:49:08 +04:00
DEBUG ( 1 , ( " SPNEGO(%s) NEG_TOKEN_INIT failed to parse contents: %s \n " ,
2005-12-22 23:34:00 +03:00
spnego_state - > sub_sec_security - > ops - > name , nt_errstr ( nt_status ) ) ) ;
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
break ;
}
spnego_state - > neg_oid = all_sec [ i ] . oid ;
2005-12-23 00:43:16 +03:00
break ;
2005-12-22 23:34:00 +03:00
}
2010-12-01 09:02:15 +03:00
if ( spnego_state - > sub_sec_security ) {
break ;
}
}
if ( ! spnego_state - > sub_sec_security ) {
DEBUG ( 1 , ( " SPNEGO: Could not find a suitable mechtype in NEG_TOKEN_INIT \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
2004-08-11 22:09:40 +04:00
}
2005-12-22 23:34:00 +03:00
}
2012-09-18 21:34:48 +04:00
2010-09-14 20:20:08 +04:00
/* Having tried any optimistic token from the client (if we
2006-02-21 03:17:52 +03:00
* were the server ) , if we didn ' t get anywhere , walk our list
* in our preference order */
2012-09-18 21:34:48 +04:00
2005-12-22 23:34:00 +03:00
if ( ! spnego_state - > sub_sec_security ) {
for ( i = 0 ; all_sec & & all_sec [ i ] . op ; i + + ) {
nt_status = gensec_subcontext_start ( spnego_state ,
gensec_security ,
& spnego_state - > sub_sec_security ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
return nt_status ;
}
/* select the sub context */
nt_status = gensec_start_mech_by_ops ( spnego_state - > sub_sec_security ,
all_sec [ i ] . op ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
continue ;
}
2012-09-18 21:34:48 +04:00
2005-12-22 23:34:00 +03:00
spnego_state - > neg_oid = all_sec [ i ] . oid ;
2005-05-16 03:42:11 +04:00
2004-08-11 22:09:40 +04:00
/* only get the helping start blob for the first OID */
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
out_mem_ctx ,
2011-10-17 11:22:33 +04:00
ev ,
2004-08-11 22:09:40 +04:00
null_data_blob ,
unwrapped_out ) ;
2006-02-21 03:17:52 +03:00
/* it is likely that a NULL input token will
* not be liked by most server mechs , but if
* we are in the client , we want the first
* update packet to be able to abort the use
* of this mech */
if ( spnego_state - > state_position ! = SPNEGO_SERVER_START ) {
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_INVALID_PARAMETER ) | |
2010-11-08 08:55:17 +03:00
NT_STATUS_EQUAL ( nt_status , NT_STATUS_NO_LOGON_SERVERS ) | |
NT_STATUS_EQUAL ( nt_status , NT_STATUS_TIME_DIFFERENCE_AT_DC ) | |
2006-02-21 03:17:52 +03:00
NT_STATUS_EQUAL ( nt_status , NT_STATUS_CANT_ACCESS_DOMAIN_INFO ) ) {
/* Pretend we never started it (lets the first run find some incompatible demand) */
2012-09-18 21:34:48 +04:00
2011-10-17 06:46:57 +04:00
DEBUG ( 3 , ( " SPNEGO(%s) NEG_TOKEN_INIT failed: %s \n " ,
2006-02-21 03:17:52 +03:00
spnego_state - > sub_sec_security - > ops - > name , nt_errstr ( nt_status ) ) ) ;
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
continue ;
}
}
2005-12-22 23:34:00 +03:00
break ;
2004-08-11 22:09:40 +04:00
}
2005-12-22 23:34:00 +03:00
}
if ( spnego_state - > sub_sec_security ) {
/* it is likely that a NULL input token will
* not be liked by most server mechs , but this
* does the right thing in the CIFS client .
* just push us along the merry - go - round
* again , and hope for better luck next
* time */
2012-09-18 21:34:48 +04:00
2005-12-22 23:34:00 +03:00
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_INVALID_PARAMETER ) ) {
* unwrapped_out = data_blob ( NULL , 0 ) ;
nt_status = NT_STATUS_MORE_PROCESSING_REQUIRED ;
}
2012-09-18 21:34:48 +04:00
2005-05-16 03:42:11 +04:00
if ( ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_INVALID_PARAMETER )
& & ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED )
& & ! NT_STATUS_IS_OK ( nt_status ) ) {
2004-08-11 22:09:40 +04:00
DEBUG ( 1 , ( " SPNEGO(%s) NEG_TOKEN_INIT failed: %s \n " ,
spnego_state - > sub_sec_security - > ops - > name , nt_errstr ( nt_status ) ) ) ;
2004-12-25 02:02:39 +03:00
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
2012-09-18 21:34:48 +04:00
2005-05-16 03:42:11 +04:00
/* We started the mech correctly, and the
* input from the other side was valid .
* Return the error ( say bad password , invalid
* ticket ) */
return nt_status ;
2004-08-11 22:09:40 +04:00
}
2012-09-18 21:34:48 +04:00
2005-05-16 03:42:11 +04:00
return nt_status ; /* OK, INVALID_PARAMETER ore MORE PROCESSING */
2004-08-11 22:09:40 +04:00
}
2005-05-16 03:42:11 +04:00
DEBUG ( 1 , ( " SPNEGO: Could not find a suitable mechtype in NEG_TOKEN_INIT \n " ) ) ;
/* we could re-negotiate here, but it would only work
* if the client or server lied about what it could
* support the first time . Lets keep this code to
* reality */
2007-05-17 09:44:51 +04:00
return nt_status ;
2004-08-11 22:09:40 +04:00
}
2005-08-20 10:14:14 +04:00
/** create a negTokenInit
2004-07-06 22:07:00 +04:00
*
2005-08-20 10:14:14 +04:00
* This is the same packet , no matter if the client or server sends it first , but it is always the first packet
2004-07-06 22:07:00 +04:00
*/
2005-08-20 10:14:14 +04:00
static NTSTATUS gensec_spnego_create_negTokenInit ( struct gensec_security * gensec_security ,
2004-07-06 22:07:00 +04:00
struct spnego_state * spnego_state ,
TALLOC_CTX * out_mem_ctx ,
2011-10-17 11:22:33 +04:00
struct tevent_context * ev ,
2004-07-06 22:07:00 +04:00
const DATA_BLOB in , DATA_BLOB * out )
{
2005-08-20 10:14:14 +04:00
int i ;
NTSTATUS nt_status = NT_STATUS_INVALID_PARAMETER ;
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
2004-08-11 22:09:40 +04:00
const char * * mechTypes = NULL ;
2005-05-16 03:42:11 +04:00
DATA_BLOB unwrapped_out = data_blob ( NULL , 0 ) ;
2005-08-20 10:36:35 +04:00
const struct gensec_security_ops_wrapper * all_sec ;
2004-07-06 22:07:00 +04:00
2005-12-05 06:20:40 +03:00
mechTypes = gensec_security_oids ( gensec_security ,
out_mem_ctx , GENSEC_OID_SPNEGO ) ;
2004-07-06 22:07:00 +04:00
2005-12-05 06:20:40 +03:00
all_sec = gensec_security_by_oid_list ( gensec_security ,
out_mem_ctx ,
2005-08-20 10:14:14 +04:00
mechTypes ,
GENSEC_OID_SPNEGO ) ;
for ( i = 0 ; all_sec & & all_sec [ i ] . op ; i + + ) {
2004-07-06 22:07:00 +04:00
struct spnego_data spnego_out ;
2008-08-12 16:26:21 +04:00
const char * * send_mech_types ;
bool ok ;
2005-08-20 10:14:14 +04:00
nt_status = gensec_subcontext_start ( spnego_state ,
gensec_security ,
& spnego_state - > sub_sec_security ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
return nt_status ;
}
/* select the sub context */
nt_status = gensec_start_mech_by_ops ( spnego_state - > sub_sec_security ,
all_sec [ i ] . op ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
continue ;
}
2005-08-20 10:36:35 +04:00
/* In the client, try and produce the first (optimistic) packet */
2005-08-20 11:04:13 +04:00
if ( spnego_state - > state_position = = SPNEGO_CLIENT_START ) {
2005-08-20 10:36:35 +04:00
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
out_mem_ctx ,
2011-10-17 11:22:33 +04:00
ev ,
2005-08-20 10:36:35 +04:00
null_data_blob ,
& unwrapped_out ) ;
2012-09-18 21:34:48 +04:00
2005-08-20 10:36:35 +04:00
if ( ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED )
& & ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 1 , ( " SPNEGO(%s) creating NEG_TOKEN_INIT failed: %s \n " ,
spnego_state - > sub_sec_security - > ops - > name , nt_errstr ( nt_status ) ) ) ;
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
/* Pretend we never started it (lets the first run find some incompatible demand) */
2012-09-18 21:34:48 +04:00
2005-08-20 10:36:35 +04:00
continue ;
}
2005-08-20 10:14:14 +04:00
}
2005-08-20 10:36:35 +04:00
2004-07-06 22:07:00 +04:00
spnego_out . type = SPNEGO_NEG_TOKEN_INIT ;
2008-08-12 16:26:21 +04:00
send_mech_types = gensec_security_oids_from_ops_wrapped ( out_mem_ctx ,
& all_sec [ i ] ) ;
ok = spnego_write_mech_types ( spnego_state ,
send_mech_types ,
& spnego_state - > mech_types ) ;
if ( ! ok ) {
DEBUG ( 1 , ( " SPNEGO: Failed to write mechTypes \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
2005-08-20 10:36:35 +04:00
/* List the remaining mechs as options */
2008-08-12 16:26:21 +04:00
spnego_out . negTokenInit . mechTypes = send_mech_types ;
2009-08-13 10:12:01 +04:00
spnego_out . negTokenInit . reqFlags = null_data_blob ;
spnego_out . negTokenInit . reqFlagsPadding = 0 ;
2012-09-18 21:34:48 +04:00
2005-08-20 11:04:13 +04:00
if ( spnego_state - > state_position = = SPNEGO_SERVER_START ) {
2005-08-20 10:36:35 +04:00
spnego_out . negTokenInit . mechListMIC
2010-12-09 09:51:36 +03:00
= data_blob_string_const ( ADS_IGNORE_PRINCIPAL ) ;
2005-08-20 10:36:35 +04:00
} else {
spnego_out . negTokenInit . mechListMIC = null_data_blob ;
}
2005-10-20 14:25:51 +04:00
2004-07-06 22:07:00 +04:00
spnego_out . negTokenInit . mechToken = unwrapped_out ;
2012-09-18 21:34:48 +04:00
2004-07-06 22:07:00 +04:00
if ( spnego_write_data ( out_mem_ctx , out , & spnego_out ) = = - 1 ) {
2005-08-20 10:14:14 +04:00
DEBUG ( 1 , ( " Failed to write NEG_TOKEN_INIT \n " ) ) ;
2004-07-06 22:07:00 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 22:07:00 +04:00
/* set next state */
2005-10-20 07:20:43 +04:00
spnego_state - > neg_oid = all_sec [ i ] . oid ;
2012-09-18 21:34:48 +04:00
2005-01-01 03:19:08 +03:00
if ( NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-07 02:16:19 +04:00
spnego_state - > no_response_expected = true ;
2005-01-01 03:19:08 +03:00
}
return NT_STATUS_MORE_PROCESSING_REQUIRED ;
2005-01-01 01:45:11 +03:00
}
2004-12-25 02:02:39 +03:00
talloc_free ( spnego_state - > sub_sec_security ) ;
spnego_state - > sub_sec_security = NULL ;
2004-07-06 22:07:00 +04:00
2005-01-01 01:45:11 +03:00
DEBUG ( 1 , ( " Failed to setup SPNEGO negTokenInit request: %s \n " , nt_errstr ( nt_status ) ) ) ;
2004-07-06 22:07:00 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2004-08-11 22:09:40 +04:00
2005-10-20 07:20:43 +04:00
/** create a server negTokenTarg
2004-08-11 22:09:40 +04:00
*
* This is the case , where the client is the first one who sends data
*/
2012-06-30 11:32:50 +04:00
static NTSTATUS gensec_spnego_server_negTokenTarg ( struct spnego_state * spnego_state ,
2004-08-11 22:09:40 +04:00
TALLOC_CTX * out_mem_ctx ,
NTSTATUS nt_status ,
2008-08-12 16:26:21 +04:00
const DATA_BLOB unwrapped_out ,
DATA_BLOB mech_list_mic ,
DATA_BLOB * out )
2004-08-11 22:09:40 +04:00
{
struct spnego_data spnego_out ;
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
/* compose reply */
spnego_out . type = SPNEGO_NEG_TOKEN_TARG ;
spnego_out . negTokenTarg . responseToken = unwrapped_out ;
spnego_out . negTokenTarg . mechListMIC = null_data_blob ;
2004-12-02 21:15:39 +03:00
spnego_out . negTokenTarg . supportedMech = NULL ;
2005-05-16 03:42:11 +04:00
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
spnego_out . negTokenTarg . supportedMech = spnego_state - > neg_oid ;
2004-08-11 22:09:40 +04:00
spnego_out . negTokenTarg . negResult = SPNEGO_ACCEPT_INCOMPLETE ;
spnego_state - > state_position = SPNEGO_SERVER_TARG ;
} else if ( NT_STATUS_IS_OK ( nt_status ) ) {
2004-12-02 21:15:39 +03:00
if ( unwrapped_out . data ) {
2005-05-16 03:42:11 +04:00
spnego_out . negTokenTarg . supportedMech = spnego_state - > neg_oid ;
2004-12-02 21:15:39 +03:00
}
2004-08-11 22:09:40 +04:00
spnego_out . negTokenTarg . negResult = SPNEGO_ACCEPT_COMPLETED ;
2008-08-12 16:26:21 +04:00
spnego_out . negTokenTarg . mechListMIC = mech_list_mic ;
2004-08-11 22:09:40 +04:00
spnego_state - > state_position = SPNEGO_DONE ;
} else {
spnego_out . negTokenTarg . negResult = SPNEGO_REJECT ;
2004-12-30 14:24:49 +03:00
DEBUG ( 2 , ( " SPNEGO login failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
2004-08-11 22:09:40 +04:00
spnego_state - > state_position = SPNEGO_DONE ;
}
2004-12-02 21:15:39 +03:00
2004-08-11 22:09:40 +04:00
if ( spnego_write_data ( out_mem_ctx , out , & spnego_out ) = = - 1 ) {
DEBUG ( 1 , ( " Failed to write SPNEGO reply to NEG_TOKEN_TARG \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_TARG ;
return nt_status ;
}
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 13:40:10 +04:00
static NTSTATUS gensec_spnego_update ( struct gensec_security * gensec_security , TALLOC_CTX * out_mem_ctx ,
2011-10-17 11:22:33 +04:00
struct tevent_context * ev ,
2004-09-13 08:28:10 +04:00
const DATA_BLOB in , DATA_BLOB * out )
2004-06-19 12:15:41 +04:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2004-06-20 04:58:09 +04:00
DATA_BLOB null_data_blob = data_blob ( NULL , 0 ) ;
2008-08-12 16:26:21 +04:00
DATA_BLOB mech_list_mic = data_blob ( NULL , 0 ) ;
2004-07-12 13:11:13 +04:00
DATA_BLOB unwrapped_out = data_blob ( NULL , 0 ) ;
2004-06-20 04:58:09 +04:00
struct spnego_data spnego_out ;
struct spnego_data spnego ;
2004-06-19 12:15:41 +04:00
2004-06-20 04:58:09 +04:00
ssize_t len ;
2004-06-19 12:15:41 +04:00
2004-08-11 22:09:40 +04:00
* out = data_blob ( NULL , 0 ) ;
2004-06-20 04:58:09 +04:00
if ( ! out_mem_ctx ) {
2004-09-26 06:16:25 +04:00
out_mem_ctx = spnego_state ;
2004-06-19 12:15:41 +04:00
}
2004-07-06 07:02:33 +04:00
/* and switch into the state machine */
switch ( spnego_state - > state_position ) {
case SPNEGO_FALLBACK :
2011-10-17 11:22:33 +04:00
return gensec_update ( spnego_state - > sub_sec_security , ev ,
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 13:40:10 +04:00
out_mem_ctx , in , out ) ;
2004-07-06 07:02:33 +04:00
case SPNEGO_SERVER_START :
{
2005-08-20 10:14:14 +04:00
NTSTATUS nt_status ;
2004-07-06 07:02:33 +04:00
if ( in . length ) {
2004-08-11 22:09:40 +04:00
2007-05-21 10:12:06 +04:00
len = spnego_read_data ( gensec_security , in , & spnego ) ;
2004-07-06 07:02:33 +04:00
if ( len = = - 1 ) {
2011-10-17 11:22:33 +04:00
return gensec_spnego_server_try_fallback ( gensec_security , spnego_state ,
out_mem_ctx , ev , in , out ) ;
2004-07-06 07:02:33 +04:00
}
2004-08-11 22:09:40 +04:00
/* client sent NegTargetInit, we send NegTokenTarg */
/* OK, so it's real SPNEGO, check the packet's the one we expect */
if ( spnego . type ! = spnego_state - > expected_packet ) {
DEBUG ( 1 , ( " Invalid SPNEGO request: %d, expected %d \n " , spnego . type ,
spnego_state - > expected_packet ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-08-11 22:09:40 +04:00
spnego_free_data ( & spnego ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2005-05-16 03:42:11 +04:00
nt_status = gensec_spnego_parse_negTokenInit ( gensec_security ,
2004-08-11 22:09:40 +04:00
spnego_state ,
out_mem_ctx ,
2011-10-17 11:22:33 +04:00
ev ,
2004-08-11 22:09:40 +04:00
spnego . negTokenInit . mechTypes ,
spnego . negTokenInit . mechToken ,
& unwrapped_out ) ;
2012-09-18 21:34:48 +04:00
2012-06-30 11:32:50 +04:00
nt_status = gensec_spnego_server_negTokenTarg ( spnego_state ,
2004-08-11 22:09:40 +04:00
out_mem_ctx ,
nt_status ,
2008-08-12 16:26:21 +04:00
unwrapped_out ,
null_data_blob ,
2004-08-11 22:09:40 +04:00
out ) ;
2012-09-18 21:34:48 +04:00
2004-08-11 22:09:40 +04:00
spnego_free_data ( & spnego ) ;
2012-09-18 21:34:48 +04:00
2004-08-11 22:09:40 +04:00
return nt_status ;
2004-07-06 07:02:33 +04:00
} else {
2005-08-20 11:31:29 +04:00
nt_status = gensec_spnego_create_negTokenInit ( gensec_security , spnego_state ,
2011-10-17 11:22:33 +04:00
out_mem_ctx , ev , in , out ) ;
2005-10-20 17:11:06 +04:00
spnego_state - > state_position = SPNEGO_SERVER_START ;
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_INIT ;
2005-08-20 11:31:29 +04:00
return nt_status ;
2004-07-06 07:02:33 +04:00
}
2004-06-19 12:15:41 +04:00
}
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
case SPNEGO_CLIENT_START :
{
/* The server offers a list of mechanisms */
2012-09-18 21:34:48 +04:00
2004-10-28 16:46:59 +04:00
const char * my_mechs [ ] = { NULL , NULL } ;
2004-07-09 16:29:33 +04:00
NTSTATUS nt_status = NT_STATUS_INVALID_PARAMETER ;
2004-07-06 07:02:33 +04:00
if ( ! in . length ) {
/* client to produce negTokenInit */
2005-08-20 11:31:29 +04:00
nt_status = gensec_spnego_create_negTokenInit ( gensec_security , spnego_state ,
2011-10-17 11:22:33 +04:00
out_mem_ctx , ev , in , out ) ;
2005-08-20 11:31:29 +04:00
spnego_state - > state_position = SPNEGO_CLIENT_TARG ;
2005-10-20 17:11:06 +04:00
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_TARG ;
2005-08-20 11:31:29 +04:00
return nt_status ;
2004-07-06 07:02:33 +04:00
}
2012-09-18 21:34:48 +04:00
2007-05-21 10:12:06 +04:00
len = spnego_read_data ( gensec_security , in , & spnego ) ;
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
if ( len = = - 1 ) {
2004-07-09 16:29:33 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: \n " ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-06 07:02:33 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
/* OK, so it's real SPNEGO, check the packet's the one we expect */
if ( spnego . type ! = spnego_state - > expected_packet ) {
2004-07-12 13:11:13 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: %d, expected %d \n " , spnego . type ,
2004-07-06 07:02:33 +04:00
spnego_state - > expected_packet ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-09 16:29:33 +04:00
spnego_free_data ( & spnego ) ;
2004-07-06 07:02:33 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2010-12-04 07:23:44 +03:00
if ( spnego . negTokenInit . targetPrincipal
& & strcmp ( spnego . negTokenInit . targetPrincipal , ADS_IGNORE_PRINCIPAL ) ! = 0 ) {
2005-09-17 13:46:20 +04:00
DEBUG ( 5 , ( " Server claims it's principal name is %s \n " , spnego . negTokenInit . targetPrincipal ) ) ;
2010-07-16 08:32:42 +04:00
if ( lpcfg_client_use_spnego_principal ( gensec_security - > settings - > lp_ctx ) ) {
2010-05-13 01:59:41 +04:00
gensec_set_target_principal ( gensec_security , spnego . negTokenInit . targetPrincipal ) ;
}
2004-07-12 13:11:13 +04:00
}
2005-05-16 03:42:11 +04:00
nt_status = gensec_spnego_parse_negTokenInit ( gensec_security ,
2004-08-11 22:09:40 +04:00
spnego_state ,
out_mem_ctx ,
2011-10-17 11:22:33 +04:00
ev ,
2004-08-11 22:09:40 +04:00
spnego . negTokenInit . mechTypes ,
spnego . negTokenInit . mechToken ,
& unwrapped_out ) ;
2004-07-12 13:11:13 +04:00
if ( ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED ) & & ! NT_STATUS_IS_OK ( nt_status ) ) {
2004-09-24 10:51:14 +04:00
spnego_free_data ( & spnego ) ;
2004-07-06 07:02:33 +04:00
return nt_status ;
}
2004-08-11 22:09:40 +04:00
2005-05-16 03:42:11 +04:00
my_mechs [ 0 ] = spnego_state - > neg_oid ;
2004-07-06 07:02:33 +04:00
/* compose reply */
spnego_out . type = SPNEGO_NEG_TOKEN_INIT ;
spnego_out . negTokenInit . mechTypes = my_mechs ;
2009-08-13 10:12:01 +04:00
spnego_out . negTokenInit . reqFlags = null_data_blob ;
spnego_out . negTokenInit . reqFlagsPadding = 0 ;
2004-07-06 07:02:33 +04:00
spnego_out . negTokenInit . mechListMIC = null_data_blob ;
spnego_out . negTokenInit . mechToken = unwrapped_out ;
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
if ( spnego_write_data ( out_mem_ctx , out , & spnego_out ) = = - 1 ) {
2004-07-12 13:11:13 +04:00
DEBUG ( 1 , ( " Failed to write SPNEGO reply to NEG_TOKEN_INIT \n " ) ) ;
2004-07-06 07:02:33 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
/* set next state */
spnego_state - > expected_packet = SPNEGO_NEG_TOKEN_TARG ;
2004-07-06 21:53:44 +04:00
spnego_state - > state_position = SPNEGO_CLIENT_TARG ;
2005-01-01 03:19:08 +03:00
if ( NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-07 02:16:19 +04:00
spnego_state - > no_response_expected = true ;
2005-01-01 03:19:08 +03:00
}
2012-09-18 21:34:48 +04:00
2005-10-20 07:20:43 +04:00
spnego_free_data ( & spnego ) ;
2004-07-12 13:11:13 +04:00
return NT_STATUS_MORE_PROCESSING_REQUIRED ;
2004-07-06 07:02:33 +04:00
}
2004-07-06 21:53:44 +04:00
case SPNEGO_SERVER_TARG :
2004-07-06 07:02:33 +04:00
{
NTSTATUS nt_status ;
2008-08-12 16:26:21 +04:00
bool new_spnego = false ;
2004-07-06 07:02:33 +04:00
if ( ! in . length ) {
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2007-05-21 10:12:06 +04:00
len = spnego_read_data ( gensec_security , in , & spnego ) ;
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
if ( len = = - 1 ) {
2004-07-09 16:29:33 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: \n " ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-06 07:02:33 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
/* OK, so it's real SPNEGO, check the packet's the one we expect */
2004-07-06 04:09:10 +04:00
if ( spnego . type ! = spnego_state - > expected_packet ) {
2004-07-12 13:11:13 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: %d, expected %d \n " , spnego . type ,
2004-07-06 04:09:10 +04:00
spnego_state - > expected_packet ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-09 16:29:33 +04:00
spnego_free_data ( & spnego ) ;
2004-07-06 04:09:10 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2004-08-11 22:09:40 +04:00
2005-01-21 14:10:03 +03:00
if ( ! spnego_state - > sub_sec_security ) {
DEBUG ( 1 , ( " SPNEGO: Did not setup a mech in NEG_TOKEN_INIT \n " ) ) ;
2005-10-20 07:20:43 +04:00
spnego_free_data ( & spnego ) ;
2005-01-21 14:10:03 +03:00
return NT_STATUS_INVALID_PARAMETER ;
}
2004-07-12 13:11:13 +04:00
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
2011-10-17 11:22:33 +04:00
out_mem_ctx , ev ,
2004-08-11 22:09:40 +04:00
spnego . negTokenTarg . responseToken ,
2004-07-12 13:11:13 +04:00
& unwrapped_out ) ;
2008-08-12 16:26:21 +04:00
if ( NT_STATUS_IS_OK ( nt_status ) & & spnego . negTokenTarg . mechListMIC . length > 0 ) {
new_spnego = true ;
nt_status = gensec_check_packet ( spnego_state - > sub_sec_security ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
& spnego . negTokenTarg . mechListMIC ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 2 , ( " GENSEC SPNEGO: failed to verify mechListMIC: %s \n " ,
nt_errstr ( nt_status ) ) ) ;
}
}
if ( NT_STATUS_IS_OK ( nt_status ) & & new_spnego ) {
nt_status = gensec_sign_packet ( spnego_state - > sub_sec_security ,
out_mem_ctx ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
& mech_list_mic ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 2 , ( " GENSEC SPNEGO: failed to sign mechListMIC: %s \n " ,
nt_errstr ( nt_status ) ) ) ;
}
}
2004-08-11 22:09:40 +04:00
2012-06-30 11:32:50 +04:00
nt_status = gensec_spnego_server_negTokenTarg ( spnego_state ,
2004-08-11 22:09:40 +04:00
out_mem_ctx ,
nt_status ,
2008-08-12 16:26:21 +04:00
unwrapped_out ,
mech_list_mic ,
2004-08-11 22:09:40 +04:00
out ) ;
2012-09-18 21:34:48 +04:00
2004-07-06 07:02:33 +04:00
spnego_free_data ( & spnego ) ;
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
return nt_status ;
}
case SPNEGO_CLIENT_TARG :
{
NTSTATUS nt_status ;
if ( ! in . length ) {
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2007-05-21 10:12:06 +04:00
len = spnego_read_data ( gensec_security , in , & spnego ) ;
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
if ( len = = - 1 ) {
2004-07-09 16:29:33 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: \n " ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-06 21:53:44 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
/* OK, so it's real SPNEGO, check the packet's the one we expect */
if ( spnego . type ! = spnego_state - > expected_packet ) {
2004-07-09 16:29:33 +04:00
DEBUG ( 1 , ( " Invalid SPNEGO request: %d, expected %d \n " , spnego . type ,
2004-07-06 21:53:44 +04:00
spnego_state - > expected_packet ) ) ;
2004-11-15 23:31:12 +03:00
dump_data ( 1 , in . data , in . length ) ;
2004-07-09 16:29:33 +04:00
spnego_free_data ( & spnego ) ;
2004-07-06 21:53:44 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
if ( spnego . negTokenTarg . negResult = = SPNEGO_REJECT ) {
2005-10-20 07:20:43 +04:00
spnego_free_data ( & spnego ) ;
2004-07-06 21:53:44 +04:00
return NT_STATUS_ACCESS_DENIED ;
}
2004-07-12 13:11:13 +04:00
2005-10-20 07:20:43 +04:00
/* Server didn't like our choice of mech, and chose something else */
if ( ( spnego . negTokenTarg . negResult = = SPNEGO_ACCEPT_INCOMPLETE ) & &
2006-12-11 19:36:30 +03:00
spnego . negTokenTarg . supportedMech & &
2005-10-20 07:20:43 +04:00
strcmp ( spnego . negTokenTarg . supportedMech , spnego_state - > neg_oid ) ! = 0 ) {
DEBUG ( 3 , ( " GENSEC SPNEGO: client preferred mech (%s) not accepted, server wants: %s \n " ,
2008-11-03 01:58:49 +03:00
gensec_get_name_by_oid ( gensec_security , spnego . negTokenTarg . supportedMech ) ,
gensec_get_name_by_oid ( gensec_security , spnego_state - > neg_oid ) ) ) ;
2012-09-18 21:34:48 +04:00
2005-10-20 07:20:43 +04:00
talloc_free ( spnego_state - > sub_sec_security ) ;
nt_status = gensec_subcontext_start ( spnego_state ,
gensec_security ,
& spnego_state - > sub_sec_security ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
spnego_free_data ( & spnego ) ;
return nt_status ;
}
/* select the sub context */
nt_status = gensec_start_mech_by_oid ( spnego_state - > sub_sec_security ,
spnego . negTokenTarg . supportedMech ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
spnego_free_data ( & spnego ) ;
return nt_status ;
}
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
2011-10-17 11:22:33 +04:00
out_mem_ctx , ev ,
2005-10-20 07:20:43 +04:00
spnego . negTokenTarg . responseToken ,
& unwrapped_out ) ;
spnego_state - > neg_oid = talloc_strdup ( spnego_state , spnego . negTokenTarg . supportedMech ) ;
} else if ( spnego_state - > no_response_expected ) {
2005-01-10 13:48:19 +03:00
if ( spnego . negTokenTarg . negResult ! = SPNEGO_ACCEPT_COMPLETED ) {
2005-01-11 23:20:27 +03:00
DEBUG ( 3 , ( " GENSEC SPNEGO: client GENSEC accepted, but server rejected (bad password?) \n " ) ) ;
nt_status = NT_STATUS_INVALID_PARAMETER ;
} else if ( spnego . negTokenTarg . responseToken . length ) {
DEBUG ( 2 , ( " GENSEC SPNEGO: client GENSEC accepted, but server continued negotiation! \n " ) ) ;
2005-01-10 13:48:19 +03:00
nt_status = NT_STATUS_INVALID_PARAMETER ;
} else {
nt_status = NT_STATUS_OK ;
}
2008-08-12 16:26:21 +04:00
if ( NT_STATUS_IS_OK ( nt_status ) & & spnego . negTokenTarg . mechListMIC . length > 0 ) {
nt_status = gensec_check_packet ( spnego_state - > sub_sec_security ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
& spnego . negTokenTarg . mechListMIC ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 2 , ( " GENSEC SPNEGO: failed to verify mechListMIC: %s \n " ,
nt_errstr ( nt_status ) ) ) ;
}
}
2005-01-01 03:19:08 +03:00
} else {
2008-08-12 16:26:21 +04:00
bool new_spnego = false ;
2005-01-01 03:19:08 +03:00
nt_status = gensec_update ( spnego_state - > sub_sec_security ,
2011-10-17 11:22:33 +04:00
out_mem_ctx , ev ,
2005-01-01 03:19:08 +03:00
spnego . negTokenTarg . responseToken ,
& unwrapped_out ) ;
2005-01-10 13:48:19 +03:00
2009-07-28 10:17:25 +04:00
if ( NT_STATUS_IS_OK ( nt_status )
& & spnego . negTokenTarg . negResult ! = SPNEGO_ACCEPT_COMPLETED ) {
2008-08-12 16:26:21 +04:00
new_spnego = gensec_have_feature ( spnego_state - > sub_sec_security ,
GENSEC_FEATURE_NEW_SPNEGO ) ;
}
if ( NT_STATUS_IS_OK ( nt_status ) & & new_spnego ) {
nt_status = gensec_sign_packet ( spnego_state - > sub_sec_security ,
out_mem_ctx ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
spnego_state - > mech_types . data ,
spnego_state - > mech_types . length ,
& mech_list_mic ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 2 , ( " GENSEC SPNEGO: failed to sign mechListMIC: %s \n " ,
nt_errstr ( nt_status ) ) ) ;
}
}
2005-01-10 13:48:19 +03:00
if ( NT_STATUS_IS_OK ( nt_status ) ) {
2007-10-07 02:16:19 +04:00
spnego_state - > no_response_expected = true ;
2005-01-10 13:48:19 +03:00
}
2004-07-16 06:54:57 +04:00
}
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
spnego_free_data ( & spnego ) ;
2004-07-16 06:54:57 +04:00
2005-01-10 13:48:19 +03:00
if ( ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED )
& & ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 1 , ( " SPNEGO(%s) login failed: %s \n " ,
spnego_state - > sub_sec_security - > ops - > name ,
nt_errstr ( nt_status ) ) ) ;
return nt_status ;
}
2009-07-24 11:33:06 +04:00
if ( unwrapped_out . length | | mech_list_mic . length ) {
2004-07-29 14:33:36 +04:00
/* compose reply */
2004-07-16 06:54:57 +04:00
spnego_out . type = SPNEGO_NEG_TOKEN_TARG ;
spnego_out . negTokenTarg . negResult = SPNEGO_NONE_RESULT ;
spnego_out . negTokenTarg . supportedMech = NULL ;
spnego_out . negTokenTarg . responseToken = unwrapped_out ;
2008-08-12 16:26:21 +04:00
spnego_out . negTokenTarg . mechListMIC = mech_list_mic ;
2012-09-18 21:34:48 +04:00
2004-07-16 06:54:57 +04:00
if ( spnego_write_data ( out_mem_ctx , out , & spnego_out ) = = - 1 ) {
DEBUG ( 1 , ( " Failed to write SPNEGO reply to NEG_TOKEN_TARG \n " ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2004-07-06 21:53:44 +04:00
spnego_state - > state_position = SPNEGO_CLIENT_TARG ;
2005-01-10 13:48:19 +03:00
nt_status = NT_STATUS_MORE_PROCESSING_REQUIRED ;
} else {
2004-07-16 06:54:57 +04:00
/* all done - server has accepted, and we agree */
2005-01-10 13:48:19 +03:00
* out = null_data_blob ;
2004-07-29 14:33:36 +04:00
2005-01-10 13:48:19 +03:00
if ( spnego . negTokenTarg . negResult ! = SPNEGO_ACCEPT_COMPLETED ) {
/* unless of course it did not accept */
DEBUG ( 1 , ( " gensec_update ok but not accepted \n " ) ) ;
nt_status = NT_STATUS_INVALID_PARAMETER ;
}
2012-09-18 21:34:48 +04:00
2005-10-20 07:20:43 +04:00
spnego_state - > state_position = SPNEGO_DONE ;
}
2005-01-10 13:48:19 +03:00
2004-07-06 07:02:33 +04:00
return nt_status ;
}
2004-07-07 03:20:23 +04:00
case SPNEGO_DONE :
2005-10-20 07:20:43 +04:00
/* We should not be called after we are 'done' */
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2004-07-07 03:20:23 +04:00
return NT_STATUS_INVALID_PARAMETER ;
2004-06-19 12:15:41 +04:00
}
2011-12-24 03:27:45 +04:00
static NTSTATUS gensec_spnego_update_in ( struct gensec_security * gensec_security ,
const DATA_BLOB in , DATA_BLOB * full_in )
{
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
size_t expected ;
NTSTATUS status ;
bool ok ;
* full_in = data_blob_null ;
if ( spnego_state - > in_needed = = 0 ) {
size_t size = 0 ;
/*
* try to work out the size of the full
* input token , it might be fragmented
*/
status = asn1_peek_full_tag ( in , ASN1_APPLICATION ( 0 ) , & size ) ;
if ( ! NT_STATUS_IS_OK ( status ) & &
! NT_STATUS_EQUAL ( status , STATUS_MORE_ENTRIES ) ) {
status = asn1_peek_full_tag ( in , ASN1_CONTEXT ( 1 ) , & size ) ;
}
if ( NT_STATUS_IS_OK ( status ) | |
NT_STATUS_EQUAL ( status , STATUS_MORE_ENTRIES ) ) {
spnego_state - > in_needed = size ;
} else {
/*
* If it is not an asn1 message
* just call the next layer .
*/
spnego_state - > in_needed = in . length ;
}
}
if ( spnego_state - > in_needed > UINT16_MAX ) {
/*
* limit the incoming message to 0xFFFF
* to avoid DoS attacks .
*/
return NT_STATUS_INVALID_BUFFER_SIZE ;
}
if ( ( spnego_state - > in_needed > 0 ) & & ( in . length = = 0 ) ) {
/*
* If we reach this , we know we got at least
* part of an asn1 message , getting 0 means
* the remote peer wants us to spin .
*/
return NT_STATUS_INVALID_PARAMETER ;
}
expected = spnego_state - > in_needed - spnego_state - > in_frag . length ;
if ( in . length > expected ) {
/*
* we got more than expected
*/
return NT_STATUS_INVALID_PARAMETER ;
}
if ( in . length = = spnego_state - > in_needed ) {
/*
* if the in . length contains the full blob
* we are done .
*
* Note : this implies spnego_state - > in_frag . length = = 0 ,
* but we do not need to check this explicitly
* because we already know that we did not get
* more than expected .
*/
* full_in = in ;
return NT_STATUS_OK ;
}
ok = data_blob_append ( spnego_state , & spnego_state - > in_frag ,
in . data , in . length ) ;
if ( ! ok ) {
return NT_STATUS_NO_MEMORY ;
}
if ( spnego_state - > in_needed > spnego_state - > in_frag . length ) {
return NT_STATUS_MORE_PROCESSING_REQUIRED ;
}
* full_in = spnego_state - > in_frag ;
return NT_STATUS_OK ;
}
static NTSTATUS gensec_spnego_update_out ( struct gensec_security * gensec_security ,
TALLOC_CTX * out_mem_ctx ,
DATA_BLOB * _out )
{
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
DATA_BLOB out = data_blob_null ;
* _out = data_blob_null ;
if ( spnego_state - > out_frag . length = = 0 ) {
return spnego_state - > out_status ;
}
/*
* There is still more data to be delivered
* to the remote peer .
*/
if ( spnego_state - > out_frag . length < = spnego_state - > out_max_length ) {
/*
* Fast path , we can deliver everything
*/
* _out = spnego_state - > out_frag ;
talloc_steal ( out_mem_ctx , _out - > data ) ;
spnego_state - > out_frag = data_blob_null ;
return spnego_state - > out_status ;
}
out = spnego_state - > out_frag ;
/*
* copy the remaining bytes
*/
spnego_state - > out_frag = data_blob_talloc ( spnego_state ,
out . data + spnego_state - > out_max_length ,
out . length - spnego_state - > out_max_length ) ;
if ( spnego_state - > out_frag . data = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
/*
* truncate the buffer
*/
data_blob_realloc ( spnego_state , & out , spnego_state - > out_max_length ) ;
talloc_steal ( out_mem_ctx , out . data ) ;
* _out = out ;
return NT_STATUS_MORE_PROCESSING_REQUIRED ;
}
static NTSTATUS gensec_spnego_update_wrapper ( struct gensec_security * gensec_security ,
TALLOC_CTX * out_mem_ctx ,
struct tevent_context * ev ,
const DATA_BLOB in , DATA_BLOB * out )
{
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
DATA_BLOB full_in = data_blob_null ;
NTSTATUS status ;
* out = data_blob_null ;
if ( spnego_state - > out_frag . length > 0 ) {
if ( in . length > 0 ) {
return NT_STATUS_INVALID_PARAMETER ;
}
return gensec_spnego_update_out ( gensec_security ,
out_mem_ctx ,
out ) ;
}
status = gensec_spnego_update_in ( gensec_security ,
in , & full_in ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
status = gensec_spnego_update ( gensec_security ,
spnego_state , ev ,
full_in ,
& spnego_state - > out_frag ) ;
data_blob_free ( & spnego_state - > in_frag ) ;
spnego_state - > in_needed = 0 ;
if ( ! NT_STATUS_IS_OK ( status ) & &
! NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
return status ;
}
spnego_state - > out_status = status ;
return gensec_spnego_update_out ( gensec_security ,
out_mem_ctx ,
out ) ;
}
2008-10-01 04:27:09 +04:00
static void gensec_spnego_want_feature ( struct gensec_security * gensec_security ,
uint32_t feature )
{
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
if ( ! spnego_state | | ! spnego_state - > sub_sec_security ) {
gensec_security - > want_features | = feature ;
return ;
}
gensec_want_feature ( spnego_state - > sub_sec_security ,
feature ) ;
}
2007-10-07 02:16:19 +04:00
static bool gensec_spnego_have_feature ( struct gensec_security * gensec_security ,
2005-02-10 08:09:35 +03:00
uint32_t feature )
2005-01-01 01:45:11 +03:00
{
2007-09-07 19:08:14 +04:00
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
2005-01-01 01:45:11 +03:00
if ( ! spnego_state - > sub_sec_security ) {
2007-10-07 02:16:19 +04:00
return false ;
2005-01-01 01:45:11 +03:00
}
2012-09-18 21:34:48 +04:00
2005-01-01 01:45:11 +03:00
return gensec_have_feature ( spnego_state - > sub_sec_security ,
feature ) ;
}
2012-03-03 07:33:15 +04:00
static NTTIME gensec_spnego_expire_time ( struct gensec_security * gensec_security )
{
struct spnego_state * spnego_state = ( struct spnego_state * ) gensec_security - > private_data ;
if ( ! spnego_state - > sub_sec_security ) {
return GENSEC_EXPIRE_TIME_INFINITY ;
}
return gensec_expire_time ( spnego_state - > sub_sec_security ) ;
}
2005-05-16 03:42:11 +04:00
static const char * gensec_spnego_oids [ ] = {
GENSEC_OID_SPNEGO ,
NULL
} ;
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 13:40:10 +04:00
static const struct gensec_security_ops gensec_spnego_security_ops = {
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
. name = " spnego " ,
. sasl_name = " GSS-SPNEGO " ,
. auth_type = DCERPC_AUTH_TYPE_SPNEGO ,
. oid = gensec_spnego_oids ,
. client_start = gensec_spnego_client_start ,
. server_start = gensec_spnego_server_start ,
2011-12-24 03:27:45 +04:00
. update = gensec_spnego_update_wrapper ,
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
. seal_packet = gensec_spnego_seal_packet ,
. sign_packet = gensec_spnego_sign_packet ,
. sig_size = gensec_spnego_sig_size ,
. max_wrapped_size = gensec_spnego_max_wrapped_size ,
. max_input_size = gensec_spnego_max_input_size ,
. check_packet = gensec_spnego_check_packet ,
. unseal_packet = gensec_spnego_unseal_packet ,
2006-09-05 13:42:54 +04:00
. packet_full_request = gensec_spnego_packet_full_request ,
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
. wrap = gensec_spnego_wrap ,
. unwrap = gensec_spnego_unwrap ,
2006-09-05 13:42:54 +04:00
. wrap_packets = gensec_spnego_wrap_packets ,
. unwrap_packets = gensec_spnego_unwrap_packets ,
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
. session_key = gensec_spnego_session_key ,
. session_info = gensec_spnego_session_info ,
2008-10-01 04:27:09 +04:00
. want_feature = gensec_spnego_want_feature ,
r17197: This patch moves the encryption of bulk data on SASL negotiated security
contexts from the application layer into the socket layer.
This improves a number of correctness aspects, as we now allow LDAP
packets to cross multiple SASL packets. It should also make it much
easier to write async LDAP tests from windows clients, as they use SASL
by default. It is also vital to allowing OpenLDAP clients to use GSSAPI
against Samba4, as it negotiates a rather small SASL buffer size.
This patch mirrors the earlier work done to move TLS into the socket
layer.
Unusual in this pstch is the extra read callback argument I take. As
SASL is a layer on top of a socket, it is entirely possible for the
SASL layer to drain a socket dry, but for the caller not to have read
all the decrypted data. This would leave the system without an event
to restart the read (as the socket is dry).
As such, I re-invoke the read handler from a timed callback, which
should trigger on the next running of the event loop. I believe that
the TLS code does require a similar callback.
In trying to understand why this is required, imagine a SASL-encrypted
LDAP packet in the following formation:
+-----------------+---------------------+
| SASL Packet #1 | SASL Packet #2 |
----------------------------------------+
| LDAP Packet #1 | LDAP Packet #2 |
----------------------------------------+
In the old code, this was illegal, but it is perfectly standard
SASL-encrypted LDAP. Without the callback, we would read and process
the first LDAP packet, and the SASL code would have read the second SASL
packet (to decrypt enough data for the LDAP packet), and no data would
remain on the socket.
Without data on the socket, read events stop. That is why I add timed
events, until the SASL buffer is drained.
Another approach would be to add a hack to the event system, to have it
pretend there remained data to read off the network (but that is ugly).
In improving the code, to handle more real-world cases, I've been able
to remove almost all the special-cases in the testnonblock code. The
only special case is that we must use a deterministic partial packet
when calling send, rather than a random length. (1 + n/2). This is
needed because of the way the SASL and TLS code works, and the 'resend
on failure' requirements.
Andrew Bartlett
(This used to be commit 5d7c9c12cb2b39673172a357092b80cd814850b0)
2006-07-23 06:50:08 +04:00
. have_feature = gensec_spnego_have_feature ,
2012-03-03 07:33:15 +04:00
. expire_time = gensec_spnego_expire_time ,
2007-10-07 02:16:19 +04:00
. enabled = true ,
2006-09-08 10:21:02 +04:00
. priority = GENSEC_SPNEGO
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 13:40:10 +04:00
} ;
2008-02-20 21:40:20 +03:00
_PUBLIC_ NTSTATUS gensec_spnego_init ( void )
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 13:40:10 +04:00
{
NTSTATUS ret ;
2004-11-15 01:23:23 +03:00
ret = gensec_register ( & gensec_spnego_security_ops ) ;
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 13:40:10 +04:00
if ( ! NT_STATUS_IS_OK ( ret ) ) {
DEBUG ( 0 , ( " Failed to register '%s' gensec backend! \n " ,
gensec_spnego_security_ops . name ) ) ;
return ret ;
}
return ret ;
}