2011-07-21 07:20:26 +04:00
/*
2004-06-20 04:58:09 +04:00
Unix SMB / CIFS implementation .
2011-07-21 07:20:26 +04:00
2004-06-20 04:58:09 +04:00
Generic Authentication Interface
Copyright ( C ) Andrew Tridgell 2003
2006-09-05 13:42:54 +04:00
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2004 - 2006
2011-07-21 07:20:26 +04:00
2004-06-20 04:58:09 +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-20 04:58:09 +04:00
( at your option ) any later version .
2011-07-21 07:20:26 +04:00
2004-06-20 04:58:09 +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 .
2011-07-21 07:20:26 +04:00
2004-06-20 04:58:09 +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-20 04:58:09 +04:00
*/
# include "includes.h"
2009-12-16 15:27:20 +03:00
# include "system/network.h"
2011-10-09 16:28:15 +04:00
# include "tevent.h"
2009-12-22 18:24:44 +03:00
# include "../lib/util/tevent_ntstatus.h"
2014-02-12 15:08:19 +04:00
# include "librpc/gen_ndr/dcerpc.h"
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials.h"
# include "auth/gensec/gensec.h"
2013-08-05 09:12:01 +04:00
# include "auth/gensec/gensec_internal.h"
2011-10-09 16:28:15 +04:00
# include "lib/param/param.h"
2010-02-13 05:00:03 +03:00
# include "lib/util/tsort.h"
2011-12-03 10:03:35 +04:00
# include "lib/util/samba_modules.h"
2016-05-03 17:12:10 +03:00
# include "lib/util/base64.h"
2019-12-11 19:45:39 +03:00
# include "lib/crypto/gnutls_helpers.h"
2004-06-20 04:58:09 +04:00
2017-12-19 12:49:10 +03:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_AUTH
2020-08-07 23:27:39 +03:00
# undef strcasecmp
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
/* the list of currently registered GENSEC backends */
2013-08-05 13:20:21 +04:00
static const struct gensec_security_ops * * generic_security_ops ;
2004-08-11 20:13:25 +04:00
static int gensec_num_backends ;
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
2006-01-28 15:15:24 +03:00
/* Return all the registered mechs. Don't modify the return pointer,
2013-08-05 13:20:21 +04:00
* but you may talloc_referen it if convient */
_PUBLIC_ const struct gensec_security_ops * const * gensec_security_all ( void )
2005-12-05 06:20:40 +03:00
{
return generic_security_ops ;
}
2013-08-05 13:20:21 +04:00
bool gensec_security_ops_enabled ( const struct gensec_security_ops * ops , struct gensec_security * security )
2008-11-02 21:28:17 +03:00
{
2019-12-11 19:45:39 +03:00
bool ok = lpcfg_parm_bool ( security - > settings - > lp_ctx ,
NULL ,
" gensec " ,
ops - > name ,
ops - > enabled ) ;
if ( ! samba_gnutls_weak_crypto_allowed ( ) & & ops - > weak_crypto ) {
ok = false ;
}
return ok ;
2008-11-02 21:28:17 +03:00
}
2006-01-28 15:15:24 +03:00
/* Sometimes we want to force only kerberos, sometimes we want to
* force it ' s avoidance . The old list could be either
* gensec_security_all ( ) , or from cli_credentials_gensec_list ( ) ( ie ,
2012-02-10 13:54:18 +04:00
* an existing list we have trimmed down )
*
* The intended logic is :
*
* if we are in the default AUTO have kerberos :
* - take a reference to the master list
* otherwise
* - always add spnego then :
* - if we ' MUST ' have kerberos :
* only add kerberos mechs
* - if we ' DONT ' want kerberos ' :
* only add non - kerberos mechs
*
* Once we get things like NegoEx or moonshot , this will of course get
* more compplex .
*/
2006-01-28 15:15:24 +03:00
2013-08-05 13:20:21 +04:00
_PUBLIC_ const struct gensec_security_ops * * gensec_use_kerberos_mechs ( TALLOC_CTX * mem_ctx ,
const struct gensec_security_ops * const * old_gensec_list ,
struct cli_credentials * creds )
2006-01-28 15:15:24 +03:00
{
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * new_gensec_list ;
2006-01-28 15:15:24 +03:00
int i , j , num_mechs_in ;
2007-09-29 19:16:38 +04:00
enum credentials_use_kerberos use_kerberos = CRED_AUTO_USE_KERBEROS ;
2014-12-17 21:42:55 +03:00
bool keep_schannel = false ;
2007-09-29 19:16:38 +04:00
if ( creds ) {
use_kerberos = cli_credentials_get_kerberos_state ( creds ) ;
2014-12-17 21:42:55 +03:00
if ( cli_credentials_get_netlogon_creds ( creds ) ! = NULL ) {
keep_schannel = true ;
}
2007-09-29 19:16:38 +04:00
}
2006-01-28 15:15:24 +03:00
for ( num_mechs_in = 0 ; old_gensec_list & & old_gensec_list [ num_mechs_in ] ; num_mechs_in + + ) {
/* noop */
}
2013-08-05 13:20:21 +04:00
new_gensec_list = talloc_array ( mem_ctx ,
const struct gensec_security_ops * ,
num_mechs_in + 1 ) ;
2006-01-28 15:15:24 +03:00
if ( ! new_gensec_list ) {
return NULL ;
}
j = 0 ;
for ( i = 0 ; old_gensec_list & & old_gensec_list [ i ] ; i + + ) {
2013-08-05 12:37:26 +04:00
bool keep = false ;
2017-07-21 00:28:51 +03:00
/*
* We want to keep SPNGEO and other backends
*/
keep = old_gensec_list [ i ] - > glue ;
2013-08-05 12:37:26 +04:00
2014-12-17 21:42:55 +03:00
if ( old_gensec_list [ i ] - > auth_type = = DCERPC_AUTH_TYPE_SCHANNEL ) {
keep = keep_schannel ;
}
2006-01-28 15:15:24 +03:00
switch ( use_kerberos ) {
2013-08-05 12:37:26 +04:00
case CRED_AUTO_USE_KERBEROS :
keep = true ;
break ;
2006-01-28 15:15:24 +03:00
case CRED_DONT_USE_KERBEROS :
2007-10-07 02:16:19 +04:00
if ( old_gensec_list [ i ] - > kerberos = = false ) {
2013-08-05 12:37:26 +04:00
keep = true ;
2006-01-28 15:15:24 +03:00
}
2013-08-05 12:37:26 +04:00
2006-01-28 15:15:24 +03:00
break ;
2013-08-05 12:37:26 +04:00
2006-01-28 15:15:24 +03:00
case CRED_MUST_USE_KERBEROS :
2007-10-07 02:16:19 +04:00
if ( old_gensec_list [ i ] - > kerberos = = true ) {
2013-08-05 12:37:26 +04:00
keep = true ;
2006-01-28 15:15:24 +03:00
}
2013-08-05 12:37:26 +04:00
2006-01-28 15:15:24 +03:00
break ;
2006-07-06 09:51:39 +04:00
default :
/* Can't happen or invalid parameter */
return NULL ;
2006-01-28 15:15:24 +03:00
}
2013-08-05 12:37:26 +04:00
if ( ! keep ) {
continue ;
}
new_gensec_list [ j ] = old_gensec_list [ i ] ;
j + + ;
2006-01-28 15:15:24 +03:00
}
2011-07-21 07:20:26 +04:00
new_gensec_list [ j ] = NULL ;
2006-01-28 15:15:24 +03:00
return new_gensec_list ;
}
2013-08-05 13:20:21 +04:00
_PUBLIC_ const struct gensec_security_ops * * gensec_security_mechs (
2012-01-12 19:18:38 +04:00
struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx )
2006-01-28 15:15:24 +03:00
{
2013-08-05 12:39:16 +04:00
struct cli_credentials * creds = NULL ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * const * backends = gensec_security_all ( ) ;
2013-08-05 12:39:16 +04:00
if ( gensec_security ! = NULL ) {
creds = gensec_get_credentials ( gensec_security ) ;
2011-12-26 03:53:56 +04:00
if ( gensec_security - > settings - > backends ) {
backends = gensec_security - > settings - > backends ;
}
2006-01-28 15:15:24 +03:00
}
2013-08-05 12:39:16 +04:00
return gensec_use_kerberos_mechs ( mem_ctx , backends , creds ) ;
2006-01-28 15:15:24 +03:00
}
2012-01-12 19:18:38 +04:00
_PUBLIC_ const struct gensec_security_ops * gensec_security_by_oid (
struct gensec_security * gensec_security ,
const char * oid_string )
2004-06-20 04:58:09 +04:00
{
2005-05-16 03:42:11 +04:00
int i , j ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2006-01-28 15:15:24 +03:00
const struct gensec_security_ops * backend ;
TALLOC_CTX * mem_ctx = talloc_new ( gensec_security ) ;
if ( ! mem_ctx ) {
return NULL ;
2005-12-05 06:20:40 +03:00
}
2006-01-28 15:15:24 +03:00
backends = gensec_security_mechs ( gensec_security , mem_ctx ) ;
2005-12-05 06:20:40 +03:00
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2011-07-21 07:20:26 +04:00
if ( gensec_security ! = NULL & &
! gensec_security_ops_enabled ( backends [ i ] ,
2009-09-26 22:55:18 +04:00
gensec_security ) )
2008-11-02 21:28:17 +03:00
continue ;
2005-12-05 06:20:40 +03:00
if ( backends [ i ] - > oid ) {
2011-07-21 07:20:26 +04:00
for ( j = 0 ; backends [ i ] - > oid [ j ] ; j + + ) {
2005-12-05 06:20:40 +03:00
if ( backends [ i ] - > oid [ j ] & &
( strcmp ( backends [ i ] - > oid [ j ] , oid_string ) = = 0 ) ) {
2006-01-28 15:15:24 +03:00
backend = backends [ i ] ;
talloc_free ( mem_ctx ) ;
return backend ;
2005-05-16 03:42:11 +04:00
}
}
2004-06-20 04:58:09 +04:00
}
}
2006-01-28 15:15:24 +03:00
talloc_free ( mem_ctx ) ;
2004-06-20 04:58:09 +04:00
return NULL ;
}
2012-01-12 19:18:38 +04:00
_PUBLIC_ const struct gensec_security_ops * gensec_security_by_sasl_name (
struct gensec_security * gensec_security ,
const char * sasl_name )
2004-06-20 04:58:09 +04:00
{
int i ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2006-01-28 15:15:24 +03:00
const struct gensec_security_ops * backend ;
TALLOC_CTX * mem_ctx = talloc_new ( gensec_security ) ;
if ( ! mem_ctx ) {
return NULL ;
2005-12-05 06:20:40 +03:00
}
2006-01-28 15:15:24 +03:00
backends = gensec_security_mechs ( gensec_security , mem_ctx ) ;
2005-12-05 06:20:40 +03:00
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2016-03-01 21:29:40 +03:00
if ( gensec_security ! = NULL & &
! gensec_security_ops_enabled ( backends [ i ] , gensec_security ) ) {
continue ;
}
2011-07-21 07:20:26 +04:00
if ( backends [ i ] - > sasl_name
2005-12-05 06:20:40 +03:00
& & ( strcmp ( backends [ i ] - > sasl_name , sasl_name ) = = 0 ) ) {
2006-01-28 15:15:24 +03:00
backend = backends [ i ] ;
talloc_free ( mem_ctx ) ;
return backend ;
2004-06-20 04:58:09 +04:00
}
}
2006-01-28 15:15:24 +03:00
talloc_free ( mem_ctx ) ;
2004-06-20 04:58:09 +04:00
return NULL ;
}
2013-08-03 13:43:58 +04:00
_PUBLIC_ const struct gensec_security_ops * gensec_security_by_auth_type (
struct gensec_security * gensec_security ,
uint32_t auth_type )
{
int i ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2013-08-03 13:43:58 +04:00
const struct gensec_security_ops * backend ;
2015-07-10 14:01:47 +03:00
TALLOC_CTX * mem_ctx ;
if ( auth_type = = DCERPC_AUTH_TYPE_NONE ) {
return NULL ;
}
mem_ctx = talloc_new ( gensec_security ) ;
2013-08-03 13:43:58 +04:00
if ( ! mem_ctx ) {
return NULL ;
}
backends = gensec_security_mechs ( gensec_security , mem_ctx ) ;
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2013-09-18 19:25:55 +04:00
if ( gensec_security ! = NULL & &
! gensec_security_ops_enabled ( backends [ i ] , gensec_security ) ) {
continue ;
}
2013-08-03 13:43:58 +04:00
if ( backends [ i ] - > auth_type = = auth_type ) {
backend = backends [ i ] ;
talloc_free ( mem_ctx ) ;
return backend ;
}
}
talloc_free ( mem_ctx ) ;
return NULL ;
}
2015-11-26 13:43:02 +03:00
const struct gensec_security_ops * gensec_security_by_name ( struct gensec_security * gensec_security ,
const char * name )
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
{
int i ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2006-01-28 15:15:24 +03:00
const struct gensec_security_ops * backend ;
TALLOC_CTX * mem_ctx = talloc_new ( gensec_security ) ;
if ( ! mem_ctx ) {
return NULL ;
2005-12-05 06:20:40 +03:00
}
2006-01-28 15:15:24 +03:00
backends = gensec_security_mechs ( gensec_security , mem_ctx ) ;
2005-12-05 06:20:40 +03:00
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2011-07-21 07:20:26 +04:00
if ( gensec_security ! = NULL & &
2009-09-26 22:55:18 +04:00
! gensec_security_ops_enabled ( backends [ i ] , gensec_security ) )
2008-11-02 21:28:17 +03:00
continue ;
2011-07-21 07:20:26 +04:00
if ( backends [ i ] - > name
2005-12-05 06:20:40 +03:00
& & ( strcmp ( backends [ i ] - > name , name ) = = 0 ) ) {
2006-01-28 15:15:24 +03:00
backend = backends [ i ] ;
talloc_free ( mem_ctx ) ;
return backend ;
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
}
}
2006-01-28 15:15:24 +03:00
talloc_free ( 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
return NULL ;
}
2005-11-05 14:02:37 +03:00
/**
* Return a unique list of security subsystems from those specified in
2011-07-21 07:20:26 +04:00
* the list of SASL names .
2005-11-05 14:02:37 +03:00
*
2005-12-05 06:20:40 +03:00
* Use the list of enabled GENSEC mechanisms from the credentials
* attached to the gensec_security , and return in our preferred order .
2005-11-05 14:02:37 +03:00
*/
2013-05-11 12:35:59 +04:00
static const struct gensec_security_ops * * gensec_security_by_sasl_list (
struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const char * * sasl_names )
2005-11-05 14:02:37 +03:00
{
const struct gensec_security_ops * * backends_out ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2005-11-05 14:02:37 +03:00
int i , k , sasl_idx ;
int num_backends_out = 0 ;
if ( ! sasl_names ) {
return NULL ;
}
2006-01-28 15:15:24 +03:00
backends = gensec_security_mechs ( gensec_security , mem_ctx ) ;
2005-11-05 14:02:37 +03:00
backends_out = talloc_array ( mem_ctx , const struct gensec_security_ops * , 1 ) ;
if ( ! backends_out ) {
return NULL ;
}
backends_out [ 0 ] = NULL ;
/* Find backends in our preferred order, by walking our list,
* then looking in the supplied list */
2005-12-05 06:20:40 +03:00
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2011-07-21 07:20:26 +04:00
if ( gensec_security ! = NULL & &
2009-09-26 22:55:18 +04:00
! gensec_security_ops_enabled ( backends [ i ] , gensec_security ) )
2008-11-02 21:28:17 +03:00
continue ;
2005-11-05 14:02:37 +03:00
for ( sasl_idx = 0 ; sasl_names [ sasl_idx ] ; sasl_idx + + ) {
if ( ! backends [ i ] - > sasl_name | |
2011-07-21 07:20:26 +04:00
! ( strcmp ( backends [ i ] - > sasl_name ,
2005-11-05 14:02:37 +03:00
sasl_names [ sasl_idx ] ) = = 0 ) ) {
continue ;
}
2011-07-21 07:20:26 +04:00
2005-11-05 14:02:37 +03:00
for ( k = 0 ; backends_out [ k ] ; k + + ) {
if ( backends_out [ k ] = = backends [ i ] ) {
break ;
}
}
2011-07-21 07:20:26 +04:00
2005-11-05 14:02:37 +03:00
if ( k < num_backends_out ) {
/* already in there */
continue ;
}
2011-07-21 07:20:26 +04:00
backends_out = talloc_realloc ( mem_ctx , backends_out ,
const struct gensec_security_ops * ,
2005-11-05 14:02:37 +03:00
num_backends_out + 2 ) ;
if ( ! backends_out ) {
return NULL ;
}
2011-07-21 07:20:26 +04:00
2005-11-05 14:02:37 +03:00
backends_out [ num_backends_out ] = backends [ i ] ;
num_backends_out + + ;
backends_out [ num_backends_out ] = NULL ;
}
}
return backends_out ;
}
2005-05-16 03:42:11 +04:00
/**
* Return a unique list of security subsystems from those specified in
* the OID list . That is , where two OIDs refer to the same module ,
2011-07-21 07:20:26 +04:00
* return that module only once .
2005-05-16 03:42:11 +04:00
*
2005-12-05 06:20:40 +03:00
* Use the list of enabled GENSEC mechanisms from the credentials
* attached to the gensec_security , and return in our preferred order .
2005-05-16 03:42:11 +04:00
*/
2012-01-12 19:18:38 +04:00
_PUBLIC_ const struct gensec_security_ops_wrapper * gensec_security_by_oid_list (
struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
2013-08-05 13:10:55 +04:00
const char * const * oid_strings ,
2012-01-12 19:18:38 +04:00
const char * skip )
2004-08-11 20:13:25 +04:00
{
2005-05-16 03:42:11 +04:00
struct gensec_security_ops_wrapper * backends_out ;
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * backends ;
2005-05-16 03:42:11 +04:00
int i , j , k , oid_idx ;
int num_backends_out = 0 ;
if ( ! oid_strings ) {
return NULL ;
}
2006-01-28 15:15:24 +03:00
backends = gensec_security_mechs ( gensec_security , gensec_security ) ;
2005-05-16 03:42:11 +04:00
backends_out = talloc_array ( mem_ctx , struct gensec_security_ops_wrapper , 1 ) ;
if ( ! backends_out ) {
return NULL ;
}
backends_out [ 0 ] . op = NULL ;
backends_out [ 0 ] . oid = NULL ;
2005-11-05 14:02:37 +03:00
/* Find backends in our preferred order, by walking our list,
* then looking in the supplied list */
2005-12-05 06:20:40 +03:00
for ( i = 0 ; backends & & backends [ i ] ; i + + ) {
2011-07-21 07:20:26 +04:00
if ( gensec_security ! = NULL & &
2009-09-26 22:55:18 +04:00
! gensec_security_ops_enabled ( backends [ i ] , gensec_security ) )
2008-11-02 21:28:17 +03:00
continue ;
2005-11-05 14:02:37 +03:00
if ( ! backends [ i ] - > oid ) {
2005-05-16 03:42:11 +04:00
continue ;
}
2005-11-05 14:02:37 +03:00
for ( oid_idx = 0 ; oid_strings [ oid_idx ] ; oid_idx + + ) {
if ( strcmp ( oid_strings [ oid_idx ] , skip ) = = 0 ) {
2005-05-16 03:42:11 +04:00
continue ;
}
2005-11-05 14:02:37 +03:00
2011-07-21 07:20:26 +04:00
for ( j = 0 ; backends [ i ] - > oid [ j ] ; j + + ) {
2005-05-16 03:42:11 +04:00
if ( ! backends [ i ] - > oid [ j ] | |
2011-07-21 07:20:26 +04:00
! ( strcmp ( backends [ i ] - > oid [ j ] ,
2005-05-16 03:42:11 +04:00
oid_strings [ oid_idx ] ) = = 0 ) ) {
continue ;
}
2011-07-21 07:20:26 +04:00
2005-05-16 03:42:11 +04:00
for ( k = 0 ; backends_out [ k ] . op ; k + + ) {
if ( backends_out [ k ] . op = = backends [ i ] ) {
break ;
}
}
2011-07-21 07:20:26 +04:00
2005-05-16 03:42:11 +04:00
if ( k < num_backends_out ) {
/* already in there */
continue ;
}
2011-07-21 07:20:26 +04:00
backends_out = talloc_realloc ( mem_ctx , backends_out ,
struct gensec_security_ops_wrapper ,
2005-05-16 03:42:11 +04:00
num_backends_out + 2 ) ;
if ( ! backends_out ) {
return NULL ;
}
2011-07-21 07:20:26 +04:00
2005-05-16 03:42:11 +04:00
backends_out [ num_backends_out ] . op = backends [ i ] ;
backends_out [ num_backends_out ] . oid = backends [ i ] - > oid [ j ] ;
num_backends_out + + ;
backends_out [ num_backends_out ] . op = NULL ;
backends_out [ num_backends_out ] . oid = NULL ;
}
}
}
return backends_out ;
}
/**
* Return OIDS from the security subsystems listed
*/
2013-05-11 12:36:12 +04:00
static const char * * gensec_security_oids_from_ops (
struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * const * ops ,
2013-05-11 12:36:12 +04:00
const char * skip )
2005-05-16 03:42:11 +04:00
{
int i ;
int j = 0 ;
int k ;
const char * * oid_list ;
2004-08-11 20:13:25 +04:00
if ( ! ops ) {
return NULL ;
}
2005-05-16 03:42:11 +04:00
oid_list = talloc_array ( mem_ctx , const char * , 1 ) ;
2004-08-11 20:13:25 +04:00
if ( ! oid_list ) {
return NULL ;
}
2011-07-21 07:20:26 +04:00
2005-12-05 06:20:40 +03:00
for ( i = 0 ; ops & & ops [ i ] ; i + + ) {
2011-07-21 07:20:26 +04:00
if ( gensec_security ! = NULL & &
2009-09-26 22:55:18 +04:00
! gensec_security_ops_enabled ( ops [ i ] , gensec_security ) ) {
2008-11-03 01:58:49 +03:00
continue ;
}
2004-08-11 20:13:25 +04:00
if ( ! ops [ i ] - > oid ) {
continue ;
}
2011-07-21 07:20:26 +04:00
2005-05-16 03:42:11 +04:00
for ( k = 0 ; ops [ i ] - > oid [ k ] ; k + + ) {
if ( skip & & strcmp ( skip , ops [ i ] - > oid [ k ] ) = = 0 ) {
} else {
oid_list = talloc_realloc ( mem_ctx , oid_list , const char * , j + 2 ) ;
if ( ! oid_list ) {
return NULL ;
}
oid_list [ j ] = ops [ i ] - > oid [ k ] ;
j + + ;
}
2004-08-11 20:13:25 +04:00
}
}
oid_list [ j ] = NULL ;
return oid_list ;
}
2005-05-16 03:42:11 +04:00
2005-08-20 10:14:14 +04:00
/**
* Return OIDS from the security subsystems listed
*/
2012-01-12 19:18:38 +04:00
_PUBLIC_ const char * * gensec_security_oids_from_ops_wrapped ( TALLOC_CTX * mem_ctx ,
const struct gensec_security_ops_wrapper * wops )
2005-08-20 10:14:14 +04:00
{
int i ;
int j = 0 ;
int k ;
const char * * oid_list ;
if ( ! wops ) {
return NULL ;
}
oid_list = talloc_array ( mem_ctx , const char * , 1 ) ;
if ( ! oid_list ) {
return NULL ;
}
2011-07-21 07:20:26 +04:00
2005-08-20 10:14:14 +04:00
for ( i = 0 ; wops [ i ] . op ; i + + ) {
if ( ! wops [ i ] . op - > oid ) {
continue ;
}
2011-07-21 07:20:26 +04:00
2005-08-20 10:14:14 +04:00
for ( k = 0 ; wops [ i ] . op - > oid [ k ] ; k + + ) {
oid_list = talloc_realloc ( mem_ctx , oid_list , const char * , j + 2 ) ;
if ( ! oid_list ) {
return NULL ;
}
oid_list [ j ] = wops [ i ] . op - > oid [ k ] ;
j + + ;
}
}
oid_list [ j ] = NULL ;
return oid_list ;
}
2005-05-16 03:42:11 +04:00
/**
2005-12-05 06:20:40 +03:00
* Return all the security subsystems currently enabled on a GENSEC context .
2011-07-21 07:20:26 +04:00
*
2007-12-02 21:31:14 +03:00
* This is taken from a list attached to the cli_credentials , and
2005-12-05 06:20:40 +03:00
* skips the OID in ' skip ' . ( Typically the SPNEGO OID )
2011-07-21 07:20:26 +04:00
*
2005-05-16 03:42:11 +04:00
*/
2012-01-12 19:18:38 +04:00
_PUBLIC_ const char * * gensec_security_oids ( struct gensec_security * gensec_security ,
TALLOC_CTX * mem_ctx ,
const char * skip )
2005-05-16 03:42:11 +04:00
{
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * * ops ;
ops = gensec_security_mechs ( gensec_security , mem_ctx ) ;
2008-11-03 01:58:49 +03:00
return gensec_security_oids_from_ops ( gensec_security , mem_ctx , ops , skip ) ;
2005-05-16 03:42:11 +04:00
}
2016-12-30 19:54:12 +03:00
static int gensec_security_destructor ( struct gensec_security * gctx )
{
if ( gctx - > parent_security ! = NULL ) {
if ( gctx - > parent_security - > child_security = = gctx ) {
gctx - > parent_security - > child_security = NULL ;
}
gctx - > parent_security = NULL ;
}
if ( gctx - > child_security ! = NULL ) {
if ( gctx - > child_security - > parent_security = = gctx ) {
gctx - > child_security - > parent_security = NULL ;
}
gctx - > child_security = NULL ;
}
return 0 ;
}
2005-01-05 06:21:45 +03:00
/**
Start the GENSEC system , returning a context pointer .
@ param mem_ctx The parent TALLOC memory context .
@ param gensec_security Returned GENSEC context pointer .
@ note The mem_ctx is only a parent and may be NULL .
2011-01-17 08:20:09 +03:00
@ note , the auth context is moved to be a referenced pointer of the
2011-07-21 07:20:26 +04:00
@ gensec_security return
2004-09-25 16:08:57 +04:00
*/
2011-07-21 07:20:26 +04:00
static NTSTATUS gensec_start ( TALLOC_CTX * mem_ctx ,
2008-11-02 04:05:48 +03:00
struct gensec_settings * settings ,
2011-07-21 07:20:26 +04:00
struct auth4_context * auth_context ,
2006-07-31 18:05:08 +04:00
struct gensec_security * * gensec_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
{
2010-09-27 08:11:42 +04:00
( * gensec_security ) = talloc_zero ( mem_ctx , struct gensec_security ) ;
2005-06-16 15:36:09 +04:00
NT_STATUS_HAVE_NO_MEMORY ( * gensec_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
2011-12-24 03:27:45 +04:00
( * gensec_security ) - > max_update_size = 0 ;
2011-12-24 04:14:26 +04:00
2008-11-03 01:58:49 +03:00
SMB_ASSERT ( settings - > lp_ctx ! = NULL ) ;
2008-11-02 07:49:36 +03:00
( * gensec_security ) - > settings = talloc_reference ( * gensec_security , settings ) ;
2011-01-17 08:20:09 +03:00
/* We need to reference this, not steal, as the caller may be
* python , which won ' t like it if we steal it ' s object away
* from it */
( * gensec_security ) - > auth_context = talloc_reference ( * gensec_security , auth_context ) ;
2005-06-16 15:36:09 +04:00
2016-12-30 19:54:12 +03:00
talloc_set_destructor ( ( * gensec_security ) , gensec_security_destructor ) ;
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 NT_STATUS_OK ;
}
2011-07-21 07:20:26 +04:00
/**
2004-07-06 06:59:05 +04:00
* Start a GENSEC subcontext , with a copy of the properties of the parent
2005-01-05 06:21:45 +03:00
* @ param mem_ctx The parent TALLOC memory context .
2011-07-21 07:20:26 +04:00
* @ param parent The parent GENSEC context
2005-01-05 06:21:45 +03:00
* @ param gensec_security Returned GENSEC context pointer .
r5902: A rather large change...
I wanted to add a simple 'workstation' argument to the DCERPC
authenticated binding calls, but this patch kind of grew from there.
With SCHANNEL, the 'workstation' name (the netbios name of the client)
matters, as this is what ties the session between the NETLOGON ops and
the SCHANNEL bind. This changes a lot of files, and these will again
be changed when jelmer does the credentials work.
I also correct some schannel IDL to distinguish between workstation
names and account names. The distinction matters for domain trust
accounts.
Issues in handling this (issues with lifetime of talloc pointers)
caused me to change the 'creds_CredentialsState' and 'struct
dcerpc_binding' pointers to always be talloc()ed pointers.
In the schannel DB, we now store both the domain and computername, and
query on both. This should ensure we fault correctly when the domain
is specified incorrectly in the SCHANNEL bind.
In the RPC-SCHANNEL test, I finally fixed a bug that vl pointed out,
where the comment claimed we re-used a connection, but in fact we made
a new connection.
This was achived by breaking apart some of the
dcerpc_secondary_connection() logic.
The addition of workstation handling was also propogated to NTLMSSP
and GENSEC, for completeness.
The RPC-SAMSYNC test has been cleaned up a little, using a loop over
usernames/passwords rather than manually expanded tests. This will be
expanded further (the code in #if 0 in this patch) to use a newly
created user account for testing.
In making this test pass test_rpc.sh, I found a bug in the RPC-ECHO
server, caused by the removal of [ref] and the assoicated pointer from
the IDL. This has been re-added, until the underlying pidl issues are
solved.
(This used to be commit 824289dcc20908ddec957a4a892a103eec2da9b9)
2005-03-19 11:34:43 +03:00
* @ note Used by SPNEGO in particular , for the actual implementation mechanism
2004-07-06 06:59:05 +04:00
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_subcontext_start ( TALLOC_CTX * mem_ctx ,
struct gensec_security * parent ,
2004-07-06 06:59:05 +04:00
struct gensec_security * * gensec_security )
{
2016-12-30 19:54:12 +03:00
if ( parent - > child_security ! = NULL ) {
return NT_STATUS_INTERNAL_ERROR ;
}
2010-09-27 08:11:42 +04:00
( * gensec_security ) = talloc_zero ( mem_ctx , struct gensec_security ) ;
2005-06-16 15:36:09 +04:00
NT_STATUS_HAVE_NO_MEMORY ( * gensec_security ) ;
2004-07-06 06:59:05 +04:00
( * * gensec_security ) = * parent ;
( * gensec_security ) - > ops = NULL ;
( * gensec_security ) - > private_data = NULL ;
2017-06-14 17:21:56 +03:00
( * gensec_security ) - > update_busy_ptr = NULL ;
2004-07-06 06:59:05 +04:00
2007-10-07 02:16:19 +04:00
( * gensec_security ) - > subcontext = true ;
2008-10-01 04:27:09 +04:00
( * gensec_security ) - > want_features = parent - > want_features ;
2011-12-24 04:14:26 +04:00
( * gensec_security ) - > max_update_size = parent - > max_update_size ;
2011-10-15 06:17:33 +04:00
( * gensec_security ) - > dcerpc_auth_level = parent - > dcerpc_auth_level ;
2009-02-13 02:24:16 +03:00
( * gensec_security ) - > auth_context = talloc_reference ( * gensec_security , parent - > auth_context ) ;
2008-11-02 07:49:36 +03:00
( * gensec_security ) - > settings = talloc_reference ( * gensec_security , parent - > settings ) ;
2009-02-13 02:24:16 +03:00
( * gensec_security ) - > auth_context = talloc_reference ( * gensec_security , parent - > auth_context ) ;
2004-07-06 06:59:05 +04:00
2016-12-30 19:54:12 +03:00
talloc_set_destructor ( ( * gensec_security ) , gensec_security_destructor ) ;
return NT_STATUS_OK ;
}
_PUBLIC_ NTSTATUS gensec_child_ready ( struct gensec_security * parent ,
struct gensec_security * child )
{
if ( parent - > child_security ! = NULL ) {
return NT_STATUS_INTERNAL_ERROR ;
}
if ( child - > parent_security ! = NULL ) {
return NT_STATUS_INTERNAL_ERROR ;
}
parent - > child_security = child ;
child - > parent_security = parent ;
2004-07-06 18:42:07 +04:00
return NT_STATUS_OK ;
2004-07-06 06:59:05 +04:00
}
2005-01-05 06:21:45 +03:00
/**
Start the GENSEC system , in client mode , returning a context pointer .
@ param mem_ctx The parent TALLOC memory context .
@ param gensec_security Returned GENSEC context pointer .
@ note The mem_ctx is only a parent and may be NULL .
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_client_start ( TALLOC_CTX * mem_ctx ,
2005-06-16 15:36:09 +04:00
struct gensec_security * * gensec_security ,
2008-11-02 04:05:48 +03:00
struct gensec_settings * settings )
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 status ;
2006-07-31 18:05:08 +04:00
2008-11-03 01:58:49 +03:00
if ( settings = = NULL ) {
DEBUG ( 0 , ( " gensec_client_start: no settings given! \n " ) ) ;
return NT_STATUS_INTERNAL_ERROR ;
}
2011-10-17 11:22:33 +04:00
status = gensec_start ( mem_ctx , settings , NULL , gensec_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
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
( * gensec_security ) - > gensec_role = GENSEC_CLIENT ;
return status ;
}
2010-04-13 06:00:06 +04:00
2005-01-05 06:21:45 +03:00
/**
Start the GENSEC system , in server mode , returning a context pointer .
@ param mem_ctx The parent TALLOC memory context .
@ param gensec_security Returned GENSEC context pointer .
@ note The mem_ctx is only a parent and may be NULL .
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_server_start ( TALLOC_CTX * mem_ctx ,
2009-02-13 02:24:16 +03:00
struct gensec_settings * settings ,
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_context ,
2009-02-13 02:24:16 +03:00
struct gensec_security * * gensec_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
{
NTSTATUS status ;
2006-07-31 18:05:08 +04:00
2008-11-03 01:58:49 +03:00
if ( ! settings ) {
DEBUG ( 0 , ( " gensec_server_start: no settings given! \n " ) ) ;
return NT_STATUS_INTERNAL_ERROR ;
}
2011-10-17 11:22:33 +04:00
status = gensec_start ( mem_ctx , settings , auth_context , gensec_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
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
( * gensec_security ) - > gensec_role = GENSEC_SERVER ;
return status ;
}
2017-05-11 01:05:02 +03:00
static NTSTATUS gensec_start_mech ( struct gensec_security * gensec_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
{
NTSTATUS status ;
2013-09-16 20:38:09 +04:00
2017-05-11 01:05:29 +03:00
/*
* Callers sometimes just reuse a context , we should
* clear the internal state before starting it again .
*/
talloc_unlink ( gensec_security , gensec_security - > private_data ) ;
gensec_security - > private_data = NULL ;
2016-12-30 19:54:12 +03:00
if ( gensec_security - > child_security ! = NULL ) {
/*
* The talloc_unlink ( . . , gensec_security - > private_data )
* should have cleared this via
* gensec_security_destructor ( ) .
*/
return NT_STATUS_INTERNAL_ERROR ;
}
2017-05-11 01:05:29 +03:00
2013-09-16 20:38:09 +04:00
if ( gensec_security - > credentials ) {
const char * forced_mech = cli_credentials_get_forced_sasl_mech ( gensec_security - > credentials ) ;
if ( forced_mech & &
( gensec_security - > ops - > sasl_name = = NULL | |
strcasecmp ( forced_mech , gensec_security - > ops - > sasl_name ) ! = 0 ) ) {
DEBUG ( 5 , ( " GENSEC mechanism %s (%s) skipped, as it "
" did not match forced mechanism %s \n " ,
gensec_security - > ops - > name ,
gensec_security - > ops - > sasl_name ,
forced_mech ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
}
2011-07-21 07:20:26 +04:00
DEBUG ( 5 , ( " Starting GENSEC %smechanism %s \n " ,
gensec_security - > subcontext ? " sub " : " " ,
2004-07-13 09:14:59 +04:00
gensec_security - > ops - > name ) ) ;
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
switch ( gensec_security - > gensec_role ) {
case GENSEC_CLIENT :
if ( gensec_security - > ops - > client_start ) {
2007-12-03 19:41:50 +03:00
status = gensec_security - > ops - > client_start ( gensec_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
if ( ! NT_STATUS_IS_OK ( status ) ) {
2011-06-17 07:47:14 +04:00
DEBUG ( gensec_security - > subcontext ? 4 : 2 , ( " Failed to start GENSEC client mech %s: %s \n " ,
2011-07-21 07:20:26 +04:00
gensec_security - > ops - > name , nt_errstr ( 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
}
return status ;
}
2006-03-15 05:39:05 +03:00
break ;
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
case GENSEC_SERVER :
if ( gensec_security - > ops - > server_start ) {
status = gensec_security - > ops - > server_start ( gensec_security ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2004-11-08 05:43:49 +03:00
DEBUG ( 1 , ( " Failed to start GENSEC server mech %s: %s \n " ,
2011-07-21 07:20:26 +04:00
gensec_security - > ops - > name , nt_errstr ( 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
}
return status ;
}
2006-03-15 05:39:05 +03:00
break ;
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 NT_STATUS_INVALID_PARAMETER ;
}
2011-07-21 07:20:26 +04:00
/**
* Start a GENSEC sub - mechanism with a specified mechansim structure , used in SPNEGO
*
*/
NTSTATUS gensec_start_mech_by_ops ( struct gensec_security * gensec_security ,
const struct gensec_security_ops * ops )
{
gensec_security - > ops = ops ;
return gensec_start_mech ( gensec_security ) ;
}
/**
* Start a GENSEC sub - mechanism by DCERPC allocated ' auth type ' number
2005-01-05 06:21:45 +03:00
* @ param gensec_security GENSEC context pointer .
* @ param auth_type DCERPC auth type
2011-07-21 07:20:26 +04:00
* @ param auth_level DCERPC auth level
2004-07-06 06:59:05 +04:00
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_start_mech_by_authtype ( struct gensec_security * gensec_security ,
uint8_t auth_type , uint8_t auth_level )
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
{
2013-09-18 19:24:49 +04:00
gensec_security - > ops = gensec_security_by_auth_type ( gensec_security , auth_type ) ;
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 ( ! gensec_security - > ops ) {
2004-08-25 06:25:20 +04:00
DEBUG ( 3 , ( " Could not find GENSEC backend for auth_type=%d \n " , ( int ) auth_type ) ) ;
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 NT_STATUS_INVALID_PARAMETER ;
}
2011-10-15 06:17:33 +04:00
gensec_security - > dcerpc_auth_level = auth_level ;
2015-06-20 17:19:31 +03:00
/*
* We need to reset sign / seal in order to reset it .
* We may got some default features inherited by the credentials
*/
gensec_security - > want_features & = ~ GENSEC_FEATURE_SIGN ;
gensec_security - > want_features & = ~ GENSEC_FEATURE_SEAL ;
2004-12-21 15:39:39 +03:00
gensec_want_feature ( gensec_security , GENSEC_FEATURE_DCE_STYLE ) ;
2005-08-20 10:14:14 +04:00
gensec_want_feature ( gensec_security , GENSEC_FEATURE_ASYNC_REPLIES ) ;
2004-08-25 06:25:20 +04:00
if ( auth_level = = DCERPC_AUTH_LEVEL_INTEGRITY ) {
2016-09-01 12:00:54 +03:00
if ( gensec_security - > gensec_role = = GENSEC_CLIENT ) {
gensec_want_feature ( gensec_security , GENSEC_FEATURE_SIGN ) ;
}
2016-08-31 22:57:31 +03:00
} else if ( auth_level = = DCERPC_AUTH_LEVEL_PACKET ) {
/*
* For connection oriented DCERPC DCERPC_AUTH_LEVEL_PACKET ( 4 )
* has the same behavior as DCERPC_AUTH_LEVEL_INTEGRITY ( 5 ) .
*/
if ( gensec_security - > gensec_role = = GENSEC_CLIENT ) {
gensec_want_feature ( gensec_security , GENSEC_FEATURE_SIGN ) ;
}
2005-04-25 07:37:37 +04:00
} else if ( auth_level = = DCERPC_AUTH_LEVEL_PRIVACY ) {
2004-12-06 18:44:17 +03:00
gensec_want_feature ( gensec_security , GENSEC_FEATURE_SIGN ) ;
gensec_want_feature ( gensec_security , GENSEC_FEATURE_SEAL ) ;
2005-04-25 07:37:37 +04:00
} else if ( auth_level = = DCERPC_AUTH_LEVEL_CONNECT ) {
/* Default features */
} else {
2011-07-21 07:20:26 +04:00
DEBUG ( 2 , ( " auth_level %d not supported in DCE/RPC authentication \n " ,
2005-04-25 07:37:37 +04:00
auth_level ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
2004-08-25 06:25:20 +04:00
}
2004-08-25 11:13:01 +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_start_mech ( gensec_security ) ;
}
2011-07-21 07:20:26 +04:00
_PUBLIC_ const char * gensec_get_name_by_authtype ( struct gensec_security * gensec_security , uint8_t authtype )
2004-08-10 08:28:00 +04:00
{
const struct gensec_security_ops * ops ;
2013-09-18 19:24:49 +04:00
ops = gensec_security_by_auth_type ( gensec_security , authtype ) ;
2004-08-10 08:28:00 +04:00
if ( ops ) {
return ops - > name ;
}
return NULL ;
}
2011-07-21 07:20:26 +04:00
2004-08-10 08:28:00 +04:00
2008-11-03 01:58:49 +03:00
_PUBLIC_ const char * gensec_get_name_by_oid ( struct gensec_security * gensec_security ,
2011-07-21 07:20:26 +04:00
const char * oid_string )
2004-09-13 08:28:10 +04:00
{
const struct gensec_security_ops * ops ;
2008-11-03 01:58:49 +03:00
ops = gensec_security_by_oid ( gensec_security , oid_string ) ;
2004-09-13 08:28:10 +04:00
if ( ops ) {
return ops - > name ;
}
2005-10-20 07:47:55 +04:00
return oid_string ;
2004-09-13 08:28:10 +04:00
}
2010-09-23 00:57:07 +04:00
/**
2004-07-06 06:59:05 +04:00
* Start a GENSEC sub - mechanism by OID , used in SPNEGO
*
* @ note This should also be used when you wish to just start NLTMSSP ( for example ) , as it uses a
* well - known # define to hook it in .
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_start_mech_by_oid ( struct gensec_security * gensec_security ,
const char * mech_oid )
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-11-03 01:58:49 +03:00
SMB_ASSERT ( gensec_security ! = NULL ) ;
2005-12-05 06:20:40 +03:00
gensec_security - > ops = gensec_security_by_oid ( gensec_security , mech_oid ) ;
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 ( ! gensec_security - > ops ) {
2004-07-06 06:59:05 +04:00
DEBUG ( 3 , ( " Could not find GENSEC backend for oid=%s \n " , mech_oid ) ) ;
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 NT_STATUS_INVALID_PARAMETER ;
}
return gensec_start_mech ( gensec_security ) ;
}
2011-07-21 07:20:26 +04:00
/**
2004-07-06 06:59:05 +04:00
* Start a GENSEC sub - mechanism by a well know SASL name
*
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_start_mech_by_sasl_name ( struct gensec_security * gensec_security ,
const char * sasl_name )
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
{
2005-12-05 06:20:40 +03:00
gensec_security - > ops = gensec_security_by_sasl_name ( gensec_security , sasl_name ) ;
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 ( ! gensec_security - > ops ) {
2004-07-06 06:59:05 +04:00
DEBUG ( 3 , ( " Could not find GENSEC backend for sasl_name=%s \n " , sasl_name ) ) ;
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 NT_STATUS_INVALID_PARAMETER ;
}
return gensec_start_mech ( gensec_security ) ;
2005-10-20 07:47:55 +04:00
}
2011-07-21 07:20:26 +04:00
/**
2006-02-04 12:53:50 +03:00
* Start a GENSEC sub - mechanism with the preferred option from a SASL name list
*
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_start_mech_by_sasl_list ( struct gensec_security * gensec_security ,
const char * * sasl_names )
2006-02-04 12:53:50 +03:00
{
2006-09-10 14:00:42 +04:00
NTSTATUS nt_status = NT_STATUS_INVALID_PARAMETER ;
2006-02-04 12:53:50 +03:00
TALLOC_CTX * mem_ctx = talloc_new ( gensec_security ) ;
const struct gensec_security_ops * * ops ;
2006-09-08 08:36:41 +04:00
int i ;
2006-02-04 12:53:50 +03:00
if ( ! mem_ctx ) {
return NT_STATUS_NO_MEMORY ;
}
ops = gensec_security_by_sasl_list ( gensec_security , mem_ctx , sasl_names ) ;
if ( ! ops | | ! * ops ) {
2011-07-21 07:20:26 +04:00
DEBUG ( 3 , ( " Could not find GENSEC backend for any of sasl_name = %s \n " ,
str_list_join ( mem_ctx ,
2006-02-04 12:53:50 +03:00
sasl_names , ' ' ) ) ) ;
talloc_free ( mem_ctx ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2006-09-08 08:36:41 +04:00
for ( i = 0 ; ops [ i ] ; i + + ) {
nt_status = gensec_start_mech_by_ops ( gensec_security , ops [ i ] ) ;
if ( ! NT_STATUS_EQUAL ( nt_status , NT_STATUS_INVALID_PARAMETER ) ) {
break ;
}
}
2006-02-04 12:53:50 +03:00
talloc_free ( mem_ctx ) ;
return nt_status ;
}
2011-07-21 07:20:26 +04:00
/**
2005-10-20 07:47:55 +04:00
* Start a GENSEC sub - mechanism by an internal name
*
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_start_mech_by_name ( struct gensec_security * gensec_security ,
const char * name )
2005-10-20 07:47:55 +04:00
{
2005-12-05 06:20:40 +03:00
gensec_security - > ops = gensec_security_by_name ( gensec_security , name ) ;
2005-10-20 07:47:55 +04:00
if ( ! gensec_security - > ops ) {
DEBUG ( 3 , ( " Could not find GENSEC backend for name=%s \n " , name ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
return gensec_start_mech ( gensec_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
}
/**
2011-07-21 07:20:26 +04:00
* Associate a credentials structure with a GENSEC context - talloc_reference ( ) s it to the context
2009-12-22 18:24:44 +03:00
*
2006-07-27 14:02:21 +04:00
*/
2011-07-21 07:20:26 +04:00
_PUBLIC_ NTSTATUS gensec_set_credentials ( struct gensec_security * gensec_security , struct cli_credentials * credentials )
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
{
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
gensec_security - > credentials = talloc_reference ( gensec_security , credentials ) ;
2006-12-13 00:47:56 +03:00
NT_STATUS_HAVE_NO_MEMORY ( gensec_security - > credentials ) ;
gensec_want_feature ( gensec_security , cli_credentials_get_gensec_features ( gensec_security - > credentials ) ) ;
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 NT_STATUS_OK ;
}
/*
2011-07-21 07:20:26 +04:00
register a GENSEC backend .
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
The ' name ' can be later used by other backends to find the operations
structure for this backend .
*/
2017-05-12 01:56:29 +03:00
_PUBLIC_ NTSTATUS gensec_register ( TALLOC_CTX * ctx ,
const struct gensec_security_ops * 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
{
2005-12-05 06:20:40 +03:00
if ( gensec_security_by_name ( NULL , ops - > name ) ! = 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
/* its already registered! */
2011-07-21 07:20:26 +04:00
DEBUG ( 0 , ( " GENSEC backend '%s' already registered \n " ,
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
ops - > name ) ) ;
return NT_STATUS_OBJECT_NAME_COLLISION ;
}
2017-05-12 01:56:29 +03:00
generic_security_ops = talloc_realloc ( ctx ,
2011-07-21 07:20:26 +04:00
generic_security_ops ,
2013-08-05 13:20:21 +04:00
const struct gensec_security_ops * ,
2006-01-28 15:15:24 +03:00
gensec_num_backends + 2 ) ;
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 ( ! generic_security_ops ) {
2006-03-20 03:28:12 +03:00
return NT_STATUS_NO_MEMORY ;
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
}
2013-08-05 13:20:21 +04:00
generic_security_ops [ gensec_num_backends ] = ops ;
2004-08-11 20:13:25 +04:00
gensec_num_backends + + ;
2005-12-01 07:58:15 +03:00
generic_security_ops [ gensec_num_backends ] = 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
2011-07-21 07:20:26 +04:00
DEBUG ( 3 , ( " GENSEC backend '%s' registered \n " ,
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
ops - > name ) ) ;
return NT_STATUS_OK ;
}
/*
return the GENSEC interface version , and the size of some critical types
This can be used by backends to either detect compilation errors , or provide
multiple implementations for different smbd compilation options in one module
*/
2013-05-11 12:35:33 +04:00
_PUBLIC_ const struct gensec_critical_sizes * gensec_interface_version ( 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
{
static const struct gensec_critical_sizes critical_sizes = {
GENSEC_INTERFACE_VERSION ,
sizeof ( struct gensec_security_ops ) ,
sizeof ( struct gensec_security ) ,
} ;
return & critical_sizes ;
}
2013-08-05 13:20:21 +04:00
static int sort_gensec ( const struct gensec_security_ops * * gs1 , const struct gensec_security_ops * * gs2 ) {
2006-09-08 10:21:02 +04:00
return ( * gs2 ) - > priority - ( * gs1 ) - > priority ;
2006-09-08 09:24:44 +04:00
}
2008-11-02 04:05:48 +03:00
int gensec_setting_int ( struct gensec_settings * settings , const char * mechanism , const char * name , int default_value )
{
2010-07-16 08:32:42 +04:00
return lpcfg_parm_int ( settings - > lp_ctx , NULL , mechanism , name , default_value ) ;
2008-11-02 04:05:48 +03:00
}
bool gensec_setting_bool ( struct gensec_settings * settings , const char * mechanism , const char * name , bool default_value )
{
2010-07-16 08:32:42 +04:00
return lpcfg_parm_bool ( settings - > lp_ctx , NULL , mechanism , name , default_value ) ;
2008-11-02 04:05:48 +03: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
/*
initialise the GENSEC subsystem
*/
2011-06-06 08:58:28 +04:00
_PUBLIC_ NTSTATUS gensec_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
{
2007-10-07 02:16:19 +04:00
static bool initialized = false ;
2017-04-20 22:24:43 +03:00
# define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
2011-10-21 15:16:44 +04:00
# ifdef STATIC_gensec_MODULES
2010-11-01 07:38:37 +03:00
STATIC_gensec_MODULES_PROTO ;
2011-12-03 10:03:35 +04:00
init_module_fn static_init [ ] = { STATIC_gensec_MODULES } ;
2011-10-07 10:20:33 +04:00
# else
2011-12-03 10:03:35 +04:00
init_module_fn * static_init = NULL ;
2011-10-07 10:20:33 +04:00
# endif
2011-12-03 10:03:35 +04:00
init_module_fn * shared_init ;
2005-12-26 19:46:55 +03:00
2005-12-31 01:46:16 +03:00
if ( initialized ) return NT_STATUS_OK ;
2007-10-07 02:16:19 +04:00
initialized = true ;
2011-07-21 07:20:26 +04:00
2011-12-03 10:03:35 +04:00
shared_init = load_samba_modules ( NULL , " gensec " ) ;
2005-12-31 01:46:16 +03:00
2017-04-20 22:24:43 +03:00
run_init_functions ( NULL , static_init ) ;
run_init_functions ( NULL , shared_init ) ;
2005-12-26 19:46:55 +03:00
talloc_free ( shared_init ) ;
2006-09-08 09:24:44 +04:00
2010-02-13 05:00:03 +03:00
TYPESAFE_QSORT ( generic_security_ops , gensec_num_backends , sort_gensec ) ;
2011-07-21 07:20:26 +04:00
2004-11-07 02:23:15 +03:00
return NT_STATUS_OK ;
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
}