LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_initshutdown_scompat.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 15 138 10.9 %
Date: 2024-04-21 15:09:00 Functions: 5 13 38.5 %

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_initshutdown.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_initshutdown_scompat.h"
       4             : #include <librpc/rpc/dcesrv_core.h>
       5             : #include <rpc_server/rpc_config.h>
       6             : #include <rpc_server/rpc_server.h>
       7             : #include <util/debug.h>
       8             : 
       9             : enum s3compat_rpc_dispatch {
      10             :         S3COMPAT_RPC_DISPATCH_EXTERNAL = 0x00000001,
      11             :         S3COMPAT_RPC_DISPATCH_INTERNAL = 0x00000002,
      12             : };
      13             : 
      14             : /* initshutdown - dcerpc server boilerplate generated by pidl */
      15           4 : static NTSTATUS initshutdown__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      16             : {
      17             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_BIND
      18             :         return DCESRV_INTERFACE_INITSHUTDOWN_BIND(context,iface);
      19             : #else
      20           4 :         return NT_STATUS_OK;
      21             : #endif
      22             : }
      23             : 
      24           4 : static void initshutdown__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      25             : {
      26             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_UNBIND
      27             :         DCESRV_INTERFACE_INITSHUTDOWN_UNBIND(context, iface);
      28             : #else
      29           4 :         return;
      30             : #endif
      31             : }
      32             : 
      33           0 : NTSTATUS initshutdown__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      34             : {
      35           0 :         enum ndr_err_code ndr_err;
      36           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      37             : 
      38           0 :         dce_call->fault_code = 0;
      39             : 
      40           0 :         if (opnum >= ndr_table_initshutdown.num_calls) {
      41           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      42           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      43             :         }
      44             : 
      45           0 :         *r = talloc_named(mem_ctx, ndr_table_initshutdown.calls[opnum].struct_size, "struct %s", ndr_table_initshutdown.calls[opnum].name);
      46           0 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      47             : 
      48             :         /* unravel the NDR for the packet */
      49           0 :         ndr_err = ndr_table_initshutdown.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      50           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      51           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
      52           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      53             :         }
      54             : 
      55           0 :         return NT_STATUS_OK;
      56             : }
      57             : 
      58           0 : static NTSTATUS initshutdown__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
      59             : {
      60           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      61           0 :         struct pipes_struct *p = NULL;
      62           0 :         NTSTATUS status = NT_STATUS_OK;
      63           0 :         bool impersonated = false;
      64             : 
      65             :         /* Retrieve pipes struct */
      66           0 :         p = dcesrv_get_pipes_struct(dce_call->conn);
      67           0 :         p->dce_call = dce_call;
      68           0 :         p->mem_ctx = mem_ctx;
      69             :         /* Reset pipes struct fault state */
      70           0 :         p->fault_state = 0;
      71             : 
      72             :         /* Impersonate */
      73           0 :         if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
      74           0 :                 impersonated = become_authenticated_pipe_user(dce_call->auth_state->session_info);
      75           0 :                 if (!impersonated) {
      76           0 :                         dce_call->fault_code = DCERPC_FAULT_ACCESS_DENIED;
      77           0 :                         status = NT_STATUS_NET_WRITE_FAULT;
      78           0 :                         goto fail;
      79             :                 }
      80             :         }
      81             : 
      82           0 :         switch (opnum) {
      83           0 :         case 0: { /* initshutdown_Init */
      84           0 :                 struct initshutdown_Init *r2 = (struct initshutdown_Init *)r;
      85           0 :                 if (DEBUGLEVEL >= 10) {
      86           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_Init, NDR_IN, r2);
      87             :                 }
      88           0 :                 r2->out.result = _initshutdown_Init(p, r2);
      89           0 :                 break;
      90             :         }
      91           0 :         case 1: { /* initshutdown_Abort */
      92           0 :                 struct initshutdown_Abort *r2 = (struct initshutdown_Abort *)r;
      93           0 :                 if (DEBUGLEVEL >= 10) {
      94           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_Abort, NDR_IN, r2);
      95             :                 }
      96           0 :                 r2->out.result = _initshutdown_Abort(p, r2);
      97           0 :                 break;
      98             :         }
      99           0 :         case 2: { /* initshutdown_InitEx */
     100           0 :                 struct initshutdown_InitEx *r2 = (struct initshutdown_InitEx *)r;
     101           0 :                 if (DEBUGLEVEL >= 10) {
     102           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_InitEx, NDR_IN, r2);
     103             :                 }
     104           0 :                 r2->out.result = _initshutdown_InitEx(p, r2);
     105           0 :                 break;
     106             :         }
     107           0 :         default:
     108           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     109           0 :                 break;
     110             :         }
     111             : 
     112           0 : fail:
     113             :         /* Unimpersonate */
     114           0 :         if (impersonated) {
     115           0 :                 unbecome_authenticated_pipe_user();
     116             :         }
     117             : 
     118           0 :         p->dce_call = NULL;
     119           0 :         p->mem_ctx = NULL;
     120             :         /* Check pipes struct fault state */
     121           0 :         if (p->fault_state != 0) {
     122           0 :                 dce_call->fault_code = p->fault_state;
     123             :         }
     124           0 :         if (dce_call->fault_code != 0) {
     125           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     126             :         }
     127             : 
     128           0 :         return status;
     129             : }
     130             : 
     131           0 : NTSTATUS initshutdown__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     132             : {
     133           0 :         return initshutdown__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     134             : }
     135             : 
     136           0 : NTSTATUS initshutdown__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     137             : {
     138           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     139             : 
     140           0 :         switch (opnum) {
     141           0 :         case 0: { /* initshutdown_Init */
     142           0 :                 struct initshutdown_Init *r2 = (struct initshutdown_Init *)r;
     143           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     144           0 :                         DEBUG(5,("function initshutdown_Init replied async\n"));
     145             :                 }
     146           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     147           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_Init, NDR_OUT | NDR_SET_VALUES, r2);
     148             :                 }
     149           0 :                 if (dce_call->fault_code != 0) {
     150           0 :                         DBG_WARNING("dcerpc_fault %s in initshutdown_Init\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     151             :                 }
     152           0 :                 break;
     153             :         }
     154           0 :         case 1: { /* initshutdown_Abort */
     155           0 :                 struct initshutdown_Abort *r2 = (struct initshutdown_Abort *)r;
     156           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     157           0 :                         DEBUG(5,("function initshutdown_Abort replied async\n"));
     158             :                 }
     159           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     160           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_Abort, NDR_OUT | NDR_SET_VALUES, r2);
     161             :                 }
     162           0 :                 if (dce_call->fault_code != 0) {
     163           0 :                         DBG_WARNING("dcerpc_fault %s in initshutdown_Abort\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     164             :                 }
     165           0 :                 break;
     166             :         }
     167           0 :         case 2: { /* initshutdown_InitEx */
     168           0 :                 struct initshutdown_InitEx *r2 = (struct initshutdown_InitEx *)r;
     169           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     170           0 :                         DEBUG(5,("function initshutdown_InitEx replied async\n"));
     171             :                 }
     172           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     173           0 :                         NDR_PRINT_FUNCTION_DEBUG(initshutdown_InitEx, NDR_OUT | NDR_SET_VALUES, r2);
     174             :                 }
     175           0 :                 if (dce_call->fault_code != 0) {
     176           0 :                         DBG_WARNING("dcerpc_fault %s in initshutdown_InitEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     177             :                 }
     178           0 :                 break;
     179             :         }
     180           0 :         default:
     181           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     182           0 :                 break;
     183             :         }
     184             : 
     185           0 :         if (dce_call->fault_code != 0) {
     186           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     187             :         }
     188             : 
     189           0 :         return NT_STATUS_OK;
     190             : }
     191             : 
     192           0 : NTSTATUS initshutdown__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     193             : {
     194           0 :         enum ndr_err_code ndr_err;
     195           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     196             : 
     197           0 :         ndr_err = ndr_table_initshutdown.calls[opnum].ndr_push(push, NDR_OUT, r);
     198           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     199           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     200           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     201             :         }
     202             : 
     203           0 :         return NT_STATUS_OK;
     204             : }
     205             : 
     206           0 : NTSTATUS initshutdown__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     207             : {
     208           0 :         return initshutdown__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     209             : }
     210             : 
     211             : static const struct dcesrv_interface dcesrv_initshutdown_interface = {
     212             :         .name      = "initshutdown",
     213             :         .syntax_id = {{0x894de0c0,0x0d55,0x11d3,{0xa3,0x22},{0x00,0xc0,0x4f,0xa3,0x21,0xa1}},1.0},
     214             :         .bind      = initshutdown__op_bind,
     215             :         .unbind    = initshutdown__op_unbind,
     216             :         .ndr_pull  = initshutdown__op_ndr_pull,
     217             :         .dispatch  = initshutdown__op_dispatch,
     218             :         .reply     = initshutdown__op_reply,
     219             :         .ndr_push  = initshutdown__op_ndr_push,
     220             :         .local     = initshutdown__op_local,
     221             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_FLAGS
     222             :         .flags     = DCESRV_INTERFACE_INITSHUTDOWN_FLAGS
     223             : #else
     224             :         .flags     = 0
     225             : #endif
     226             : };
     227             : 
     228         126 : static NTSTATUS initshutdown__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     229             : {
     230           0 :         uint32_t i;
     231           0 :         NTSTATUS ret;
     232             : 
     233             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_NCACN_NP_SECONDARY_ENDPOINT
     234             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_INITSHUTDOWN_NCACN_NP_SECONDARY_ENDPOINT;
     235             : #else
     236         126 :         const char *ncacn_np_secondary_endpoint = NULL;
     237             : #endif
     238             : 
     239         252 :         for (i=0;i<ndr_table_initshutdown.endpoints->count;i++) {
     240         126 :                 const char *name = ndr_table_initshutdown.endpoints->names[i];
     241             : 
     242         126 :                 ret = dcesrv_interface_register(dce_ctx, name, ncacn_np_secondary_endpoint, &dcesrv_initshutdown_interface, NULL);
     243         126 :                 if (!NT_STATUS_IS_OK(ret)) {
     244           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     245           0 :                         return ret;
     246             :                 }
     247             :         }
     248             : 
     249         126 :         return NT_STATUS_OK;
     250             : }
     251             : 
     252         126 : static NTSTATUS initshutdown__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     253             : {
     254         126 :         return NT_STATUS_OK;
     255             : }
     256             : 
     257           0 : static bool initshutdown__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     258             : {
     259           0 :         if (dcesrv_initshutdown_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_initshutdown_interface.syntax_id.uuid, uuid)) {
     260           0 :                 memcpy(iface,&dcesrv_initshutdown_interface, sizeof(*iface));
     261           0 :                 return true;
     262             :         }
     263             : 
     264           0 :         return false;
     265             : }
     266             : 
     267           0 : static bool initshutdown__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     268             : {
     269           0 :         if (strcmp(dcesrv_initshutdown_interface.name, name)==0) {
     270           0 :                 memcpy(iface, &dcesrv_initshutdown_interface, sizeof(*iface));
     271           0 :                 return true;
     272             :         }
     273             : 
     274           0 :         return false;
     275             : }
     276             : 
     277             : static const struct dcesrv_endpoint_server initshutdown_ep_server = {
     278             :         /* fill in our name */
     279             :         .name = "initshutdown",
     280             : 
     281             :         /* Initialization flag */
     282             :         .initialized = false,
     283             : 
     284             :         /* fill in all the operations */
     285             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_INIT_SERVER
     286             :         .init_server = DCESRV_INTERFACE_INITSHUTDOWN_INIT_SERVER,
     287             : #else
     288             :         .init_server = initshutdown__op_init_server,
     289             : #endif
     290             : #ifdef DCESRV_INTERFACE_INITSHUTDOWN_SHUTDOWN_SERVER
     291             :         .shutdown_server = DCESRV_INTERFACE_INITSHUTDOWN_SHUTDOWN_SERVER,
     292             : #else
     293             :         .shutdown_server = initshutdown__op_shutdown_server,
     294             : #endif
     295             :         .interface_by_uuid = initshutdown__op_interface_by_uuid,
     296             :         .interface_by_name = initshutdown__op_interface_by_name
     297             : };
     298             : 
     299         126 : const struct dcesrv_endpoint_server *initshutdown_get_ep_server(void)
     300             : {
     301         126 :         return &initshutdown_ep_server;
     302             : }

Generated by: LCOV version 1.14