2003-12-13 02:20:40 +00:00
/*
Unix SMB / CIFS implementation .
endpoint server for the epmapper pipe
Copyright ( C ) Andrew Tridgell 2003
2004-10-24 13:30:50 +00:00
Copyright ( C ) Jelmer Vernooij 2004
2003-12-13 02:20:40 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-12-13 02:20:40 +00: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 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-12-13 02:20:40 +00:00
*/
# include "includes.h"
2004-11-01 10:30:34 +00:00
# include "librpc/gen_ndr/ndr_epmapper.h"
2004-11-02 07:42:47 +00:00
# include "rpc_server/dcerpc_server.h"
2003-12-13 02:20:40 +00:00
2018-11-21 20:06:21 +01:00
# define DCESRV_INTERFACE_EPMAPPER_BIND(context, iface) \
dcesrv_interface_epmapper_bind ( context , iface )
static NTSTATUS dcesrv_interface_epmapper_bind ( struct dcesrv_connection_context * context ,
2016-03-26 19:17:40 +01:00
const struct dcesrv_interface * iface )
{
2018-11-21 20:06:21 +01:00
return dcesrv_interface_bind_allow_connect ( context , iface ) ;
2016-03-26 19:17:40 +01:00
}
2004-08-14 05:53:53 +00:00
typedef uint32_t error_status_t ;
2003-12-13 02:20:40 +00:00
/* handle types for this module */
enum handle_types { HTYPE_LOOKUP } ;
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-08 22:55:27 +00:00
/* a endpoint combined with an interface description */
struct dcesrv_ep_iface {
const char * name ;
2004-12-29 15:36:45 +00:00
struct epm_tower ep ;
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-08 22:55:27 +00:00
} ;
2003-12-13 03:23:41 +00:00
/*
build a list of all interfaces handled by all endpoint servers
*/
2004-05-25 16:24:13 +00:00
static uint32_t build_ep_list ( TALLOC_CTX * mem_ctx ,
2004-09-26 12:50:36 +00:00
struct dcesrv_endpoint * endpoint_list ,
struct dcesrv_ep_iface * * eps )
2003-12-13 03:23:41 +00:00
{
2004-01-09 02:43:23 +00:00
struct dcesrv_endpoint * d ;
2004-05-25 16:24:13 +00:00
uint32_t total = 0 ;
2004-12-29 15:36:45 +00:00
NTSTATUS status ;
2003-12-13 03:23:41 +00:00
2004-09-27 01:36:19 +00:00
* eps = NULL ;
2004-01-09 02:43:23 +00:00
for ( d = endpoint_list ; d ; d = d - > next ) {
struct dcesrv_if_list * iface ;
for ( iface = d - > interface_list ; iface ; iface = iface - > next ) {
2014-02-04 02:33:03 +01:00
struct dcerpc_binding * description ;
2005-01-27 07:08:20 +00:00
( * eps ) = talloc_realloc ( mem_ctx ,
2004-09-27 01:36:19 +00:00
* eps ,
2004-01-09 02:43:23 +00:00
struct dcesrv_ep_iface ,
total + 1 ) ;
if ( ! * eps ) {
return 0 ;
}
2004-12-20 14:37:54 +00:00
( * eps ) [ total ] . name = iface - > iface . name ;
2004-12-29 15:36:45 +00:00
2014-02-04 02:33:03 +01:00
description = dcerpc_binding_dup ( * eps , d - > ep_description ) ;
if ( description = = NULL ) {
return 0 ;
}
2014-02-04 02:33:03 +01:00
status = dcerpc_binding_set_abstract_syntax ( description ,
& iface - > iface . syntax_id ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return 0 ;
}
2004-12-29 15:36:45 +00:00
2009-10-21 15:15:48 +11:00
status = dcerpc_binding_build_tower ( * eps , description , & ( * eps ) [ total ] . ep ) ;
2014-02-04 02:33:03 +01:00
TALLOC_FREE ( description ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 1 , ( " Unable to build tower for %s - %s \n " ,
iface - > iface . name , nt_errstr ( status ) ) ) ;
2004-12-29 15:36:45 +00:00
continue ;
}
2004-01-09 02:43:23 +00:00
total + + ;
}
}
2003-12-13 03:23:41 +00:00
return total ;
}
2007-04-04 14:24:44 +00:00
static error_status_t dcesrv_epm_Insert ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , struct epm_Insert * r )
2003-12-13 02:20:40 +00:00
{
2004-08-14 05:29:16 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2003-12-13 02:20:40 +00:00
}
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_Delete ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 05:53:53 +00:00
struct epm_Delete * r )
2003-12-13 02:20:40 +00:00
{
2004-08-14 05:29:16 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2003-12-13 02:20:40 +00:00
}
/*
implement epm_Lookup . This call is used to enumerate the interfaces
available on a rpc server
*/
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_Lookup ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 05:53:53 +00:00
struct epm_Lookup * r )
2003-12-13 02:20:40 +00:00
{
struct dcesrv_handle * h ;
struct rpc_eps {
2004-05-25 16:24:13 +00:00
uint32_t count ;
2003-12-13 02:20:40 +00:00
struct dcesrv_ep_iface * e ;
} * eps ;
2004-05-25 16:24:13 +00:00
uint32_t num_ents ;
2009-11-21 18:59:30 +01:00
unsigned int i ;
2003-12-13 02:20:40 +00:00
2005-01-10 12:15:26 +00:00
DCESRV_PULL_HANDLE_FAULT ( h , r - > in . entry_handle , HTYPE_LOOKUP ) ;
2003-12-13 02:20:40 +00:00
eps = h - > data ;
if ( ! eps ) {
/* this is the first call - fill the list. Subsequent calls
will feed from this list , stored in the handle */
2005-01-27 07:08:20 +00:00
eps = talloc ( h , struct rpc_eps ) ;
2003-12-13 02:20:40 +00:00
if ( ! eps ) {
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MEMORY ;
2003-12-13 02:20:40 +00:00
}
h - > data = eps ;
2003-12-13 03:23:41 +00:00
2004-09-25 11:24:10 +00:00
eps - > count = build_ep_list ( h , dce_call - > conn - > dce_ctx - > endpoint_list , & eps - > e ) ;
2003-12-13 02:20:40 +00:00
}
/* return the next N elements */
num_ents = r - > in . max_ents ;
if ( num_ents > eps - > count ) {
num_ents = eps - > count ;
}
* r - > out . entry_handle = h - > wire_handle ;
2006-11-22 16:55:21 +00:00
r - > out . num_ents = talloc ( mem_ctx , uint32_t ) ;
* r - > out . num_ents = num_ents ;
2003-12-13 02:20:40 +00:00
if ( num_ents = = 0 ) {
r - > out . entries = NULL ;
2003-12-13 04:46:50 +00:00
ZERO_STRUCTP ( r - > out . entry_handle ) ;
2005-01-10 12:15:26 +00:00
talloc_free ( h ) ;
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MORE_ENTRIES ;
2003-12-13 02:20:40 +00:00
}
2005-01-27 07:08:20 +00:00
r - > out . entries = talloc_array ( mem_ctx , struct epm_entry_t , num_ents ) ;
2003-12-13 02:20:40 +00:00
if ( ! r - > out . entries ) {
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MEMORY ;
2003-12-13 02:20:40 +00:00
}
for ( i = 0 ; i < num_ents ; i + + ) {
ZERO_STRUCT ( r - > out . entries [ i ] . object ) ;
2003-12-13 04:46:50 +00:00
r - > out . entries [ i ] . annotation = eps - > e [ i ] . name ;
2005-01-27 07:08:20 +00:00
r - > out . entries [ i ] . tower = talloc ( mem_ctx , struct epm_twr_t ) ;
2003-12-13 03:23:41 +00:00
if ( ! r - > out . entries [ i ] . tower ) {
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MEMORY ;
2003-12-13 02:20:40 +00:00
}
2004-12-29 15:36:45 +00:00
r - > out . entries [ i ] . tower - > tower = eps - > e [ i ] . ep ;
2003-12-13 02:20:40 +00:00
}
eps - > count - = num_ents ;
eps - > e + = num_ents ;
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_OK ;
2003-12-13 02:20:40 +00:00
}
/*
implement epm_Map . This is used to find the specific endpoint to talk to given
a generic protocol tower
*/
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_Map ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 05:53:53 +00:00
struct epm_Map * r )
2003-12-13 02:20:40 +00:00
{
2004-05-25 16:24:13 +00:00
uint32_t count ;
2009-11-21 18:59:30 +01:00
unsigned int i ;
2003-12-13 03:23:41 +00:00
struct dcesrv_ep_iface * eps ;
struct epm_floor * floors ;
2004-10-24 13:30:50 +00:00
enum dcerpc_transport_t transport ;
2007-08-18 06:57:49 +00:00
struct ndr_syntax_id ndr_syntax ;
2003-12-13 03:23:41 +00: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-08 22:55:27 +00:00
count = build_ep_list ( mem_ctx , dce_call - > conn - > dce_ctx - > endpoint_list , & eps ) ;
2003-12-13 03:23:41 +00:00
2004-06-03 23:15:16 +00:00
ZERO_STRUCT ( * r - > out . entry_handle ) ;
2006-11-22 16:55:21 +00:00
r - > out . num_towers = talloc ( mem_ctx , uint32_t ) ;
2009-01-06 23:25:41 +01:00
if ( ! r - > out . num_towers ) {
return EPMAPPER_STATUS_NO_MEMORY ;
}
2006-11-22 16:55:21 +00:00
* r - > out . num_towers = 1 ;
2005-01-27 07:08:20 +00:00
r - > out . towers = talloc ( mem_ctx , struct epm_twr_p_t ) ;
2003-12-13 03:23:41 +00:00
if ( ! r - > out . towers ) {
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MEMORY ;
2003-12-13 03:23:41 +00:00
}
2005-01-27 07:08:20 +00:00
r - > out . towers - > twr = talloc ( mem_ctx , struct epm_twr_t ) ;
2003-12-13 03:23:41 +00:00
if ( ! r - > out . towers - > twr ) {
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MEMORY ;
2003-12-13 03:23:41 +00:00
}
2004-10-24 13:30:50 +00:00
if ( ! r - > in . map_tower | | r - > in . max_towers = = 0 | |
r - > in . map_tower - > tower . num_floors < 3 ) {
2003-12-13 03:23:41 +00:00
goto failed ;
}
2004-10-21 10:52:03 +00:00
floors = r - > in . map_tower - > tower . floors ;
2003-12-13 03:23:41 +00:00
2006-03-26 00:59:17 +00:00
dcerpc_floor_get_lhs_data ( & r - > in . map_tower - > tower . floors [ 1 ] , & ndr_syntax ) ;
2005-02-04 01:32:19 +00:00
2004-12-29 15:36:45 +00:00
if ( floors [ 1 ] . lhs . protocol ! = EPM_PROTOCOL_UUID | |
2012-03-18 16:46:57 +01:00
! GUID_equal ( & ndr_syntax . uuid , & ndr_transfer_syntax_ndr . uuid ) | |
ndr_syntax . if_version ! = ndr_transfer_syntax_ndr . if_version ) {
2004-10-24 13:30:50 +00:00
goto failed ;
}
transport = dcerpc_transport_by_tower ( & r - > in . map_tower - > tower ) ;
if ( transport = = - 1 ) {
2005-01-30 00:54:57 +00:00
DEBUG ( 2 , ( " Client requested unknown transport with levels: " ) ) ;
2004-10-24 13:30:50 +00:00
for ( i = 2 ; i < r - > in . map_tower - > tower . num_floors ; i + + ) {
2005-01-30 00:54:57 +00:00
DEBUG ( 2 , ( " %d, " , r - > in . map_tower - > tower . floors [ i ] . lhs . protocol ) ) ;
2004-10-24 13:30:50 +00:00
}
2005-01-30 00:54:57 +00:00
DEBUG ( 2 , ( " \n " ) ) ;
2003-12-13 03:23:41 +00:00
goto failed ;
}
2004-10-24 13:30:50 +00:00
2004-12-29 15:36:45 +00:00
for ( i = 0 ; i < count ; i + + ) {
2005-02-04 01:32:19 +00:00
if (
2007-06-20 04:15:39 +00:00
data_blob_cmp ( & r - > in . map_tower - > tower . floors [ 0 ] . lhs . lhs_data ,
& eps [ i ] . ep . floors [ 0 ] . lhs . lhs_data ) ! = 0
2005-02-04 01:32:19 +00:00
| | transport ! = dcerpc_transport_by_tower ( & eps [ i ] . ep ) ) {
2004-10-24 13:30:50 +00:00
continue ;
}
2004-12-29 15:36:45 +00:00
r - > out . towers - > twr - > tower = eps [ i ] . ep ;
2004-06-06 10:49:26 +00:00
r - > out . towers - > twr - > tower_length = 0 ;
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_OK ;
2003-12-13 03:23:41 +00:00
}
failed :
2006-11-22 16:55:21 +00:00
* r - > out . num_towers = 0 ;
2003-12-13 03:23:41 +00:00
r - > out . towers - > twr = NULL ;
2004-08-14 05:53:53 +00:00
return EPMAPPER_STATUS_NO_MORE_ENTRIES ;
2003-12-13 02:20:40 +00:00
}
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_LookupHandleFree ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 05:53:53 +00:00
struct epm_LookupHandleFree * r )
2003-12-13 02:20:40 +00:00
{
2004-08-14 05:29:16 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2003-12-13 02:20:40 +00:00
}
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_InqObject ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 05:53:53 +00:00
struct epm_InqObject * r )
2003-12-13 02:20:40 +00:00
{
2004-08-14 05:29:16 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2003-12-13 02:20:40 +00:00
}
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_MgmtDelete ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2003-12-13 03:23:41 +00:00
struct epm_MgmtDelete * r )
2003-12-13 02:20:40 +00:00
{
2004-08-14 05:29:16 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2003-12-13 02:20:40 +00:00
}
2007-01-17 14:49:36 +00:00
static error_status_t dcesrv_epm_MapAuth ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-08-14 01:11:34 +00:00
struct epm_MapAuth * r )
{
2004-08-14 05:53:53 +00:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-08-14 01:11:34 +00:00
}
2003-12-13 02:20:40 +00:00
2003-12-14 13:22:12 +00:00
/* include the generated boilerplate */
# include "librpc/gen_ndr/ndr_epmapper_s.c"