2019-10-03 20:38:31 +03:00
/*
2007-01-15 03:42:16 +03:00
Unix SMB / CIFS implementation .
endpoint server for the mgmt pipe
Copyright ( C ) Jelmer Vernooij 2006
2019-10-03 20:38:31 +03:00
2007-01-15 03:42:16 +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
2007-01-15 03:42:16 +03:00
( at your option ) any later version .
2019-10-03 20:38:31 +03:00
2007-01-15 03:42:16 +03:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2019-10-03 20:38:31 +03:00
2007-01-15 03:42:16 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2007-01-15 03:42:16 +03:00
*/
# include "includes.h"
2019-10-03 20:38:31 +03:00
# include "librpc/rpc/dcesrv_core.h"
# include "librpc/rpc/dcesrv_core_proto.h"
2007-01-15 03:42:16 +03:00
# include "librpc/gen_ndr/ndr_mgmt.h"
2018-11-21 22:06:21 +03:00
# define DCESRV_INTERFACE_MGMT_BIND(context, iface) \
dcesrv_interface_mgmt_bind ( context , iface )
2016-11-14 01:24:03 +03:00
/*
* This # define allows the mgmt interface to accept invalid
* association groups , because association groups are to coordinate
* handles , and handles are not used in mgmt . This in turn avoids
* the need to coordinate these across multiple possible NETLOGON
* processes , as an mgmt interface is added to each
*/
# define DCESRV_INTERFACE_MGMT_FLAGS DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED
2018-11-21 22:06:21 +03:00
static NTSTATUS dcesrv_interface_mgmt_bind ( struct dcesrv_connection_context * context ,
2016-03-26 21:18:42 +03:00
const struct dcesrv_interface * iface )
{
2018-11-21 22:06:21 +03:00
return dcesrv_interface_bind_allow_connect ( context , iface ) ;
2016-03-26 21:18:42 +03:00
}
2019-10-03 20:38:31 +03:00
/*
mgmt_inq_if_ids
2007-01-15 03:42:16 +03:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_mgmt_inq_if_ids ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2007-01-15 03:42:16 +03:00
struct mgmt_inq_if_ids * r )
{
2007-01-16 17:44:23 +03:00
const struct dcesrv_endpoint * ep = dce_call - > conn - > endpoint ;
2023-08-09 13:42:43 +03:00
struct dcesrv_if_list * l = NULL ;
struct rpc_if_id_vector_t * vector = NULL ;
vector = talloc ( mem_ctx , struct rpc_if_id_vector_t ) ;
if ( vector = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2007-01-16 17:44:23 +03:00
vector - > count = 0 ;
vector - > if_id = NULL ;
2023-08-09 13:42:43 +03:00
2007-01-16 17:44:23 +03:00
for ( l = ep - > interface_list ; l ; l = l - > next ) {
2023-08-09 18:05:56 +03:00
bool filter ;
filter = ndr_syntax_id_equal ( & l - > iface - > syntax_id , & ndr_table_mgmt . syntax_id ) ;
if ( filter ) {
/*
* We should not return the mgmt syntax itself here
*/
continue ;
}
2007-01-16 17:44:23 +03:00
vector - > count + + ;
2023-08-09 13:42:43 +03:00
vector - > if_id = talloc_realloc ( vector , vector - > if_id , struct ndr_syntax_id_p , vector - > count ) ;
if ( vector - > if_id = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2019-10-01 17:48:01 +03:00
vector - > if_id [ vector - > count - 1 ] . id = & l - > iface - > syntax_id ;
2007-01-16 17:44:23 +03:00
}
2023-08-09 13:42:43 +03:00
* r - > out . if_id_vector = vector ;
2007-01-16 17:44:23 +03:00
return WERR_OK ;
2007-01-15 03:42:16 +03:00
}
2019-10-03 20:38:31 +03:00
/*
mgmt_inq_stats
2007-01-15 03:42:16 +03:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_mgmt_inq_stats ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2007-01-15 03:42:16 +03:00
struct mgmt_inq_stats * r )
{
2007-01-16 17:44:23 +03:00
if ( r - > in . max_count ! = MGMT_STATS_ARRAY_MAX_SIZE )
return WERR_NOT_SUPPORTED ;
2023-08-09 13:42:43 +03:00
r - > out . statistics - > statistics = talloc_zero_array ( mem_ctx ,
uint32_t ,
r - > in . max_count ) ;
if ( r - > out . statistics - > statistics = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2007-01-16 17:44:23 +03:00
r - > out . statistics - > count = r - > in . max_count ;
/* FIXME */
r - > out . statistics - > statistics [ MGMT_STATS_CALLS_IN ] = 0 ;
r - > out . statistics - > statistics [ MGMT_STATS_CALLS_OUT ] = 0 ;
r - > out . statistics - > statistics [ MGMT_STATS_PKTS_IN ] = 0 ;
r - > out . statistics - > statistics [ MGMT_STATS_PKTS_OUT ] = 0 ;
return WERR_OK ;
2007-01-15 03:42:16 +03:00
}
2019-10-03 20:38:31 +03:00
/*
mgmt_is_server_listening
2007-01-15 03:42:16 +03:00
*/
2007-01-17 17:49:36 +03:00
static uint32_t dcesrv_mgmt_is_server_listening ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2007-01-15 03:42:16 +03:00
struct mgmt_is_server_listening * r )
{
2007-01-16 17:44:23 +03:00
* r - > out . status = 0 ;
return 1 ;
2007-01-15 03:42:16 +03:00
}
2019-10-03 20:38:31 +03:00
/*
mgmt_stop_server_listening
2007-01-15 03:42:16 +03:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_mgmt_stop_server_listening ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2007-01-15 03:42:16 +03:00
struct mgmt_stop_server_listening * r )
{
2007-01-16 17:44:23 +03:00
return WERR_ACCESS_DENIED ;
2007-01-15 03:42:16 +03:00
}
2019-10-03 20:38:31 +03:00
/*
mgmt_inq_princ_name
2007-01-15 03:42:16 +03:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_mgmt_inq_princ_name ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2007-01-15 03:42:16 +03:00
struct mgmt_inq_princ_name * r )
{
2023-08-09 14:26:31 +03:00
const char * principal = NULL ;
if ( r - > in . princ_name_size < 1 ) {
DCESRV_FAULT ( DCERPC_FAULT_BAD_STUB_DATA ) ;
}
r - > out . princ_name = " " ;
principal = dcesrv_auth_type_principal_find ( dce_call - > conn - > dce_ctx ,
r - > in . authn_proto ) ;
if ( principal = = NULL ) {
return WERR_RPC_S_UNKNOWN_AUTHN_SERVICE ;
}
if ( strlen ( principal ) + 1 > r - > in . princ_name_size ) {
return WERR_INSUFFICIENT_BUFFER ;
}
r - > out . princ_name = principal ;
return WERR_OK ;
2007-01-15 03:42:16 +03:00
}
/* include the generated boilerplate */
# include "librpc/gen_ndr/ndr_mgmt_s.c"
2016-11-21 01:31:27 +03:00
2019-10-01 17:48:01 +03:00
const struct dcesrv_interface * dcesrv_get_mgmt_interface ( void )
2016-11-21 01:31:27 +03:00
{
2019-10-01 17:48:01 +03:00
return & dcesrv_mgmt_interface ;
2016-11-21 01:31:27 +03:00
}