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

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_dssetup.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_dssetup_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             : /* dssetup - dcerpc server boilerplate generated by pidl */
      15           0 : static NTSTATUS dssetup__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_DSSETUP_BIND
      23             :         return DCESRV_INTERFACE_DSSETUP_BIND(context,iface);
      24             : #else
      25           0 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29           0 : static void dssetup__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_DSSETUP_UNBIND
      32             :         DCESRV_INTERFACE_DSSETUP_UNBIND(context, iface);
      33             : #else
      34           0 :         return;
      35             : #endif
      36             : }
      37             : 
      38           0 : NTSTATUS dssetup__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_dssetup.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_dssetup.calls[opnum].struct_size, "struct %s", ndr_table_dssetup.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_dssetup.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 dssetup__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: { /* dssetup_DsRoleGetPrimaryDomainInformation */
      98           0 :                 struct dssetup_DsRoleGetPrimaryDomainInformation *r2 = (struct dssetup_DsRoleGetPrimaryDomainInformation *)r;
      99           0 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetPrimaryDomainInformation, NDR_IN, r2);
     101             :                 }
     102           0 :                 NDR_ZERO_STRUCT(r2->out);
     103           0 :                 r2->out.info = talloc_zero(r2, union dssetup_DsRoleInfo);
     104           0 :                 if (r2->out.info == NULL) {
     105           0 :                         status = NT_STATUS_NO_MEMORY;
     106           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     107           0 :                         goto fail;
     108             :                 }
     109             : 
     110           0 :                 r2->out.result = _dssetup_DsRoleGetPrimaryDomainInformation(p, r2);
     111           0 :                 break;
     112             :         }
     113           0 :         case 1: { /* dssetup_DsRoleDnsNameToFlatName */
     114           0 :                 struct dssetup_DsRoleDnsNameToFlatName *r2 = (struct dssetup_DsRoleDnsNameToFlatName *)r;
     115           0 :                 if (DEBUGLEVEL >= 10) {
     116           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDnsNameToFlatName, NDR_IN, r2);
     117             :                 }
     118           0 :                 r2->out.result = _dssetup_DsRoleDnsNameToFlatName(p, r2);
     119           0 :                 break;
     120             :         }
     121           0 :         case 2: { /* dssetup_DsRoleDcAsDc */
     122           0 :                 struct dssetup_DsRoleDcAsDc *r2 = (struct dssetup_DsRoleDcAsDc *)r;
     123           0 :                 if (DEBUGLEVEL >= 10) {
     124           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDcAsDc, NDR_IN, r2);
     125             :                 }
     126           0 :                 r2->out.result = _dssetup_DsRoleDcAsDc(p, r2);
     127           0 :                 break;
     128             :         }
     129           0 :         case 3: { /* dssetup_DsRoleDcAsReplica */
     130           0 :                 struct dssetup_DsRoleDcAsReplica *r2 = (struct dssetup_DsRoleDcAsReplica *)r;
     131           0 :                 if (DEBUGLEVEL >= 10) {
     132           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDcAsReplica, NDR_IN, r2);
     133             :                 }
     134           0 :                 r2->out.result = _dssetup_DsRoleDcAsReplica(p, r2);
     135           0 :                 break;
     136             :         }
     137           0 :         case 4: { /* dssetup_DsRoleDemoteDc */
     138           0 :                 struct dssetup_DsRoleDemoteDc *r2 = (struct dssetup_DsRoleDemoteDc *)r;
     139           0 :                 if (DEBUGLEVEL >= 10) {
     140           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDemoteDc, NDR_IN, r2);
     141             :                 }
     142           0 :                 r2->out.result = _dssetup_DsRoleDemoteDc(p, r2);
     143           0 :                 break;
     144             :         }
     145           0 :         case 5: { /* dssetup_DsRoleGetDcOperationProgress */
     146           0 :                 struct dssetup_DsRoleGetDcOperationProgress *r2 = (struct dssetup_DsRoleGetDcOperationProgress *)r;
     147           0 :                 if (DEBUGLEVEL >= 10) {
     148           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetDcOperationProgress, NDR_IN, r2);
     149             :                 }
     150           0 :                 r2->out.result = _dssetup_DsRoleGetDcOperationProgress(p, r2);
     151           0 :                 break;
     152             :         }
     153           0 :         case 6: { /* dssetup_DsRoleGetDcOperationResults */
     154           0 :                 struct dssetup_DsRoleGetDcOperationResults *r2 = (struct dssetup_DsRoleGetDcOperationResults *)r;
     155           0 :                 if (DEBUGLEVEL >= 10) {
     156           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetDcOperationResults, NDR_IN, r2);
     157             :                 }
     158           0 :                 r2->out.result = _dssetup_DsRoleGetDcOperationResults(p, r2);
     159           0 :                 break;
     160             :         }
     161           0 :         case 7: { /* dssetup_DsRoleCancel */
     162           0 :                 struct dssetup_DsRoleCancel *r2 = (struct dssetup_DsRoleCancel *)r;
     163           0 :                 if (DEBUGLEVEL >= 10) {
     164           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleCancel, NDR_IN, r2);
     165             :                 }
     166           0 :                 r2->out.result = _dssetup_DsRoleCancel(p, r2);
     167           0 :                 break;
     168             :         }
     169           0 :         case 8: { /* dssetup_DsRoleServerSaveStateForUpgrade */
     170           0 :                 struct dssetup_DsRoleServerSaveStateForUpgrade *r2 = (struct dssetup_DsRoleServerSaveStateForUpgrade *)r;
     171           0 :                 if (DEBUGLEVEL >= 10) {
     172           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleServerSaveStateForUpgrade, NDR_IN, r2);
     173             :                 }
     174           0 :                 r2->out.result = _dssetup_DsRoleServerSaveStateForUpgrade(p, r2);
     175           0 :                 break;
     176             :         }
     177           0 :         case 9: { /* dssetup_DsRoleUpgradeDownlevelServer */
     178           0 :                 struct dssetup_DsRoleUpgradeDownlevelServer *r2 = (struct dssetup_DsRoleUpgradeDownlevelServer *)r;
     179           0 :                 if (DEBUGLEVEL >= 10) {
     180           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleUpgradeDownlevelServer, NDR_IN, r2);
     181             :                 }
     182           0 :                 r2->out.result = _dssetup_DsRoleUpgradeDownlevelServer(p, r2);
     183           0 :                 break;
     184             :         }
     185           0 :         case 10: { /* dssetup_DsRoleAbortDownlevelServerUpgrade */
     186           0 :                 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r2 = (struct dssetup_DsRoleAbortDownlevelServerUpgrade *)r;
     187           0 :                 if (DEBUGLEVEL >= 10) {
     188           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleAbortDownlevelServerUpgrade, NDR_IN, r2);
     189             :                 }
     190           0 :                 r2->out.result = _dssetup_DsRoleAbortDownlevelServerUpgrade(p, r2);
     191           0 :                 break;
     192             :         }
     193           0 :         default:
     194           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     195           0 :                 break;
     196             :         }
     197             : 
     198           0 : fail:
     199             :         /* Unimpersonate */
     200           0 :         if (impersonated) {
     201           0 :                 unbecome_authenticated_pipe_user();
     202             :         }
     203             : 
     204           0 :         p->dce_call = NULL;
     205           0 :         p->mem_ctx = NULL;
     206             :         /* Restore session info */
     207           0 :         p->session_info = pipe_session_info;
     208           0 :         p->auth.auth_type = 0;
     209           0 :         p->auth.auth_level = 0;
     210           0 :         p->auth.auth_context_id = 0;
     211             :         /* Check pipes struct fault state */
     212           0 :         if (p->fault_state != 0) {
     213           0 :                 dce_call->fault_code = p->fault_state;
     214             :         }
     215           0 :         if (dce_call->fault_code != 0) {
     216           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     217             :         }
     218             : 
     219           0 :         return status;
     220             : }
     221             : 
     222           0 : NTSTATUS dssetup__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     223             : {
     224           0 :         return dssetup__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     225             : }
     226             : 
     227           0 : NTSTATUS dssetup__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     228             : {
     229           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     230             : 
     231           0 :         switch (opnum) {
     232           0 :         case 0: { /* dssetup_DsRoleGetPrimaryDomainInformation */
     233           0 :                 struct dssetup_DsRoleGetPrimaryDomainInformation *r2 = (struct dssetup_DsRoleGetPrimaryDomainInformation *)r;
     234           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     235           0 :                         DEBUG(5,("function dssetup_DsRoleGetPrimaryDomainInformation replied async\n"));
     236             :                 }
     237           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     238           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetPrimaryDomainInformation, NDR_OUT | NDR_SET_VALUES, r2);
     239             :                 }
     240           0 :                 if (dce_call->fault_code != 0) {
     241           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleGetPrimaryDomainInformation\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     242             :                 }
     243           0 :                 break;
     244             :         }
     245           0 :         case 1: { /* dssetup_DsRoleDnsNameToFlatName */
     246           0 :                 struct dssetup_DsRoleDnsNameToFlatName *r2 = (struct dssetup_DsRoleDnsNameToFlatName *)r;
     247           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     248           0 :                         DEBUG(5,("function dssetup_DsRoleDnsNameToFlatName replied async\n"));
     249             :                 }
     250           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     251           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDnsNameToFlatName, NDR_OUT | NDR_SET_VALUES, r2);
     252             :                 }
     253           0 :                 if (dce_call->fault_code != 0) {
     254           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleDnsNameToFlatName\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     255             :                 }
     256           0 :                 break;
     257             :         }
     258           0 :         case 2: { /* dssetup_DsRoleDcAsDc */
     259           0 :                 struct dssetup_DsRoleDcAsDc *r2 = (struct dssetup_DsRoleDcAsDc *)r;
     260           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     261           0 :                         DEBUG(5,("function dssetup_DsRoleDcAsDc replied async\n"));
     262             :                 }
     263           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     264           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDcAsDc, NDR_OUT | NDR_SET_VALUES, r2);
     265             :                 }
     266           0 :                 if (dce_call->fault_code != 0) {
     267           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleDcAsDc\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     268             :                 }
     269           0 :                 break;
     270             :         }
     271           0 :         case 3: { /* dssetup_DsRoleDcAsReplica */
     272           0 :                 struct dssetup_DsRoleDcAsReplica *r2 = (struct dssetup_DsRoleDcAsReplica *)r;
     273           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     274           0 :                         DEBUG(5,("function dssetup_DsRoleDcAsReplica replied async\n"));
     275             :                 }
     276           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     277           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDcAsReplica, NDR_OUT | NDR_SET_VALUES, r2);
     278             :                 }
     279           0 :                 if (dce_call->fault_code != 0) {
     280           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleDcAsReplica\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     281             :                 }
     282           0 :                 break;
     283             :         }
     284           0 :         case 4: { /* dssetup_DsRoleDemoteDc */
     285           0 :                 struct dssetup_DsRoleDemoteDc *r2 = (struct dssetup_DsRoleDemoteDc *)r;
     286           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     287           0 :                         DEBUG(5,("function dssetup_DsRoleDemoteDc replied async\n"));
     288             :                 }
     289           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     290           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleDemoteDc, NDR_OUT | NDR_SET_VALUES, r2);
     291             :                 }
     292           0 :                 if (dce_call->fault_code != 0) {
     293           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleDemoteDc\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     294             :                 }
     295           0 :                 break;
     296             :         }
     297           0 :         case 5: { /* dssetup_DsRoleGetDcOperationProgress */
     298           0 :                 struct dssetup_DsRoleGetDcOperationProgress *r2 = (struct dssetup_DsRoleGetDcOperationProgress *)r;
     299           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     300           0 :                         DEBUG(5,("function dssetup_DsRoleGetDcOperationProgress replied async\n"));
     301             :                 }
     302           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     303           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetDcOperationProgress, NDR_OUT | NDR_SET_VALUES, r2);
     304             :                 }
     305           0 :                 if (dce_call->fault_code != 0) {
     306           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleGetDcOperationProgress\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     307             :                 }
     308           0 :                 break;
     309             :         }
     310           0 :         case 6: { /* dssetup_DsRoleGetDcOperationResults */
     311           0 :                 struct dssetup_DsRoleGetDcOperationResults *r2 = (struct dssetup_DsRoleGetDcOperationResults *)r;
     312           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     313           0 :                         DEBUG(5,("function dssetup_DsRoleGetDcOperationResults replied async\n"));
     314             :                 }
     315           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     316           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleGetDcOperationResults, NDR_OUT | NDR_SET_VALUES, r2);
     317             :                 }
     318           0 :                 if (dce_call->fault_code != 0) {
     319           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleGetDcOperationResults\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     320             :                 }
     321           0 :                 break;
     322             :         }
     323           0 :         case 7: { /* dssetup_DsRoleCancel */
     324           0 :                 struct dssetup_DsRoleCancel *r2 = (struct dssetup_DsRoleCancel *)r;
     325           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     326           0 :                         DEBUG(5,("function dssetup_DsRoleCancel replied async\n"));
     327             :                 }
     328           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     329           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleCancel, NDR_OUT | NDR_SET_VALUES, r2);
     330             :                 }
     331           0 :                 if (dce_call->fault_code != 0) {
     332           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleCancel\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     333             :                 }
     334           0 :                 break;
     335             :         }
     336           0 :         case 8: { /* dssetup_DsRoleServerSaveStateForUpgrade */
     337           0 :                 struct dssetup_DsRoleServerSaveStateForUpgrade *r2 = (struct dssetup_DsRoleServerSaveStateForUpgrade *)r;
     338           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     339           0 :                         DEBUG(5,("function dssetup_DsRoleServerSaveStateForUpgrade replied async\n"));
     340             :                 }
     341           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     342           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleServerSaveStateForUpgrade, NDR_OUT | NDR_SET_VALUES, r2);
     343             :                 }
     344           0 :                 if (dce_call->fault_code != 0) {
     345           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleServerSaveStateForUpgrade\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     346             :                 }
     347           0 :                 break;
     348             :         }
     349           0 :         case 9: { /* dssetup_DsRoleUpgradeDownlevelServer */
     350           0 :                 struct dssetup_DsRoleUpgradeDownlevelServer *r2 = (struct dssetup_DsRoleUpgradeDownlevelServer *)r;
     351           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     352           0 :                         DEBUG(5,("function dssetup_DsRoleUpgradeDownlevelServer replied async\n"));
     353             :                 }
     354           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     355           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleUpgradeDownlevelServer, NDR_OUT | NDR_SET_VALUES, r2);
     356             :                 }
     357           0 :                 if (dce_call->fault_code != 0) {
     358           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleUpgradeDownlevelServer\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     359             :                 }
     360           0 :                 break;
     361             :         }
     362           0 :         case 10: { /* dssetup_DsRoleAbortDownlevelServerUpgrade */
     363           0 :                 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r2 = (struct dssetup_DsRoleAbortDownlevelServerUpgrade *)r;
     364           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     365           0 :                         DEBUG(5,("function dssetup_DsRoleAbortDownlevelServerUpgrade replied async\n"));
     366             :                 }
     367           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     368           0 :                         NDR_PRINT_FUNCTION_DEBUG(dssetup_DsRoleAbortDownlevelServerUpgrade, NDR_OUT | NDR_SET_VALUES, r2);
     369             :                 }
     370           0 :                 if (dce_call->fault_code != 0) {
     371           0 :                         DBG_WARNING("dcerpc_fault %s in dssetup_DsRoleAbortDownlevelServerUpgrade\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     372             :                 }
     373           0 :                 break;
     374             :         }
     375           0 :         default:
     376           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     377           0 :                 break;
     378             :         }
     379             : 
     380           0 :         if (dce_call->fault_code != 0) {
     381           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     382             :         }
     383             : 
     384           0 :         return NT_STATUS_OK;
     385             : }
     386             : 
     387           0 : NTSTATUS dssetup__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     388             : {
     389             :         enum ndr_err_code ndr_err;
     390           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     391             : 
     392           0 :         ndr_err = ndr_table_dssetup.calls[opnum].ndr_push(push, NDR_OUT, r);
     393           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     394           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     395           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     396             :         }
     397             : 
     398           0 :         return NT_STATUS_OK;
     399             : }
     400             : 
     401           0 : NTSTATUS dssetup__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     402             : {
     403           0 :         return dssetup__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     404             : }
     405             : 
     406             : static const struct dcesrv_interface dcesrv_dssetup_interface = {
     407             :         .name      = "dssetup",
     408             :         .syntax_id = {{0x3919286a,0xb10c,0x11d0,{0x9b,0xa8},{0x00,0xc0,0x4f,0xd9,0x2e,0xf5}},0.0},
     409             :         .bind      = dssetup__op_bind,
     410             :         .unbind    = dssetup__op_unbind,
     411             :         .ndr_pull  = dssetup__op_ndr_pull,
     412             :         .dispatch  = dssetup__op_dispatch,
     413             :         .reply     = dssetup__op_reply,
     414             :         .ndr_push  = dssetup__op_ndr_push,
     415             :         .local     = dssetup__op_local,
     416             : #ifdef DCESRV_INTERFACE_DSSETUP_FLAGS
     417             :         .flags     = DCESRV_INTERFACE_DSSETUP_FLAGS
     418             : #else
     419             :         .flags     = 0
     420             : #endif
     421             : };
     422             : 
     423         112 : static NTSTATUS dssetup__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
     424         112 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
     425             :         NTSTATUS status;
     426             : 
     427             :         /* If service is disabled, do not register */
     428         112 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
     429           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
     430             :         }
     431             : 
     432             :         /* If service is embedded, register only for ncacn_np
     433             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
     434             :          */
     435         112 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
     436          28 :                 DBG_INFO("Interface 'dssetup' not registered in endpoint '%s' as service is embedded\n", name);
     437          28 :                 return NT_STATUS_NOT_SUPPORTED;
     438             :         }
     439             : 
     440             :         /*
     441             :          * If rpc service is external then change the default ncalrpc endpoint,
     442             :          * otherwise if the rpc daemon running this service is configured in
     443             :          * fork mode the forked process will race with main smbd to accept the
     444             :          * connections in the default ncalrpc socket, and the forked process
     445             :          * may not have the requested interface registered.
     446             :          * For example, in the ad_member test environment:
     447             :          *
     448             :          *   rpc_server:lsarpc = external
     449             :          *   rpc_server:samr = external
     450             :          *   rpc_server:netlogon = disabled
     451             :          *   rpc_daemon:lsasd = fork
     452             :          *
     453             :          * With these settings both, the main smbd and all the preforked lsasd
     454             :          * processes would be listening in the default ncalrpc socket if it is
     455             :          * not changed. If a client connection is accepted by one of the lsasd
     456             :          * worker processes and the client asks for an interface not registered
     457             :          * in these processes (winreg for example) it will get an error.
     458             :          */
     459          84 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
     460           0 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "DSSETUP");
     461           0 :                 if (!NT_STATUS_IS_OK(status)) {
     462           0 :                         return status;
     463             :                 }
     464             :         }
     465             : 
     466          84 :         return NT_STATUS_OK;
     467             : }
     468             : 
     469          28 : static NTSTATUS dssetup__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     470             : {
     471             :         uint32_t i;
     472             :         NTSTATUS ret;
     473             :         struct dcerpc_binding *binding;
     474          28 :         struct dcerpc_binding *binding2 = NULL;
     475             : 
     476             : #ifdef DCESRV_INTERFACE_DSSETUP_NCACN_NP_SECONDARY_ENDPOINT
     477             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_DSSETUP_NCACN_NP_SECONDARY_ENDPOINT;
     478             : #else
     479          28 :         const char *ncacn_np_secondary_endpoint = NULL;
     480             : #endif
     481             : 
     482         140 :         for (i=0;i<ndr_table_dssetup.endpoints->count;i++) {
     483         112 :                 const char *name = ndr_table_dssetup.endpoints->names[i];
     484             : 
     485         112 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
     486         112 :                 if (NT_STATUS_IS_ERR(ret)) {
     487           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
     488           0 :                         return ret;
     489             :                 }
     490             : 
     491         112 :                 ret = dssetup__check_register_in_endpoint("dssetup", binding);
     492         112 :                 if (NT_STATUS_IS_ERR(ret)) {
     493          28 :                         talloc_free(binding);
     494          28 :                         continue;
     495             :                 }
     496             : 
     497          84 :                 if (ncacn_np_secondary_endpoint != NULL) {
     498           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
     499           0 :                         if (NT_STATUS_IS_ERR(ret)) {
     500           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
     501           0 :                                 TALLOC_FREE(binding);
     502           0 :                                 return ret;
     503             :                         }
     504             :                 }
     505             : 
     506          84 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_dssetup_interface, NULL);
     507          84 :                 TALLOC_FREE(binding);
     508          84 :                 TALLOC_FREE(binding2);
     509          84 :                 if (!NT_STATUS_IS_OK(ret)) {
     510           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     511           0 :                         return ret;
     512             :                 }
     513             :         }
     514             : 
     515          28 :         return NT_STATUS_OK;
     516             : }
     517             : 
     518          19 : static NTSTATUS dssetup__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     519             : {
     520          19 :         return NT_STATUS_OK;
     521             : }
     522             : 
     523           0 : static bool dssetup__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     524             : {
     525           0 :         if (dcesrv_dssetup_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_dssetup_interface.syntax_id.uuid, uuid)) {
     526           0 :                 memcpy(iface,&dcesrv_dssetup_interface, sizeof(*iface));
     527           0 :                 return true;
     528             :         }
     529             : 
     530           0 :         return false;
     531             : }
     532             : 
     533           0 : static bool dssetup__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     534             : {
     535           0 :         if (strcmp(dcesrv_dssetup_interface.name, name)==0) {
     536           0 :                 memcpy(iface, &dcesrv_dssetup_interface, sizeof(*iface));
     537           0 :                 return true;
     538             :         }
     539             : 
     540           0 :         return false;
     541             : }
     542             : 
     543             : static const struct dcesrv_endpoint_server dssetup_ep_server = {
     544             :         /* fill in our name */
     545             :         .name = "dssetup",
     546             : 
     547             :         /* Initialization flag */
     548             :         .initialized = false,
     549             : 
     550             :         /* fill in all the operations */
     551             : #ifdef DCESRV_INTERFACE_DSSETUP_INIT_SERVER
     552             :         .init_server = DCESRV_INTERFACE_DSSETUP_INIT_SERVER,
     553             : #else
     554             :         .init_server = dssetup__op_init_server,
     555             : #endif
     556             : #ifdef DCESRV_INTERFACE_DSSETUP_SHUTDOWN_SERVER
     557             :         .shutdown_server = DCESRV_INTERFACE_DSSETUP_SHUTDOWN_SERVER,
     558             : #else
     559             :         .shutdown_server = dssetup__op_shutdown_server,
     560             : #endif
     561             :         .interface_by_uuid = dssetup__op_interface_by_uuid,
     562             :         .interface_by_name = dssetup__op_interface_by_name
     563             : };
     564             : 
     565          60 : const struct dcesrv_endpoint_server *dssetup_get_ep_server(void)
     566             : {
     567          60 :         return &dssetup_ep_server;
     568             : }

Generated by: LCOV version 1.13