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 master 2b515b7d Lines: 93 163 57.1 %
Date: 2024-02-28 12: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         629 : static NTSTATUS mgmt__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      11             : {
      12             : #ifdef DCESRV_INTERFACE_MGMT_BIND
      13         629 :         return DCESRV_INTERFACE_MGMT_BIND(context,iface);
      14             : #else
      15             :         return NT_STATUS_OK;
      16             : #endif
      17             : }
      18             : 
      19         629 : 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         629 :         return;
      25             : #endif
      26             : }
      27             : 
      28       38044 : static NTSTATUS mgmt__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      29             : {
      30           0 :         enum ndr_err_code ndr_err;
      31       38044 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      32             : 
      33       38044 :         dce_call->fault_code = 0;
      34             : 
      35       38044 :         if (opnum >= ndr_table_mgmt.num_calls) {
      36          54 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      37          54 :                 return NT_STATUS_NET_WRITE_FAULT;
      38             :         }
      39             : 
      40       75980 :         *r = talloc_named(mem_ctx,
      41       37990 :                           ndr_table_mgmt.calls[opnum].struct_size,
      42             :                           "struct %s",
      43       37990 :                           ndr_table_mgmt.calls[opnum].name);
      44       37990 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      45             : 
      46             :         /* unravel the NDR for the packet */
      47       37990 :         ndr_err = ndr_table_mgmt.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      48       37990 :         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       37990 :         return NT_STATUS_OK;
      54             : }
      55             : 
      56       37990 : static NTSTATUS mgmt__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      57             : {
      58       37990 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      59             : 
      60       37990 :         switch (opnum) {
      61         465 :         case 0: {
      62         465 :                 struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
      63         465 :                 if (DEBUGLEVEL >= 10) {
      64           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_if_ids, NDR_IN, r2);
      65             :                 }
      66         465 :                 r2->out.result = dcesrv_mgmt_inq_if_ids(dce_call, mem_ctx, r2);
      67         465 :                 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         465 :                 break;
      71             :         }
      72         181 :         case 1: {
      73         181 :                 struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
      74         181 :                 if (DEBUGLEVEL >= 10) {
      75           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_stats, NDR_IN, r2);
      76             :                 }
      77         181 :                 r2->out.result = dcesrv_mgmt_inq_stats(dce_call, mem_ctx, r2);
      78         181 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      79           0 :                         DEBUG(5,("function mgmt_inq_stats will reply async\n"));
      80             :                 }
      81         181 :                 break;
      82             :         }
      83         163 :         case 2: {
      84         163 :                 struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
      85         163 :                 if (DEBUGLEVEL >= 10) {
      86           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_is_server_listening, NDR_IN, r2);
      87             :                 }
      88         163 :                 r2->out.result = dcesrv_mgmt_is_server_listening(dce_call, mem_ctx, r2);
      89         163 :                 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         163 :                 break;
      93             :         }
      94         175 :         case 3: {
      95         175 :                 struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
      96         175 :                 if (DEBUGLEVEL >= 10) {
      97           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_stop_server_listening, NDR_IN, r2);
      98             :                 }
      99         175 :                 r2->out.result = dcesrv_mgmt_stop_server_listening(dce_call, mem_ctx, r2);
     100         175 :                 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         175 :                 break;
     104             :         }
     105       37006 :         case 4: {
     106       37006 :                 struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
     107       37006 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_princ_name, NDR_IN, r2);
     109             :                 }
     110       37006 :                 r2->out.result = dcesrv_mgmt_inq_princ_name(dce_call, mem_ctx, r2);
     111       37006 :                 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       37006 :                 break;
     115             :         }
     116             : 
     117           0 :         default:
     118           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     119           0 :                 break;
     120             :         }
     121             : 
     122       37990 :         if (dce_call->fault_code != 0) {
     123         102 :                 return NT_STATUS_NET_WRITE_FAULT;
     124             :         }
     125             : 
     126       37888 :         return NT_STATUS_OK;
     127             : }
     128             : 
     129       37888 : static NTSTATUS mgmt__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     130             : {
     131       37888 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     132             : 
     133       37888 :         switch (opnum) {
     134         465 :         case 0: {
     135         465 :                 struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
     136         465 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     137           0 :                         DEBUG(5,("function mgmt_inq_if_ids replied async\n"));
     138             :                 }
     139         465 :                 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         465 :                 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         465 :                 break;
     146             :         }
     147         181 :         case 1: {
     148         181 :                 struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
     149         181 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     150           0 :                         DEBUG(5,("function mgmt_inq_stats replied async\n"));
     151             :                 }
     152         181 :                 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         181 :                 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         181 :                 break;
     159             :         }
     160         163 :         case 2: {
     161         163 :                 struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
     162         163 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     163           0 :                         DEBUG(5,("function mgmt_is_server_listening replied async\n"));
     164             :                 }
     165         163 :                 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         163 :                 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         163 :                 break;
     172             :         }
     173         175 :         case 3: {
     174         175 :                 struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
     175         175 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     176           0 :                         DEBUG(5,("function mgmt_stop_server_listening replied async\n"));
     177             :                 }
     178         175 :                 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         175 :                 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         175 :                 break;
     185             :         }
     186       36904 :         case 4: {
     187       36904 :                 struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
     188       36904 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     189           0 :                         DEBUG(5,("function mgmt_inq_princ_name replied async\n"));
     190             :                 }
     191       36904 :                 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       36904 :                 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       36904 :                 break;
     198             :         }
     199             : 
     200           0 :         default:
     201           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     202           0 :                 break;
     203             :         }
     204             : 
     205       37888 :         if (dce_call->fault_code != 0) {
     206           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     207             :         }
     208             : 
     209       37888 :         return NT_STATUS_OK;
     210             : }
     211             : 
     212       37888 : 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           0 :         enum ndr_err_code ndr_err;
     215       37888 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     216             : 
     217       37888 :         ndr_err = ndr_table_mgmt.calls[opnum].ndr_push(push, NDR_OUT, r);
     218       37888 :         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       37888 :         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           0 :         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           0 :                 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           0 :         NTSTATUS ret;
     301           0 :         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.14