LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_mgmt_s.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 87 157 55.4 %
Date: 2021-09-23 10:06:22 Functions: 6 11 54.5 %

          Line data    Source code
       1             : /* server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_mgmt.h"
       3             : #include <util/debug.h>
       4             : 
       5             : NTSTATUS dcerpc_server_mgmt_init(TALLOC_CTX *);
       6             : 
       7             : /* mgmt - dcerpc server boilerplate generated by pidl */
       8             : 
       9             : 
      10         182 : static NTSTATUS mgmt__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      11             : {
      12             : #ifdef DCESRV_INTERFACE_MGMT_BIND
      13         182 :         return DCESRV_INTERFACE_MGMT_BIND(context,iface);
      14             : #else
      15             :         return NT_STATUS_OK;
      16             : #endif
      17             : }
      18             : 
      19         182 : static void mgmt__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      20             : {
      21             : #ifdef DCESRV_INTERFACE_MGMT_UNBIND
      22             :         DCESRV_INTERFACE_MGMT_UNBIND(context, iface);
      23             : #else
      24         182 :         return;
      25             : #endif
      26             : }
      27             : 
      28       14981 : static NTSTATUS mgmt__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      29             : {
      30             :         enum ndr_err_code ndr_err;
      31       14981 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      32             : 
      33       14981 :         dce_call->fault_code = 0;
      34             : 
      35       14981 :         if (opnum >= ndr_table_mgmt.num_calls) {
      36          18 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      37          18 :                 return NT_STATUS_NET_WRITE_FAULT;
      38             :         }
      39             : 
      40       29926 :         *r = talloc_named(mem_ctx,
      41       14963 :                           ndr_table_mgmt.calls[opnum].struct_size,
      42             :                           "struct %s",
      43       14963 :                           ndr_table_mgmt.calls[opnum].name);
      44       14963 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      45             : 
      46             :         /* unravel the NDR for the packet */
      47       14963 :         ndr_err = ndr_table_mgmt.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      48       14963 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      49           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
      50           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      51             :         }
      52             : 
      53       14963 :         return NT_STATUS_OK;
      54             : }
      55             : 
      56       14963 : static NTSTATUS mgmt__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      57             : {
      58       14963 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      59             : 
      60       14963 :         switch (opnum) {
      61         166 :         case 0: {
      62         166 :                 struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
      63         166 :                 if (DEBUGLEVEL >= 10) {
      64           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_if_ids, NDR_IN, r2);
      65             :                 }
      66         166 :                 r2->out.result = dcesrv_mgmt_inq_if_ids(dce_call, mem_ctx, r2);
      67         166 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      68           0 :                         DEBUG(5,("function mgmt_inq_if_ids will reply async\n"));
      69             :                 }
      70         166 :                 break;
      71             :         }
      72          71 :         case 1: {
      73          71 :                 struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
      74          71 :                 if (DEBUGLEVEL >= 10) {
      75           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_stats, NDR_IN, r2);
      76             :                 }
      77          71 :                 r2->out.result = dcesrv_mgmt_inq_stats(dce_call, mem_ctx, r2);
      78          71 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      79           0 :                         DEBUG(5,("function mgmt_inq_stats will reply async\n"));
      80             :                 }
      81          71 :                 break;
      82             :         }
      83          65 :         case 2: {
      84          65 :                 struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
      85          65 :                 if (DEBUGLEVEL >= 10) {
      86           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_is_server_listening, NDR_IN, r2);
      87             :                 }
      88          65 :                 r2->out.result = dcesrv_mgmt_is_server_listening(dce_call, mem_ctx, r2);
      89          65 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      90           0 :                         DEBUG(5,("function mgmt_is_server_listening will reply async\n"));
      91             :                 }
      92          65 :                 break;
      93             :         }
      94          69 :         case 3: {
      95          69 :                 struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
      96          69 :                 if (DEBUGLEVEL >= 10) {
      97           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_stop_server_listening, NDR_IN, r2);
      98             :                 }
      99          69 :                 r2->out.result = dcesrv_mgmt_stop_server_listening(dce_call, mem_ctx, r2);
     100          69 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     101           0 :                         DEBUG(5,("function mgmt_stop_server_listening will reply async\n"));
     102             :                 }
     103          69 :                 break;
     104             :         }
     105       14592 :         case 4: {
     106       14592 :                 struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
     107       14592 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_princ_name, NDR_IN, r2);
     109             :                 }
     110       14592 :                 r2->out.result = dcesrv_mgmt_inq_princ_name(dce_call, mem_ctx, r2);
     111       14592 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     112           0 :                         DEBUG(5,("function mgmt_inq_princ_name will reply async\n"));
     113             :                 }
     114       14592 :                 break;
     115             :         }
     116             : 
     117           0 :         default:
     118           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     119           0 :                 break;
     120             :         }
     121             : 
     122       14963 :         if (dce_call->fault_code != 0) {
     123       14592 :                 return NT_STATUS_NET_WRITE_FAULT;
     124             :         }
     125             : 
     126         371 :         return NT_STATUS_OK;
     127             : }
     128             : 
     129         371 : static NTSTATUS mgmt__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     130             : {
     131         371 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     132             : 
     133         371 :         switch (opnum) {
     134         166 :         case 0: {
     135         166 :                 struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
     136         166 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     137           0 :                         DEBUG(5,("function mgmt_inq_if_ids replied async\n"));
     138             :                 }
     139         166 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     140           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_if_ids, NDR_OUT | NDR_SET_VALUES, r2);
     141             :                 }
     142         166 :                 if (dce_call->fault_code != 0) {
     143           0 :                         DEBUG(2,("dcerpc_fault %s in mgmt_inq_if_ids\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     144             :                 }
     145         166 :                 break;
     146             :         }
     147          71 :         case 1: {
     148          71 :                 struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
     149          71 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     150           0 :                         DEBUG(5,("function mgmt_inq_stats replied async\n"));
     151             :                 }
     152          71 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     153           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_stats, NDR_OUT | NDR_SET_VALUES, r2);
     154             :                 }
     155          71 :                 if (dce_call->fault_code != 0) {
     156           0 :                         DEBUG(2,("dcerpc_fault %s in mgmt_inq_stats\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     157             :                 }
     158          71 :                 break;
     159             :         }
     160          65 :         case 2: {
     161          65 :                 struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
     162          65 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     163           0 :                         DEBUG(5,("function mgmt_is_server_listening replied async\n"));
     164             :                 }
     165          65 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     166           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_is_server_listening, NDR_OUT | NDR_SET_VALUES, r2);
     167             :                 }
     168          65 :                 if (dce_call->fault_code != 0) {
     169           0 :                         DEBUG(2,("dcerpc_fault %s in mgmt_is_server_listening\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     170             :                 }
     171          65 :                 break;
     172             :         }
     173          69 :         case 3: {
     174          69 :                 struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
     175          69 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     176           0 :                         DEBUG(5,("function mgmt_stop_server_listening replied async\n"));
     177             :                 }
     178          69 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     179           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_stop_server_listening, NDR_OUT | NDR_SET_VALUES, r2);
     180             :                 }
     181          69 :                 if (dce_call->fault_code != 0) {
     182           0 :                         DEBUG(2,("dcerpc_fault %s in mgmt_stop_server_listening\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     183             :                 }
     184          69 :                 break;
     185             :         }
     186           0 :         case 4: {
     187           0 :                 struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
     188           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     189           0 :                         DEBUG(5,("function mgmt_inq_princ_name replied async\n"));
     190             :                 }
     191           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     192           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_princ_name, NDR_OUT | NDR_SET_VALUES, r2);
     193             :                 }
     194           0 :                 if (dce_call->fault_code != 0) {
     195           0 :                         DEBUG(2,("dcerpc_fault %s in mgmt_inq_princ_name\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     196             :                 }
     197           0 :                 break;
     198             :         }
     199             : 
     200           0 :         default:
     201           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     202           0 :                 break;
     203             :         }
     204             : 
     205         371 :         if (dce_call->fault_code != 0) {
     206           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     207             :         }
     208             : 
     209         371 :         return NT_STATUS_OK;
     210             : }
     211             : 
     212         371 : static NTSTATUS mgmt__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     213             : {
     214             :         enum ndr_err_code ndr_err;
     215         371 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     216             : 
     217         371 :         ndr_err = ndr_table_mgmt.calls[opnum].ndr_push(push, NDR_OUT, r);
     218         371 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     219           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     220           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     221             :         }
     222             : 
     223         371 :         return NT_STATUS_OK;
     224             : }
     225             : 
     226             : static const struct dcesrv_interface dcesrv_mgmt_interface = {
     227             :         .name               = "mgmt",
     228             :         .syntax_id          = {{0xafa8bd80,0x7d8a,0x11c9,{0xbe,0xf4},{0x08,0x00,0x2b,0x10,0x29,0x89}},1.0},
     229             :         .bind               = mgmt__op_bind,
     230             :         .unbind             = mgmt__op_unbind,
     231             :         .ndr_pull           = mgmt__op_ndr_pull,
     232             :         .dispatch           = mgmt__op_dispatch,
     233             :         .reply              = mgmt__op_reply,
     234             :         .ndr_push           = mgmt__op_ndr_push,
     235             :         .local              = NULL,
     236             : #ifdef DCESRV_INTERFACE_MGMT_FLAGS
     237             :         .flags              = DCESRV_INTERFACE_MGMT_FLAGS
     238             : #else
     239             :         .flags              = 0
     240             : #endif
     241             : };
     242             : 
     243             : 
     244           0 : static NTSTATUS mgmt__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     245             : {
     246             :         int i;
     247             : #ifdef DCESRV_INTERFACE_MGMT_NCACN_NP_SECONDARY_ENDPOINT
     248             :         const char *ncacn_np_secondary_endpoint =
     249             :                 DCESRV_INTERFACE_MGMT_NCACN_NP_SECONDARY_ENDPOINT;
     250             : #else
     251           0 :         const char *ncacn_np_secondary_endpoint = NULL;
     252             : #endif
     253             : 
     254           0 :         for (i=0;i<ndr_table_mgmt.endpoints->count;i++) {
     255             :                 NTSTATUS ret;
     256           0 :                 const char *name = ndr_table_mgmt.endpoints->names[i];
     257             : 
     258           0 :                 ret = dcesrv_interface_register(dce_ctx,
     259             :                                                 name,
     260             :                                                 ncacn_np_secondary_endpoint,
     261             :                                                 &dcesrv_mgmt_interface,
     262             :                                                 NULL);
     263           0 :                 if (!NT_STATUS_IS_OK(ret)) {
     264           0 :                         DEBUG(1,("mgmt_op_init_server: failed to register endpoint '%s'\n",name));
     265           0 :                         return ret;
     266             :                 }
     267             :         }
     268             : 
     269           0 :         return NT_STATUS_OK;
     270             : }
     271             : 
     272           0 : static NTSTATUS mgmt__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     273             : {
     274           0 :         return NT_STATUS_OK;
     275             : }
     276             : 
     277           0 : static bool mgmt__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     278             : {
     279           0 :         if (dcesrv_mgmt_interface.syntax_id.if_version == if_version &&
     280           0 :                 GUID_equal(&dcesrv_mgmt_interface.syntax_id.uuid, uuid)) {
     281           0 :                 memcpy(iface,&dcesrv_mgmt_interface, sizeof(*iface));
     282           0 :                 return true;
     283             :         }
     284             : 
     285           0 :         return false;
     286             : }
     287             : 
     288           0 : static bool mgmt__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     289             : {
     290           0 :         if (strcmp(dcesrv_mgmt_interface.name, name)==0) {
     291           0 :                 memcpy(iface, &dcesrv_mgmt_interface, sizeof(*iface));
     292           0 :                 return true;
     293             :         }
     294             : 
     295           0 :         return false;
     296             : }
     297             : 
     298           0 : NTSTATUS dcerpc_server_mgmt_init(TALLOC_CTX *ctx)
     299             : {
     300             :         NTSTATUS ret;
     301             :         static const struct dcesrv_endpoint_server ep_server = {
     302             :             /* fill in our name */
     303             :             .name = "mgmt",
     304             : 
     305             :             /* Initialization flag */
     306             :             .initialized = false,
     307             : 
     308             :             /* fill in all the operations */
     309             : #ifdef DCESRV_INTERFACE_MGMT_INIT_SERVER
     310             :             .init_server = DCESRV_INTERFACE_MGMT_INIT_SERVER,
     311             : #else
     312             :             .init_server = mgmt__op_init_server,
     313             : #endif
     314             : #ifdef DCESRV_INTERFACE_MGMT_SHUTDOWN_SERVER
     315             :             .shutdown_server = DCESRV_INTERFACE_MGMT_SHUTDOWN_SERVER,
     316             : #else
     317             :             .shutdown_server = mgmt__op_shutdown_server,
     318             : #endif
     319             :             .interface_by_uuid = mgmt__op_interface_by_uuid,
     320             :             .interface_by_name = mgmt__op_interface_by_name
     321             :         };
     322             :         /* register ourselves with the DCERPC subsystem. */
     323           0 :         ret = dcerpc_register_ep_server(&ep_server);
     324             : 
     325           0 :         if (!NT_STATUS_IS_OK(ret)) {
     326           0 :                 DEBUG(0,("Failed to register 'mgmt' endpoint server!\n"));
     327           0 :                 return ret;
     328             :         }
     329             : 
     330           0 :         return ret;
     331             : }
     332             : 

Generated by: LCOV version 1.13