2003-12-14 04:09:10 +03:00
/*
Unix SMB / CIFS implementation .
server side dcerpc authentication code
Copyright ( C ) Andrew Tridgell 2003
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
Copyright ( C ) Stefan ( metze ) Metzmacher 2004
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
2003-12-14 04:09:10 +03: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
2003-12-14 04:09:10 +03:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-12-14 04:09:10 +03:00
*/
# include "includes.h"
2004-11-02 10:42:47 +03:00
# include "rpc_server/dcerpc_server.h"
2008-04-02 06:53:27 +04:00
# include "rpc_server/dcerpc_server_proto.h"
2010-10-30 04:33:53 +04:00
# include "rpc_server/common/proto.h"
2008-04-02 06:53:27 +04:00
# include "librpc/rpc/dcerpc_proto.h"
2005-07-28 04:27:28 +04:00
# include "librpc/gen_ndr/ndr_dcerpc.h"
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials.h"
2005-12-28 18:38:36 +03:00
# include "auth/gensec/gensec.h"
2009-02-13 02:24:16 +03:00
# include "auth/auth.h"
2007-09-28 05:17:46 +04:00
# include "param/param.h"
2011-02-24 03:55:45 +03:00
# include "librpc/rpc/rpc_common.h"
2003-12-14 04:09:10 +03:00
/*
parse any auth information from a dcerpc bind request
2007-10-07 02:25:41 +04:00
return false if we can ' t handle the auth request for some
2003-12-14 13:45:50 +03:00
reason ( in which case we send a bind_nak )
2003-12-14 04:09:10 +03:00
*/
2007-10-07 02:25:41 +04:00
bool dcesrv_auth_bind ( struct dcesrv_call_state * call )
2003-12-14 04:09:10 +03:00
{
2015-06-26 09:10:46 +03:00
struct cli_credentials * server_credentials = NULL ;
2005-06-06 03:05:37 +04:00
struct ncacn_packet * pkt = & call - > pkt ;
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2005-04-25 08:06:59 +04:00
struct dcesrv_auth * auth = & dce_conn - > auth_state ;
2003-12-14 13:45:50 +03:00
NTSTATUS status ;
2015-06-26 09:10:46 +03:00
if ( pkt - > auth_length = = 0 ) {
2015-06-29 12:03:58 +03:00
auth - > auth_type = DCERPC_AUTH_TYPE_NONE ;
auth - > auth_level = DCERPC_AUTH_LEVEL_NONE ;
auth - > auth_context_id = 0 ;
2007-10-07 02:25:41 +04:00
return true ;
2003-12-14 13:45:50 +03:00
}
2010-02-13 07:32:23 +03:00
status = dcerpc_pull_auth_trailer ( pkt , call , & pkt - > u . bind . auth_info ,
2015-06-26 09:10:46 +03:00
& call - > in_auth_info ,
2016-06-20 17:11:37 +03:00
NULL , true ) ;
2015-06-26 09:10:46 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2016-06-23 14:50:39 +03:00
/*
2016-08-31 22:39:25 +03:00
* Setting DCERPC_AUTH_LEVEL_NONE ,
* gives the caller the reject_reason
* as auth_context_id .
*
* Note : DCERPC_AUTH_LEVEL_NONE = = 1
2016-06-23 14:50:39 +03:00
*/
2016-08-31 22:39:25 +03:00
auth - > auth_type = DCERPC_AUTH_TYPE_NONE ;
auth - > auth_level = DCERPC_AUTH_LEVEL_NONE ;
auth - > auth_context_id =
DCERPC_BIND_NAK_REASON_PROTOCOL_VERSION_NOT_SUPPORTED ;
2015-06-26 09:10:46 +03:00
return false ;
}
2015-07-10 14:55:27 +03:00
switch ( call - > in_auth_info . auth_level ) {
case DCERPC_AUTH_LEVEL_CONNECT :
case DCERPC_AUTH_LEVEL_CALL :
case DCERPC_AUTH_LEVEL_PACKET :
case DCERPC_AUTH_LEVEL_INTEGRITY :
case DCERPC_AUTH_LEVEL_PRIVACY :
/*
* We evaluate auth_type only if auth_level was valid
*/
break ;
default :
/*
* Setting DCERPC_AUTH_LEVEL_NONE ,
2016-08-31 22:39:25 +03:00
* gives the caller the reject_reason
* as auth_context_id .
2015-07-10 14:55:27 +03:00
*
* Note : DCERPC_AUTH_LEVEL_NONE = = 1
*/
auth - > auth_type = DCERPC_AUTH_TYPE_NONE ;
auth - > auth_level = DCERPC_AUTH_LEVEL_NONE ;
2016-08-31 22:39:25 +03:00
auth - > auth_context_id = DCERPC_BIND_NAK_REASON_NOT_SPECIFIED ;
2015-07-10 14:55:27 +03:00
return false ;
}
2015-06-26 09:10:46 +03:00
auth - > auth_type = call - > in_auth_info . auth_type ;
auth - > auth_level = call - > in_auth_info . auth_level ;
auth - > auth_context_id = call - > in_auth_info . auth_context_id ;
2015-06-29 12:03:58 +03:00
2005-10-20 07:47:55 +04:00
server_credentials
= cli_credentials_init ( call ) ;
if ( ! server_credentials ) {
DEBUG ( 1 , ( " Failed to init server credentials \n " ) ) ;
2007-10-07 02:25:41 +04:00
return false ;
2005-10-20 07:47:55 +04:00
}
2007-12-04 22:05:00 +03:00
cli_credentials_set_conf ( server_credentials , call - > conn - > dce_ctx - > lp_ctx ) ;
2007-12-14 00:46:17 +03:00
status = cli_credentials_set_machine_account ( server_credentials , call - > conn - > dce_ctx - > lp_ctx ) ;
2005-10-20 07:47:55 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2015-06-26 09:10:46 +03:00
DEBUG ( 1 , ( " Failed to obtain server credentials: %s \n " ,
nt_errstr ( status ) ) ) ;
return false ;
2005-10-20 07:47:55 +04:00
}
2009-02-13 02:24:16 +03:00
status = samba_server_gensec_start ( dce_conn , call - > event_ctx ,
call - > msg_ctx ,
2010-07-16 08:32:42 +04:00
call - > conn - > dce_ctx - > lp_ctx ,
2009-02-13 02:24:16 +03:00
server_credentials ,
NULL ,
& auth - > gensec_security ) ;
2015-01-22 16:05:15 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to call samba_server_gensec_start %s \n " ,
nt_errstr ( status ) ) ) ;
return false ;
}
if ( call - > conn - > remote_address ! = NULL ) {
status = gensec_set_remote_address ( auth - > gensec_security ,
call - > conn - > remote_address ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to call gensec_set_remote_address() %s \n " ,
nt_errstr ( status ) ) ) ;
return false ;
}
}
2005-10-20 07:47:55 +04:00
2015-06-29 12:03:58 +03:00
status = gensec_start_mech_by_authtype ( auth - > gensec_security , auth - > auth_type ,
auth - > auth_level ) ;
2003-12-14 13:45:50 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2016-08-31 22:39:25 +03:00
const char * backend_name =
gensec_get_name_by_authtype ( auth - > gensec_security ,
auth - > auth_type ) ;
DEBUG ( 3 , ( " Failed to start GENSEC mechanism for DCERPC server: "
" auth_type=%d (%s), auth_level=%d: %s \n " ,
( int ) auth - > auth_type , backend_name ,
2015-06-29 12:03:58 +03:00
( int ) auth - > auth_level ,
2005-04-25 08:06:59 +04:00
nt_errstr ( status ) ) ) ;
2016-08-31 22:39:25 +03:00
/*
* Setting DCERPC_AUTH_LEVEL_NONE ,
* gives the caller the reject_reason
* as auth_context_id .
*
* Note : DCERPC_AUTH_LEVEL_NONE = = 1
*/
auth - > auth_type = DCERPC_AUTH_TYPE_NONE ;
auth - > auth_level = DCERPC_AUTH_LEVEL_NONE ;
if ( backend_name ! = NULL ) {
auth - > auth_context_id =
DCERPC_BIND_NAK_REASON_INVALID_CHECKSUM ;
} else {
auth - > auth_context_id =
DCERPC_BIND_NAK_REASON_INVALID_AUTH_TYPE ;
}
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2004-06-04 13:46:46 +04:00
2007-10-07 02:25:41 +04:00
return true ;
2003-12-14 04:09:10 +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
add any auth information needed in a bind ack , and process the authentication
information found in the bind .
2003-12-14 04:09:10 +03:00
*/
2007-08-17 09:28:39 +04:00
NTSTATUS dcesrv_auth_bind_ack ( struct dcesrv_call_state * call , struct ncacn_packet * pkt )
2003-12-14 04:09:10 +03:00
{
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2003-12-14 13:45:50 +03:00
NTSTATUS status ;
2014-01-03 11:39:12 +04:00
bool want_header_signing = false ;
2003-12-14 13:45:50 +03:00
2015-06-26 09:10:46 +03:00
dce_conn - > allow_alter = true ;
dce_conn - > allow_auth3 = true ;
2015-06-26 09:10:46 +03:00
if ( call - > pkt . auth_length = = 0 ) {
2015-06-26 09:10:46 +03:00
dce_conn - > auth_state . auth_finished = true ;
2015-06-26 09:10:46 +03:00
dce_conn - > allow_request = true ;
2007-08-17 09:28:39 +04:00
return NT_STATUS_OK ;
2003-12-14 13:45:50 +03:00
}
2015-06-26 09:10:46 +03:00
/* We can't work without an existing gensec state */
if ( ! call - > conn - > auth_state . gensec_security ) {
return NT_STATUS_INTERNAL_ERROR ;
}
2014-01-03 11:39:12 +04:00
if ( call - > pkt . pfc_flags & DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN ) {
2014-01-08 13:57:44 +04:00
dce_conn - > auth_state . client_hdr_signing = true ;
2014-01-03 11:39:12 +04:00
want_header_signing = true ;
}
if ( ! lpcfg_parm_bool ( call - > conn - > dce_ctx - > lp_ctx , NULL , " dcesrv " , " header signing " , true ) ) {
want_header_signing = false ;
}
2015-06-26 09:10:46 +03:00
call - > _out_auth_info = ( struct dcerpc_auth ) {
. auth_type = dce_conn - > auth_state . auth_type ,
. auth_level = dce_conn - > auth_state . auth_level ,
. auth_context_id = dce_conn - > auth_state . auth_context_id ,
} ;
call - > out_auth_info = & call - > _out_auth_info ;
2013-12-13 22:37:21 +04:00
status = gensec_update_ev ( dce_conn - > auth_state . gensec_security ,
2011-10-17 11:22:33 +04:00
call , call - > event_ctx ,
2015-06-26 09:10:46 +03:00
call - > in_auth_info . credentials ,
& call - > out_auth_info - > 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
if ( NT_STATUS_IS_OK ( status ) ) {
2010-05-30 16:53:36 +04:00
status = gensec_session_info ( dce_conn - > auth_state . gensec_security ,
2011-08-01 09:39:01 +04:00
dce_conn ,
2010-05-30 16:53:36 +04:00
& dce_conn - > auth_state . session_info ) ;
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 ) ) {
DEBUG ( 1 , ( " Failed to establish session_info: %s \n " , nt_errstr ( status ) ) ) ;
2007-08-17 09:28:39 +04:00
return 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
}
2015-06-26 09:10:46 +03:00
dce_conn - > auth_state . auth_finished = true ;
2015-06-26 09:10:46 +03:00
dce_conn - > allow_request = true ;
2004-09-12 07:18:24 +04:00
2014-01-03 11:39:12 +04:00
if ( ! gensec_have_feature ( dce_conn - > auth_state . gensec_security ,
GENSEC_FEATURE_SIGN_PKT_HEADER ) )
{
want_header_signing = false ;
}
if ( want_header_signing ) {
2008-08-07 00:28:04 +04:00
gensec_want_feature ( dce_conn - > auth_state . gensec_security ,
GENSEC_FEATURE_SIGN_PKT_HEADER ) ;
2014-01-08 13:57:44 +04:00
dce_conn - > auth_state . hdr_signing = true ;
2014-01-03 11:39:12 +04:00
pkt - > pfc_flags | = DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN ;
2008-08-07 00:28:04 +04:00
}
2005-04-25 08:06:59 +04:00
/* Now that we are authenticated, go back to the generic session key... */
2004-09-12 07:18:24 +04:00
dce_conn - > auth_state . session_key = dcesrv_generic_session_key ;
2007-08-17 09:28:39 +04: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
} else if ( NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
2014-01-03 11:39:12 +04:00
if ( ! gensec_have_feature ( dce_conn - > auth_state . gensec_security ,
GENSEC_FEATURE_SIGN_PKT_HEADER ) )
{
want_header_signing = false ;
}
if ( want_header_signing ) {
gensec_want_feature ( dce_conn - > auth_state . gensec_security ,
GENSEC_FEATURE_SIGN_PKT_HEADER ) ;
2014-01-08 13:57:44 +04:00
dce_conn - > auth_state . hdr_signing = true ;
2014-01-03 11:39:12 +04:00
pkt - > pfc_flags | = DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN ;
}
2007-08-17 09:28:39 +04: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
} else {
2010-09-04 01:02:38 +04:00
DEBUG ( 4 , ( " GENSEC mech rejected the incoming authentication at bind_ack: %s \n " ,
nt_errstr ( status ) ) ) ;
2007-08-17 09:28:39 +04:00
return status ;
2003-12-14 13:45:50 +03:00
}
}
/*
2004-06-04 03:15:16 +04:00
process the final stage of a auth request
2003-12-14 13:45:50 +03:00
*/
2007-10-07 02:25:41 +04:00
bool dcesrv_auth_auth3 ( struct dcesrv_call_state * call )
2003-12-14 13:45:50 +03:00
{
2005-06-06 03:05:37 +04:00
struct ncacn_packet * pkt = & call - > pkt ;
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2003-12-14 13:45:50 +03:00
NTSTATUS status ;
2015-06-26 09:10:46 +03:00
if ( pkt - > auth_length = = 0 ) {
return false ;
}
2015-06-26 09:10:46 +03:00
if ( dce_conn - > auth_state . auth_finished ) {
2015-06-26 09:10:46 +03:00
return false ;
}
/* We can't work without an existing gensec state */
if ( ! dce_conn - > auth_state . gensec_security ) {
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2010-02-13 07:32:23 +03:00
status = dcerpc_pull_auth_trailer ( pkt , call , & pkt - > u . auth3 . auth_info ,
2016-06-20 17:11:37 +03:00
& call - > in_auth_info , NULL , true ) ;
2010-02-13 07:32:23 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2016-06-23 14:50:39 +03:00
/*
* Windows returns DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY
* instead of DCERPC_NCA_S_PROTO_ERROR .
*/
call - > fault_code = DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY ;
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2015-06-26 09:10:46 +03:00
if ( call - > in_auth_info . auth_type ! = dce_conn - > auth_state . auth_type ) {
return false ;
}
if ( call - > in_auth_info . auth_level ! = dce_conn - > auth_state . auth_level ) {
return false ;
}
if ( call - > in_auth_info . auth_context_id ! = dce_conn - > auth_state . auth_context_id ) {
return false ;
}
2015-06-26 09:10:46 +03:00
call - > _out_auth_info = ( struct dcerpc_auth ) {
. auth_type = dce_conn - > auth_state . auth_type ,
. auth_level = dce_conn - > auth_state . auth_level ,
. auth_context_id = dce_conn - > auth_state . auth_context_id ,
} ;
call - > out_auth_info = & call - > _out_auth_info ;
2004-09-11 16:48:27 +04:00
/* Pass the extra data we got from the client down to gensec for processing */
2013-12-13 22:37:21 +04:00
status = gensec_update_ev ( dce_conn - > auth_state . gensec_security ,
2011-10-17 11:22:33 +04:00
call , call - > event_ctx ,
2015-06-26 09:10:46 +03:00
call - > in_auth_info . credentials ,
& call - > out_auth_info - > 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
if ( NT_STATUS_IS_OK ( status ) ) {
status = gensec_session_info ( dce_conn - > auth_state . gensec_security ,
2011-08-01 09:39:01 +04:00
dce_conn ,
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
& dce_conn - > auth_state . session_info ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to establish session_info: %s \n " , nt_errstr ( status ) ) ) ;
2007-10-07 02:25:41 +04:00
return false ;
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
}
2015-06-26 09:10:46 +03:00
dce_conn - > auth_state . auth_finished = true ;
2015-06-26 09:10:46 +03:00
dce_conn - > allow_request = true ;
2005-08-23 02:33:58 +04:00
/* Now that we are authenticated, go back to the generic session key... */
2004-09-12 07:18:24 +04:00
dce_conn - > auth_state . session_key = dcesrv_generic_session_key ;
2015-07-14 17:18:45 +03:00
if ( call - > out_auth_info - > credentials . length ! = 0 ) {
DEBUG ( 4 , ( " GENSEC produced output token (len=%u) at bind_auth3 \n " ,
( unsigned ) call - > out_auth_info - > credentials . length ) ) ;
return false ;
}
2007-10-07 02:25:41 +04:00
return true ;
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
} else {
2010-09-04 01:02:38 +04:00
DEBUG ( 4 , ( " GENSEC mech rejected the incoming authentication at bind_auth3: %s \n " ,
2004-06-04 03:15:16 +04:00
nt_errstr ( status ) ) ) ;
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
}
2004-12-06 20:48:51 +03:00
/*
parse any auth information from a dcerpc alter request
2007-10-07 02:25:41 +04:00
return false if we can ' t handle the auth request for some
2004-12-06 20:48:51 +03:00
reason ( in which case we send a bind_nak ( is this true for here ? ) )
*/
2007-10-07 02:25:41 +04:00
bool dcesrv_auth_alter ( struct dcesrv_call_state * call )
2004-12-06 20:48:51 +03:00
{
2005-06-06 03:05:37 +04:00
struct ncacn_packet * pkt = & call - > pkt ;
2004-12-06 20:48:51 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2010-02-13 07:32:23 +03:00
NTSTATUS status ;
2004-12-06 20:48:51 +03:00
2005-01-10 15:39:42 +03:00
/* on a pure interface change there is no auth blob */
2015-06-26 09:10:46 +03:00
if ( pkt - > auth_length = = 0 ) {
2015-06-26 09:10:46 +03:00
if ( ! dce_conn - > auth_state . auth_finished ) {
return false ;
}
2007-10-07 02:25:41 +04:00
return true ;
2005-01-10 15:39:42 +03:00
}
2015-06-26 09:10:46 +03:00
if ( dce_conn - > auth_state . auth_finished ) {
2016-06-23 14:50:39 +03:00
call - > fault_code = DCERPC_FAULT_ACCESS_DENIED ;
2007-10-07 02:25:41 +04:00
return false ;
2004-12-06 20:48:51 +03:00
}
2015-06-26 09:10:46 +03:00
/* We can't work without an existing gensec state */
if ( ! dce_conn - > auth_state . gensec_security ) {
2007-10-07 02:25:41 +04:00
return false ;
2004-12-06 20:48:51 +03:00
}
2010-02-13 07:32:23 +03:00
status = dcerpc_pull_auth_trailer ( pkt , call , & pkt - > u . alter . auth_info ,
2016-06-20 17:11:37 +03:00
& call - > in_auth_info , NULL , true ) ;
2010-02-13 07:32:23 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2016-06-23 14:50:39 +03:00
call - > fault_code = DCERPC_NCA_S_PROTO_ERROR ;
return false ;
}
if ( call - > in_auth_info . auth_type = = DCERPC_AUTH_TYPE_NONE ) {
call - > fault_code = DCERPC_FAULT_ACCESS_DENIED ;
2007-10-07 02:25:41 +04:00
return false ;
2004-12-06 20:48:51 +03:00
}
2015-06-26 09:10:46 +03:00
if ( call - > in_auth_info . auth_type ! = dce_conn - > auth_state . auth_type ) {
return false ;
}
if ( call - > in_auth_info . auth_level ! = dce_conn - > auth_state . auth_level ) {
return false ;
}
if ( call - > in_auth_info . auth_context_id ! = dce_conn - > auth_state . auth_context_id ) {
return false ;
}
2007-10-07 02:25:41 +04:00
return true ;
2004-12-06 20:48:51 +03:00
}
/*
add any auth information needed in a alter ack , and process the authentication
information found in the alter .
*/
2007-08-17 09:28:39 +04:00
NTSTATUS dcesrv_auth_alter_ack ( struct dcesrv_call_state * call , struct ncacn_packet * pkt )
2004-12-06 20:48:51 +03:00
{
struct dcesrv_connection * dce_conn = call - > conn ;
NTSTATUS status ;
2005-01-11 04:53:14 +03:00
/* on a pure interface change there is no auth_info structure
setup */
2015-06-26 09:10:46 +03:00
if ( call - > pkt . auth_length = = 0 ) {
2007-08-17 09:28:39 +04:00
return NT_STATUS_OK ;
2005-01-10 15:39:42 +03:00
}
2004-12-06 20:48:51 +03:00
if ( ! call - > conn - > auth_state . gensec_security ) {
2015-06-26 09:10:46 +03:00
return NT_STATUS_INTERNAL_ERROR ;
2004-12-06 20:48:51 +03:00
}
2015-06-26 09:10:46 +03:00
call - > _out_auth_info = ( struct dcerpc_auth ) {
. auth_type = dce_conn - > auth_state . auth_type ,
. auth_level = dce_conn - > auth_state . auth_level ,
. auth_context_id = dce_conn - > auth_state . auth_context_id ,
} ;
call - > out_auth_info = & call - > _out_auth_info ;
2013-12-13 22:37:21 +04:00
status = gensec_update_ev ( dce_conn - > auth_state . gensec_security ,
2011-10-17 11:22:33 +04:00
call , call - > event_ctx ,
2015-06-26 09:10:46 +03:00
call - > in_auth_info . credentials ,
& call - > out_auth_info - > credentials ) ;
2005-01-11 04:53:14 +03:00
2004-12-06 20:48:51 +03:00
if ( NT_STATUS_IS_OK ( status ) ) {
status = gensec_session_info ( dce_conn - > auth_state . gensec_security ,
2011-08-01 09:39:01 +04:00
dce_conn ,
2004-12-06 20:48:51 +03:00
& dce_conn - > auth_state . session_info ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to establish session_info: %s \n " , nt_errstr ( status ) ) ) ;
2007-08-17 09:28:39 +04:00
return status ;
2004-12-06 20:48:51 +03:00
}
2015-06-26 09:10:46 +03:00
dce_conn - > auth_state . auth_finished = true ;
2015-06-26 09:10:46 +03:00
dce_conn - > allow_request = true ;
2004-12-06 20:48:51 +03:00
/* Now that we are authenticated, got back to the generic session key... */
dce_conn - > auth_state . session_key = dcesrv_generic_session_key ;
2007-08-17 09:28:39 +04:00
return NT_STATUS_OK ;
2004-12-06 20:48:51 +03:00
} else if ( NT_STATUS_EQUAL ( status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
2007-08-17 09:28:39 +04:00
return NT_STATUS_OK ;
2004-12-06 20:48:51 +03:00
}
2005-12-29 01:47:22 +03:00
2010-09-04 01:02:38 +04:00
DEBUG ( 4 , ( " GENSEC mech rejected the incoming authentication at auth alter_ack: %s \n " ,
nt_errstr ( status ) ) ) ;
2007-08-17 09:28:39 +04:00
return status ;
2004-12-06 20:48:51 +03:00
}
2004-09-25 11:25:51 +04:00
2003-12-14 13:45:50 +03:00
/*
2015-10-28 15:04:38 +03:00
check credentials on a packet
2003-12-14 13:45:50 +03:00
*/
2015-10-28 15:04:38 +03:00
bool dcesrv_auth_pkt_pull ( struct dcesrv_call_state * call ,
DATA_BLOB * full_packet ,
uint8_t required_flags ,
uint8_t optional_flags ,
uint8_t payload_offset ,
DATA_BLOB * payload_and_verifier )
2003-12-14 13:45:50 +03:00
{
2005-06-06 03:05:37 +04:00
struct ncacn_packet * pkt = & call - > pkt ;
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2015-10-28 15:04:38 +03:00
const struct dcerpc_auth tmp_auth = {
. auth_type = dce_conn - > auth_state . auth_type ,
. auth_level = dce_conn - > auth_state . auth_level ,
. auth_context_id = dce_conn - > auth_state . auth_context_id ,
} ;
2003-12-14 13:45:50 +03:00
NTSTATUS status ;
2015-06-26 09:10:46 +03:00
if ( ! dce_conn - > allow_request ) {
2016-09-01 11:31:04 +03:00
call - > fault_code = DCERPC_NCA_S_PROTO_ERROR ;
2015-06-26 09:10:46 +03:00
return false ;
}
2015-07-14 17:18:45 +03:00
if ( dce_conn - > auth_state . auth_invalid ) {
return false ;
}
2015-10-28 15:04:38 +03:00
status = dcerpc_ncacn_pull_pkt_auth ( & tmp_auth ,
dce_conn - > auth_state . gensec_security ,
call ,
2015-10-28 15:04:38 +03:00
pkt - > ptype ,
required_flags ,
optional_flags ,
2015-10-28 15:04:38 +03:00
payload_offset ,
2015-10-28 15:04:38 +03:00
payload_and_verifier ,
2015-10-28 15:04:38 +03:00
full_packet ,
pkt ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_RPC_PROTOCOL_ERROR ) ) {
call - > fault_code = DCERPC_NCA_S_PROTO_ERROR ;
2014-01-09 13:59:01 +04:00
return false ;
}
2015-10-28 15:04:38 +03:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_RPC_UNSUPPORTED_AUTHN_LEVEL ) ) {
call - > fault_code = DCERPC_NCA_S_UNSUPPORTED_AUTHN_LEVEL ;
2014-01-09 13:59:01 +04:00
return false ;
}
2015-10-28 15:04:38 +03:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_RPC_SEC_PKG_ERROR ) ) {
call - > fault_code = DCERPC_FAULT_SEC_PKG_ERROR ;
2014-01-09 13:59:01 +04:00
return false ;
}
2015-10-28 15:04:38 +03:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_ACCESS_DENIED ) ) {
call - > fault_code = DCERPC_FAULT_ACCESS_DENIED ;
2016-09-01 11:35:13 +03:00
return false ;
}
2016-09-01 11:31:04 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return false ;
}
return true ;
2003-12-14 13:45:50 +03:00
}
/*
push a signed or sealed dcerpc request packet into a blob
*/
2007-10-07 02:25:41 +04:00
bool dcesrv_auth_response ( struct dcesrv_call_state * call ,
2008-08-11 20:12:54 +04:00
DATA_BLOB * blob , size_t sig_size ,
struct ncacn_packet * pkt )
2003-12-14 13:45:50 +03:00
{
This patch adds a better dcerpc server infastructure.
1.) We now register endpoint servers add startup via register_backend()
and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context
2.) each endpoint server can register at context creation time as much interfaces as it wants
(multiple interfaces on one endpoint are supported!)
(NOTE: there's a difference between 'endpoint server' and 'endpoint'!
for details look at rpc_server/dcesrv_server.h)
3.) one endpoint can have a security descriptor registered to it self
this will be checked in the future when a client wants to connect
to an smb pipe endpoint.
4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module
it takes this options in the [globals] section:
dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper
dcerpc remote:binding = ...
dcerpc remote:user = ...
dcerpc remote:password = ...
5.) we currently have tree endpoint servers: epmapper, rpcecho and remote
the default for the 'dcerpc endpiont servers = epmapper, rpcecho'
for testing you can also do
dcerpc endpoint servers = rpcecho, remote, epmapper
dcerpc remote:interfaces = srvsvc, samr, netlogon
6,) please notice the the epmapper now only returns NO_ENTRIES
(but I think we'll find a solution for this too:-)
7.) also there're some other stuff left, but step by step :-)
This patch also includes updates for the
register_subsystem() , ntvfs_init(), and some other funtions
to check for duplicate subsystem registration
metze
(hmmm, my first large commit...I hope it works as supposed :-)
(This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349)
2004-01-09 01:55:27 +03:00
struct dcesrv_connection * dce_conn = call - > conn ;
2003-12-14 13:45:50 +03:00
NTSTATUS status ;
2007-11-09 21:24:51 +03:00
enum ndr_err_code ndr_err ;
2003-12-14 13:45:50 +03:00
struct ndr_push * ndr ;
2010-02-16 12:21:29 +03:00
uint32_t payload_length ;
2006-10-23 10:08:25 +04:00
DATA_BLOB creds2 ;
2003-12-14 13:45:50 +03:00
2015-06-26 09:10:46 +03:00
switch ( dce_conn - > auth_state . auth_level ) {
2008-09-12 17:47:02 +04:00
case DCERPC_AUTH_LEVEL_PRIVACY :
case DCERPC_AUTH_LEVEL_INTEGRITY :
2016-08-31 22:43:14 +03:00
case DCERPC_AUTH_LEVEL_PACKET :
2015-06-20 18:47:14 +03:00
if ( sig_size = = 0 ) {
return false ;
}
2008-09-12 17:47:02 +04:00
break ;
case DCERPC_AUTH_LEVEL_CONNECT :
/*
2010-11-03 11:23:00 +03:00
* TODO : let the gensec mech decide if it wants to generate a
* signature that might be needed for schannel . . .
2008-09-12 17:47:02 +04:00
*/
2010-05-09 19:20:01 +04:00
status = ncacn_push_auth ( blob , call , pkt , NULL ) ;
2003-12-14 13:45:50 +03:00
return NT_STATUS_IS_OK ( status ) ;
2008-09-12 17:47:02 +04:00
case DCERPC_AUTH_LEVEL_NONE :
2010-05-09 19:20:01 +04:00
status = ncacn_push_auth ( blob , call , pkt , NULL ) ;
2008-09-12 17:47:02 +04:00
return NT_STATUS_IS_OK ( status ) ;
default :
return false ;
2003-12-14 13:45:50 +03:00
}
2015-06-26 09:10:46 +03:00
if ( ! dce_conn - > auth_state . gensec_security ) {
return false ;
}
2010-05-09 19:20:01 +04:00
ndr = ndr_push_init_ctx ( call ) ;
2003-12-14 13:45:50 +03:00
if ( ! ndr ) {
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2004-06-16 16:44:15 +04:00
if ( ! ( pkt - > drep [ 0 ] & DCERPC_DREP_LE ) ) {
2003-12-17 05:06:44 +03:00
ndr - > flags | = LIBNDR_FLAG_BIGENDIAN ;
}
2007-11-09 21:24:51 +03:00
ndr_err = ndr_push_ncacn_packet ( ndr , NDR_SCALARS | NDR_BUFFERS , pkt ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2015-06-26 09:10:46 +03:00
call - > _out_auth_info = ( struct dcerpc_auth ) {
. auth_type = dce_conn - > auth_state . auth_type ,
. auth_level = dce_conn - > auth_state . auth_level ,
. auth_context_id = dce_conn - > auth_state . auth_context_id ,
} ;
call - > out_auth_info = & call - > _out_auth_info ;
2010-02-16 12:21:29 +03:00
/* pad to 16 byte multiple in the payload portion of the
packet . This matches what w2k3 does . Note that we can ' t use
ndr_push_align ( ) as that is relative to the start of the
whole packet , whereas w2k8 wants it relative to the start
of the stub */
2015-06-26 09:10:46 +03:00
call - > out_auth_info - > auth_pad_length =
2015-06-20 18:49:02 +03:00
DCERPC_AUTH_PAD_LENGTH ( pkt - > u . response . stub_and_verifier . length ) ;
2015-06-26 09:10:46 +03:00
ndr_err = ndr_push_zero ( ndr , call - > out_auth_info - > auth_pad_length ) ;
2008-09-13 12:22:39 +04:00
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
return false ;
}
2003-12-14 13:45:50 +03:00
2008-09-13 12:22:39 +04:00
payload_length = pkt - > u . response . stub_and_verifier . length +
2015-06-26 09:10:46 +03:00
call - > out_auth_info - > auth_pad_length ;
2004-09-11 19:11:36 +04:00
/* add the auth verifier */
2007-11-09 21:24:51 +03:00
ndr_err = ndr_push_dcerpc_auth ( ndr , NDR_SCALARS | NDR_BUFFERS ,
2015-06-26 09:10:46 +03:00
call - > out_auth_info ) ;
2007-11-09 21:24:51 +03:00
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
2007-10-07 02:25:41 +04:00
return false ;
2004-09-11 19:11:36 +04:00
}
/* extract the whole packet as a blob */
* blob = ndr_push_blob ( ndr ) ;
2008-09-12 17:47:02 +04:00
/*
* Setup the frag and auth length in the packet buffer .
* This is needed if the GENSEC mech does AEAD signing
* of the packet headers . The signature itself will be
* appended later .
*/
dcerpc_set_frag_length ( blob , blob - > length + sig_size ) ;
dcerpc_set_auth_length ( blob , sig_size ) ;
2004-09-11 19:11:36 +04:00
2003-12-14 13:45:50 +03:00
/* sign or seal the packet */
2015-06-26 09:10:46 +03:00
switch ( dce_conn - > auth_state . auth_level ) {
2003-12-14 13:45:50 +03:00
case DCERPC_AUTH_LEVEL_PRIVACY :
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
status = gensec_seal_packet ( dce_conn - > auth_state . gensec_security ,
2004-09-25 15:24:10 +04:00
call ,
2004-09-11 19:11:36 +04:00
ndr - > data + DCERPC_REQUEST_LENGTH ,
2004-09-12 10:04:03 +04:00
payload_length ,
2004-09-11 19:11:36 +04:00
blob - > data ,
2008-09-12 17:47:02 +04:00
blob - > length ,
2006-10-23 10:08:25 +04:00
& creds2 ) ;
2003-12-14 13:45:50 +03:00
break ;
case DCERPC_AUTH_LEVEL_INTEGRITY :
2016-08-31 22:43:14 +03:00
case DCERPC_AUTH_LEVEL_PACKET :
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
status = gensec_sign_packet ( dce_conn - > auth_state . gensec_security ,
2004-09-25 15:24:10 +04:00
call ,
2004-06-04 03:15:16 +04:00
ndr - > data + DCERPC_REQUEST_LENGTH ,
2004-09-12 10:04:03 +04:00
payload_length ,
2004-09-11 19:11:36 +04:00
blob - > data ,
2008-09-12 17:47:02 +04:00
blob - > length ,
2006-10-23 10:08:25 +04:00
& creds2 ) ;
2004-09-25 11:25:51 +04:00
break ;
2003-12-14 13:45:50 +03:00
default :
status = NT_STATUS_INVALID_LEVEL ;
break ;
}
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-10-07 02:25:41 +04:00
return false ;
2003-12-14 13:45:50 +03:00
}
2010-02-14 09:09:55 +03:00
if ( creds2 . length ! = sig_size ) {
DEBUG ( 3 , ( " dcesrv_auth_response: creds2.length[%u] != sig_size[%u] pad[%u] stub[%u] \n " ,
( unsigned ) creds2 . length , ( uint32_t ) sig_size ,
2015-06-26 09:10:46 +03:00
( unsigned ) call - > out_auth_info - > auth_pad_length ,
2010-02-14 09:09:55 +03:00
( unsigned ) pkt - > u . response . stub_and_verifier . length ) ) ;
dcerpc_set_frag_length ( blob , blob - > length + creds2 . length ) ;
dcerpc_set_auth_length ( blob , creds2 . length ) ;
}
if ( ! data_blob_append ( call , blob , creds2 . data , creds2 . length ) ) {
status = NT_STATUS_NO_MEMORY ;
2010-02-16 12:21:29 +03:00
return false ;
2010-02-14 09:09:55 +03:00
}
data_blob_free ( & creds2 ) ;
2007-10-07 02:25:41 +04:00
return true ;
2003-12-14 04:09:10 +03:00
}