LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_epmapper_scompat.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 0 278 0.0 %
Date: 2021-09-23 10:06:22 Functions: 0 14 0.0 %

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_epmapper.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_epmapper_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             : /* epmapper - dcerpc server boilerplate generated by pidl */
      15           0 : static NTSTATUS epmapper__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      16             : {
      17           0 :         struct pipes_struct *p = NULL;
      18             : 
      19             :         /* Retrieve pipes struct */
      20           0 :         p = dcesrv_get_pipes_struct(context->conn);
      21           0 :         p->pipe_bound = true;
      22             : #ifdef DCESRV_INTERFACE_EPMAPPER_BIND
      23             :         return DCESRV_INTERFACE_EPMAPPER_BIND(context,iface);
      24             : #else
      25           0 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29           0 : static void epmapper__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_EPMAPPER_UNBIND
      32             :         DCESRV_INTERFACE_EPMAPPER_UNBIND(context, iface);
      33             : #else
      34           0 :         return;
      35             : #endif
      36             : }
      37             : 
      38           0 : NTSTATUS epmapper__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      39             : {
      40             :         enum ndr_err_code ndr_err;
      41           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      42             : 
      43           0 :         dce_call->fault_code = 0;
      44             : 
      45           0 :         if (opnum >= ndr_table_epmapper.num_calls) {
      46           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      47           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      48             :         }
      49             : 
      50           0 :         *r = talloc_named(mem_ctx, ndr_table_epmapper.calls[opnum].struct_size, "struct %s", ndr_table_epmapper.calls[opnum].name);
      51           0 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      52             : 
      53             :         /* unravel the NDR for the packet */
      54           0 :         ndr_err = ndr_table_epmapper.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      55           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      56           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
      57           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      58             :         }
      59             : 
      60           0 :         return NT_STATUS_OK;
      61             : }
      62             : 
      63           0 : static NTSTATUS epmapper__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
      64             : {
      65           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      66           0 :         struct pipes_struct *p = NULL;
      67           0 :         struct auth_session_info *pipe_session_info = NULL;
      68           0 :         NTSTATUS status = NT_STATUS_OK;
      69           0 :         bool impersonated = false;
      70             : 
      71             :         /* Retrieve pipes struct */
      72           0 :         p = dcesrv_get_pipes_struct(dce_call->conn);
      73             :         /* Update pipes struct opnum */
      74           0 :         p->opnum = opnum;
      75           0 :         p->dce_call = dce_call;
      76           0 :         p->mem_ctx = mem_ctx;
      77             :         /* Update pipes struct session info */
      78           0 :         pipe_session_info = p->session_info;
      79           0 :         p->session_info = dce_call->auth_state->session_info;
      80           0 :         p->auth.auth_type = dce_call->auth_state->auth_type;
      81           0 :         p->auth.auth_level = dce_call->auth_state->auth_level;
      82           0 :         p->auth.auth_context_id = dce_call->auth_state->auth_context_id;
      83             :         /* Reset pipes struct fault state */
      84           0 :         p->fault_state = 0;
      85             : 
      86             :         /* Impersonate */
      87           0 :         if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
      88           0 :                 impersonated = become_authenticated_pipe_user(p->session_info);
      89           0 :                 if (!impersonated) {
      90           0 :                         dce_call->fault_code = DCERPC_FAULT_ACCESS_DENIED;
      91           0 :                         status = NT_STATUS_NET_WRITE_FAULT;
      92           0 :                         goto fail;
      93             :                 }
      94             :         }
      95             : 
      96           0 :         switch (opnum) {
      97           0 :         case 0: { /* epm_Insert */
      98           0 :                 struct epm_Insert *r2 = (struct epm_Insert *)r;
      99           0 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Insert, NDR_IN, r2);
     101             :                 }
     102           0 :                 r2->out.result = _epm_Insert(p, r2);
     103           0 :                 break;
     104             :         }
     105           0 :         case 1: { /* epm_Delete */
     106           0 :                 struct epm_Delete *r2 = (struct epm_Delete *)r;
     107           0 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Delete, NDR_IN, r2);
     109             :                 }
     110           0 :                 r2->out.result = _epm_Delete(p, r2);
     111           0 :                 break;
     112             :         }
     113           0 :         case 2: { /* epm_Lookup */
     114           0 :                 struct epm_Lookup *r2 = (struct epm_Lookup *)r;
     115           0 :                 if (DEBUGLEVEL >= 10) {
     116           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Lookup, NDR_IN, r2);
     117             :                 }
     118           0 :                 NDR_ZERO_STRUCT(r2->out);
     119           0 :                 r2->out.entry_handle = r2->in.entry_handle;
     120           0 :                 r2->out.num_ents = talloc_zero(r2, uint32_t);
     121           0 :                 if (r2->out.num_ents == NULL) {
     122           0 :                         status = NT_STATUS_NO_MEMORY;
     123           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     124           0 :                         goto fail;
     125             :                 }
     126             : 
     127           0 :                 r2->out.entries = talloc_zero_array(r2, struct epm_entry_t, r2->in.max_ents);
     128           0 :                 if (r2->out.entries == NULL) {
     129           0 :                         status = NT_STATUS_NO_MEMORY;
     130           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     131           0 :                         goto fail;
     132             :                 }
     133             : 
     134           0 :                 r2->out.result = _epm_Lookup(p, r2);
     135           0 :                 break;
     136             :         }
     137           0 :         case 3: { /* epm_Map */
     138           0 :                 struct epm_Map *r2 = (struct epm_Map *)r;
     139           0 :                 if (DEBUGLEVEL >= 10) {
     140           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Map, NDR_IN, r2);
     141             :                 }
     142           0 :                 NDR_ZERO_STRUCT(r2->out);
     143           0 :                 r2->out.entry_handle = r2->in.entry_handle;
     144           0 :                 r2->out.num_towers = talloc_zero(r2, uint32_t);
     145           0 :                 if (r2->out.num_towers == NULL) {
     146           0 :                         status = NT_STATUS_NO_MEMORY;
     147           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     148           0 :                         goto fail;
     149             :                 }
     150             : 
     151           0 :                 r2->out.towers = talloc_zero_array(r2, struct epm_twr_p_t, r2->in.max_towers);
     152           0 :                 if (r2->out.towers == NULL) {
     153           0 :                         status = NT_STATUS_NO_MEMORY;
     154           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     155           0 :                         goto fail;
     156             :                 }
     157             : 
     158           0 :                 r2->out.result = _epm_Map(p, r2);
     159           0 :                 break;
     160             :         }
     161           0 :         case 4: { /* epm_LookupHandleFree */
     162           0 :                 struct epm_LookupHandleFree *r2 = (struct epm_LookupHandleFree *)r;
     163           0 :                 if (DEBUGLEVEL >= 10) {
     164           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_LookupHandleFree, NDR_IN, r2);
     165             :                 }
     166           0 :                 NDR_ZERO_STRUCT(r2->out);
     167           0 :                 r2->out.entry_handle = r2->in.entry_handle;
     168           0 :                 r2->out.result = _epm_LookupHandleFree(p, r2);
     169           0 :                 break;
     170             :         }
     171           0 :         case 5: { /* epm_InqObject */
     172           0 :                 struct epm_InqObject *r2 = (struct epm_InqObject *)r;
     173           0 :                 if (DEBUGLEVEL >= 10) {
     174           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_InqObject, NDR_IN, r2);
     175             :                 }
     176           0 :                 r2->out.result = _epm_InqObject(p, r2);
     177           0 :                 break;
     178             :         }
     179           0 :         case 6: { /* epm_MgmtDelete */
     180           0 :                 struct epm_MgmtDelete *r2 = (struct epm_MgmtDelete *)r;
     181           0 :                 if (DEBUGLEVEL >= 10) {
     182           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MgmtDelete, NDR_IN, r2);
     183             :                 }
     184           0 :                 r2->out.result = _epm_MgmtDelete(p, r2);
     185           0 :                 break;
     186             :         }
     187           0 :         case 7: { /* epm_MapAuth */
     188           0 :                 struct epm_MapAuth *r2 = (struct epm_MapAuth *)r;
     189           0 :                 if (DEBUGLEVEL >= 10) {
     190           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MapAuth, NDR_IN, r2);
     191             :                 }
     192           0 :                 r2->out.result = _epm_MapAuth(p, r2);
     193           0 :                 break;
     194             :         }
     195           0 :         default:
     196           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     197           0 :                 break;
     198             :         }
     199             : 
     200           0 : fail:
     201             :         /* Unimpersonate */
     202           0 :         if (impersonated) {
     203           0 :                 unbecome_authenticated_pipe_user();
     204             :         }
     205             : 
     206           0 :         p->dce_call = NULL;
     207           0 :         p->mem_ctx = NULL;
     208             :         /* Restore session info */
     209           0 :         p->session_info = pipe_session_info;
     210           0 :         p->auth.auth_type = 0;
     211           0 :         p->auth.auth_level = 0;
     212           0 :         p->auth.auth_context_id = 0;
     213             :         /* Check pipes struct fault state */
     214           0 :         if (p->fault_state != 0) {
     215           0 :                 dce_call->fault_code = p->fault_state;
     216             :         }
     217           0 :         if (dce_call->fault_code != 0) {
     218           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     219             :         }
     220             : 
     221           0 :         return status;
     222             : }
     223             : 
     224           0 : NTSTATUS epmapper__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     225             : {
     226           0 :         return epmapper__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     227             : }
     228             : 
     229           0 : NTSTATUS epmapper__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     230             : {
     231           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     232             : 
     233           0 :         switch (opnum) {
     234           0 :         case 0: { /* epm_Insert */
     235           0 :                 struct epm_Insert *r2 = (struct epm_Insert *)r;
     236           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     237           0 :                         DEBUG(5,("function epm_Insert replied async\n"));
     238             :                 }
     239           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     240           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Insert, NDR_OUT | NDR_SET_VALUES, r2);
     241             :                 }
     242           0 :                 if (dce_call->fault_code != 0) {
     243           0 :                         DBG_WARNING("dcerpc_fault %s in epm_Insert\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     244             :                 }
     245           0 :                 break;
     246             :         }
     247           0 :         case 1: { /* epm_Delete */
     248           0 :                 struct epm_Delete *r2 = (struct epm_Delete *)r;
     249           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     250           0 :                         DEBUG(5,("function epm_Delete replied async\n"));
     251             :                 }
     252           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     253           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Delete, NDR_OUT | NDR_SET_VALUES, r2);
     254             :                 }
     255           0 :                 if (dce_call->fault_code != 0) {
     256           0 :                         DBG_WARNING("dcerpc_fault %s in epm_Delete\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     257             :                 }
     258           0 :                 break;
     259             :         }
     260           0 :         case 2: { /* epm_Lookup */
     261           0 :                 struct epm_Lookup *r2 = (struct epm_Lookup *)r;
     262           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     263           0 :                         DEBUG(5,("function epm_Lookup replied async\n"));
     264             :                 }
     265           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     266           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Lookup, NDR_OUT | NDR_SET_VALUES, r2);
     267             :                 }
     268           0 :                 if (dce_call->fault_code != 0) {
     269           0 :                         DBG_WARNING("dcerpc_fault %s in epm_Lookup\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     270             :                 }
     271           0 :                 break;
     272             :         }
     273           0 :         case 3: { /* epm_Map */
     274           0 :                 struct epm_Map *r2 = (struct epm_Map *)r;
     275           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     276           0 :                         DEBUG(5,("function epm_Map replied async\n"));
     277             :                 }
     278           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     279           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_Map, NDR_OUT | NDR_SET_VALUES, r2);
     280             :                 }
     281           0 :                 if (dce_call->fault_code != 0) {
     282           0 :                         DBG_WARNING("dcerpc_fault %s in epm_Map\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     283             :                 }
     284           0 :                 break;
     285             :         }
     286           0 :         case 4: { /* epm_LookupHandleFree */
     287           0 :                 struct epm_LookupHandleFree *r2 = (struct epm_LookupHandleFree *)r;
     288           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     289           0 :                         DEBUG(5,("function epm_LookupHandleFree replied async\n"));
     290             :                 }
     291           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     292           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_LookupHandleFree, NDR_OUT | NDR_SET_VALUES, r2);
     293             :                 }
     294           0 :                 if (dce_call->fault_code != 0) {
     295           0 :                         DBG_WARNING("dcerpc_fault %s in epm_LookupHandleFree\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     296             :                 }
     297           0 :                 break;
     298             :         }
     299           0 :         case 5: { /* epm_InqObject */
     300           0 :                 struct epm_InqObject *r2 = (struct epm_InqObject *)r;
     301           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     302           0 :                         DEBUG(5,("function epm_InqObject replied async\n"));
     303             :                 }
     304           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     305           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_InqObject, NDR_OUT | NDR_SET_VALUES, r2);
     306             :                 }
     307           0 :                 if (dce_call->fault_code != 0) {
     308           0 :                         DBG_WARNING("dcerpc_fault %s in epm_InqObject\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     309             :                 }
     310           0 :                 break;
     311             :         }
     312           0 :         case 6: { /* epm_MgmtDelete */
     313           0 :                 struct epm_MgmtDelete *r2 = (struct epm_MgmtDelete *)r;
     314           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     315           0 :                         DEBUG(5,("function epm_MgmtDelete replied async\n"));
     316             :                 }
     317           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     318           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MgmtDelete, NDR_OUT | NDR_SET_VALUES, r2);
     319             :                 }
     320           0 :                 if (dce_call->fault_code != 0) {
     321           0 :                         DBG_WARNING("dcerpc_fault %s in epm_MgmtDelete\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     322             :                 }
     323           0 :                 break;
     324             :         }
     325           0 :         case 7: { /* epm_MapAuth */
     326           0 :                 struct epm_MapAuth *r2 = (struct epm_MapAuth *)r;
     327           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     328           0 :                         DEBUG(5,("function epm_MapAuth replied async\n"));
     329             :                 }
     330           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     331           0 :                         NDR_PRINT_FUNCTION_DEBUG(epm_MapAuth, NDR_OUT | NDR_SET_VALUES, r2);
     332             :                 }
     333           0 :                 if (dce_call->fault_code != 0) {
     334           0 :                         DBG_WARNING("dcerpc_fault %s in epm_MapAuth\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     335             :                 }
     336           0 :                 break;
     337             :         }
     338           0 :         default:
     339           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     340           0 :                 break;
     341             :         }
     342             : 
     343           0 :         if (dce_call->fault_code != 0) {
     344           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     345             :         }
     346             : 
     347           0 :         return NT_STATUS_OK;
     348             : }
     349             : 
     350           0 : NTSTATUS epmapper__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     351             : {
     352             :         enum ndr_err_code ndr_err;
     353           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     354             : 
     355           0 :         ndr_err = ndr_table_epmapper.calls[opnum].ndr_push(push, NDR_OUT, r);
     356           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     357           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     358           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     359             :         }
     360             : 
     361           0 :         return NT_STATUS_OK;
     362             : }
     363             : 
     364           0 : NTSTATUS epmapper__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     365             : {
     366           0 :         return epmapper__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     367             : }
     368             : 
     369             : static const struct dcesrv_interface dcesrv_epmapper_interface = {
     370             :         .name      = "epmapper",
     371             :         .syntax_id = {{0xe1af8308,0x5d1f,0x11c9,{0x91,0xa4},{0x08,0x00,0x2b,0x14,0xa0,0xfa}},3.0},
     372             :         .bind      = epmapper__op_bind,
     373             :         .unbind    = epmapper__op_unbind,
     374             :         .ndr_pull  = epmapper__op_ndr_pull,
     375             :         .dispatch  = epmapper__op_dispatch,
     376             :         .reply     = epmapper__op_reply,
     377             :         .ndr_push  = epmapper__op_ndr_push,
     378             :         .local     = epmapper__op_local,
     379             : #ifdef DCESRV_INTERFACE_EPMAPPER_FLAGS
     380             :         .flags     = DCESRV_INTERFACE_EPMAPPER_FLAGS
     381             : #else
     382             :         .flags     = 0
     383             : #endif
     384             : };
     385             : 
     386           0 : static NTSTATUS epmapper__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
     387           0 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
     388             :         NTSTATUS status;
     389             : 
     390             :         /* If service is disabled, do not register */
     391           0 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
     392           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
     393             :         }
     394             : 
     395             :         /* If service is embedded, register only for ncacn_np
     396             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
     397             :          */
     398           0 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
     399           0 :                 DBG_INFO("Interface 'epmapper' not registered in endpoint '%s' as service is embedded\n", name);
     400           0 :                 return NT_STATUS_NOT_SUPPORTED;
     401             :         }
     402             : 
     403             :         /*
     404             :          * If rpc service is external then change the default ncalrpc endpoint,
     405             :          * otherwise if the rpc daemon running this service is configured in
     406             :          * fork mode the forked process will race with main smbd to accept the
     407             :          * connections in the default ncalrpc socket, and the forked process
     408             :          * may not have the requested interface registered.
     409             :          * For example, in the ad_member test environment:
     410             :          *
     411             :          *   rpc_server:lsarpc = external
     412             :          *   rpc_server:samr = external
     413             :          *   rpc_server:netlogon = disabled
     414             :          *   rpc_daemon:lsasd = fork
     415             :          *
     416             :          * With these settings both, the main smbd and all the preforked lsasd
     417             :          * processes would be listening in the default ncalrpc socket if it is
     418             :          * not changed. If a client connection is accepted by one of the lsasd
     419             :          * worker processes and the client asks for an interface not registered
     420             :          * in these processes (winreg for example) it will get an error.
     421             :          */
     422           0 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
     423           0 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "EPMAPPER");
     424           0 :                 if (!NT_STATUS_IS_OK(status)) {
     425           0 :                         return status;
     426             :                 }
     427             :         }
     428             : 
     429           0 :         return NT_STATUS_OK;
     430             : }
     431             : 
     432           0 : static NTSTATUS epmapper__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     433             : {
     434             :         uint32_t i;
     435             :         NTSTATUS ret;
     436             :         struct dcerpc_binding *binding;
     437           0 :         struct dcerpc_binding *binding2 = NULL;
     438             : 
     439             : #ifdef DCESRV_INTERFACE_EPMAPPER_NCACN_NP_SECONDARY_ENDPOINT
     440             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_EPMAPPER_NCACN_NP_SECONDARY_ENDPOINT;
     441             : #else
     442           0 :         const char *ncacn_np_secondary_endpoint = NULL;
     443             : #endif
     444             : 
     445           0 :         for (i=0;i<ndr_table_epmapper.endpoints->count;i++) {
     446           0 :                 const char *name = ndr_table_epmapper.endpoints->names[i];
     447             : 
     448           0 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
     449           0 :                 if (NT_STATUS_IS_ERR(ret)) {
     450           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
     451           0 :                         return ret;
     452             :                 }
     453             : 
     454           0 :                 ret = epmapper__check_register_in_endpoint("epmapper", binding);
     455           0 :                 if (NT_STATUS_IS_ERR(ret)) {
     456           0 :                         talloc_free(binding);
     457           0 :                         continue;
     458             :                 }
     459             : 
     460           0 :                 if (ncacn_np_secondary_endpoint != NULL) {
     461           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
     462           0 :                         if (NT_STATUS_IS_ERR(ret)) {
     463           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
     464           0 :                                 TALLOC_FREE(binding);
     465           0 :                                 return ret;
     466             :                         }
     467             :                 }
     468             : 
     469           0 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_epmapper_interface, NULL);
     470           0 :                 TALLOC_FREE(binding);
     471           0 :                 TALLOC_FREE(binding2);
     472           0 :                 if (!NT_STATUS_IS_OK(ret)) {
     473           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     474           0 :                         return ret;
     475             :                 }
     476             :         }
     477             : 
     478           0 :         return NT_STATUS_OK;
     479             : }
     480             : 
     481           0 : static NTSTATUS epmapper__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     482             : {
     483           0 :         return NT_STATUS_OK;
     484             : }
     485             : 
     486           0 : static bool epmapper__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     487             : {
     488           0 :         if (dcesrv_epmapper_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_epmapper_interface.syntax_id.uuid, uuid)) {
     489           0 :                 memcpy(iface,&dcesrv_epmapper_interface, sizeof(*iface));
     490           0 :                 return true;
     491             :         }
     492             : 
     493           0 :         return false;
     494             : }
     495             : 
     496           0 : static bool epmapper__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     497             : {
     498           0 :         if (strcmp(dcesrv_epmapper_interface.name, name)==0) {
     499           0 :                 memcpy(iface, &dcesrv_epmapper_interface, sizeof(*iface));
     500           0 :                 return true;
     501             :         }
     502             : 
     503           0 :         return false;
     504             : }
     505             : 
     506             : static const struct dcesrv_endpoint_server epmapper_ep_server = {
     507             :         /* fill in our name */
     508             :         .name = "epmapper",
     509             : 
     510             :         /* Initialization flag */
     511             :         .initialized = false,
     512             : 
     513             :         /* fill in all the operations */
     514             : #ifdef DCESRV_INTERFACE_EPMAPPER_INIT_SERVER
     515             :         .init_server = DCESRV_INTERFACE_EPMAPPER_INIT_SERVER,
     516             : #else
     517             :         .init_server = epmapper__op_init_server,
     518             : #endif
     519             : #ifdef DCESRV_INTERFACE_EPMAPPER_SHUTDOWN_SERVER
     520             :         .shutdown_server = DCESRV_INTERFACE_EPMAPPER_SHUTDOWN_SERVER,
     521             : #else
     522             :         .shutdown_server = epmapper__op_shutdown_server,
     523             : #endif
     524             :         .interface_by_uuid = epmapper__op_interface_by_uuid,
     525             :         .interface_by_name = epmapper__op_interface_by_name
     526             : };
     527             : 
     528           0 : const struct dcesrv_endpoint_server *epmapper_get_ep_server(void)
     529             : {
     530           0 :         return &epmapper_ep_server;
     531             : }

Generated by: LCOV version 1.13