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 ) {
2017-03-03 01:49:43 +03:00
enum dcerpc_transport_t transport =
dcerpc_binding_get_transport ( call - > conn - > endpoint - > ep_description ) ;
const char * auth_type = derpc_transport_string_by_transport ( transport ) ;
2017-03-06 04:10:17 +03:00
const char * transport_protection = AUTHZ_TRANSPORT_PROTECTION_NONE ;
if ( transport = = NCACN_NP ) {
transport_protection = AUTHZ_TRANSPORT_PROTECTION_SMB ;
}
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 ;
2017-03-03 01:49:43 +03:00
/*
* Log the authorization to this RPC interface . This
* covered ncacn_np pass - through auth , and anonymous
* DCE / RPC ( eg epmapper , netlogon etc )
*/
log_successful_authz_event ( call - > conn - > remote_address ,
call - > conn - > local_address ,
" DCE/RPC " ,
auth_type ,
2017-03-06 04:10:17 +03:00
transport_protection ,
2017-03-03 01:49:43 +03:00
call - > conn - > auth_state . session_info ) ;
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 ;
}
2017-02-20 03:32:47 +03:00
/*
* We have to call this because we set the target_service for
* Kerberos to NULL above , and in any case we wish to log a
* more specific service target .
*
*/
status = gensec_set_target_service_description ( auth - > gensec_security ,
" DCE/RPC " ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to call gensec_set_target_service_description %s \n " ,
nt_errstr ( status ) ) ) ;
return false ;
}
2015-01-22 16:05:15 +03:00
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
2017-02-24 03:29:12 +03:00
if ( call - > conn - > local_address ! = NULL ) {
status = gensec_set_local_address ( auth - > gensec_security ,
call - > conn - > local_address ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Failed to call gensec_set_local_address() %s \n " ,
nt_errstr ( status ) ) ) ;
return false ;
}
}
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
*/
2015-10-23 17:06:17 +03:00
bool dcesrv_auth_pkt_push ( struct dcesrv_call_state * call ,
2008-08-11 20:12:54 +04:00
DATA_BLOB * blob , size_t sig_size ,
2015-10-23 17:06:17 +03:00
uint8_t payload_offset ,
const DATA_BLOB * payload ,
2015-10-23 17:06:17 +03:00
const 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 ;
2015-10-23 17:06:17 +03:00
const struct dcerpc_auth tmp_auth = {
2015-06-26 09:10:46 +03:00
. 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 ,
} ;
2015-10-23 17:06:17 +03:00
NTSTATUS status ;
2010-02-14 09:09:55 +03:00
2015-10-23 17:06:17 +03:00
status = dcerpc_ncacn_push_pkt_auth ( & tmp_auth ,
dce_conn - > auth_state . gensec_security ,
call , blob , sig_size ,
2015-10-23 17:06:17 +03:00
payload_offset ,
payload ,
2015-10-23 17:06:17 +03:00
pkt ) ;
return NT_STATUS_IS_OK ( status ) ;
2003-12-14 04:09:10 +03:00
}