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

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_winbind.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_winbind_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             : /* winbind - dcerpc server boilerplate generated by pidl */
      15           0 : static NTSTATUS winbind__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_WINBIND_BIND
      23             :         return DCESRV_INTERFACE_WINBIND_BIND(context,iface);
      24             : #else
      25           0 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29           0 : static void winbind__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_WINBIND_UNBIND
      32             :         DCESRV_INTERFACE_WINBIND_UNBIND(context, iface);
      33             : #else
      34           0 :         return;
      35             : #endif
      36             : }
      37             : 
      38           0 : NTSTATUS winbind__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_winbind.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_winbind.calls[opnum].struct_size, "struct %s", ndr_table_winbind.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_winbind.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 winbind__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: { /* wbint_Ping */
      98           0 :                 struct wbint_Ping *r2 = (struct wbint_Ping *)r;
      99           0 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_Ping, NDR_IN, r2);
     101             :                 }
     102           0 :                 NDR_ZERO_STRUCT(r2->out);
     103           0 :                 r2->out.out_data = talloc_zero(r2, uint32_t);
     104           0 :                 if (r2->out.out_data == 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 :                 _wbint_Ping(p, r2);
     111           0 :                 break;
     112             :         }
     113           0 :         case 1: { /* wbint_LookupSid */
     114           0 :                 struct wbint_LookupSid *r2 = (struct wbint_LookupSid *)r;
     115           0 :                 if (DEBUGLEVEL >= 10) {
     116           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupSid, NDR_IN, r2);
     117             :                 }
     118           0 :                 NDR_ZERO_STRUCT(r2->out);
     119           0 :                 r2->out.type = talloc_zero(r2, enum lsa_SidType);
     120           0 :                 if (r2->out.type == NULL) {
     121           0 :                         status = NT_STATUS_NO_MEMORY;
     122           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     123           0 :                         goto fail;
     124             :                 }
     125             : 
     126           0 :                 r2->out.domain = talloc_zero(r2, const char *);
     127           0 :                 if (r2->out.domain == NULL) {
     128           0 :                         status = NT_STATUS_NO_MEMORY;
     129           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     130           0 :                         goto fail;
     131             :                 }
     132             : 
     133           0 :                 r2->out.name = talloc_zero(r2, const char *);
     134           0 :                 if (r2->out.name == NULL) {
     135           0 :                         status = NT_STATUS_NO_MEMORY;
     136           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     137           0 :                         goto fail;
     138             :                 }
     139             : 
     140           0 :                 r2->out.result = _wbint_LookupSid(p, r2);
     141           0 :                 break;
     142             :         }
     143           0 :         case 2: { /* wbint_LookupSids */
     144           0 :                 struct wbint_LookupSids *r2 = (struct wbint_LookupSids *)r;
     145           0 :                 if (DEBUGLEVEL >= 10) {
     146           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupSids, NDR_IN, r2);
     147             :                 }
     148           0 :                 NDR_ZERO_STRUCT(r2->out);
     149           0 :                 r2->out.domains = talloc_zero(r2, struct lsa_RefDomainList);
     150           0 :                 if (r2->out.domains == NULL) {
     151           0 :                         status = NT_STATUS_NO_MEMORY;
     152           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     153           0 :                         goto fail;
     154             :                 }
     155             : 
     156           0 :                 r2->out.names = talloc_zero(r2, struct lsa_TransNameArray);
     157           0 :                 if (r2->out.names == NULL) {
     158           0 :                         status = NT_STATUS_NO_MEMORY;
     159           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     160           0 :                         goto fail;
     161             :                 }
     162             : 
     163           0 :                 r2->out.result = _wbint_LookupSids(p, r2);
     164           0 :                 break;
     165             :         }
     166           0 :         case 3: { /* wbint_LookupName */
     167           0 :                 struct wbint_LookupName *r2 = (struct wbint_LookupName *)r;
     168           0 :                 if (DEBUGLEVEL >= 10) {
     169           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupName, NDR_IN, r2);
     170             :                 }
     171           0 :                 NDR_ZERO_STRUCT(r2->out);
     172           0 :                 r2->out.type = talloc_zero(r2, enum lsa_SidType);
     173           0 :                 if (r2->out.type == NULL) {
     174           0 :                         status = NT_STATUS_NO_MEMORY;
     175           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     176           0 :                         goto fail;
     177             :                 }
     178             : 
     179           0 :                 r2->out.sid = talloc_zero(r2, struct dom_sid);
     180           0 :                 if (r2->out.sid == NULL) {
     181           0 :                         status = NT_STATUS_NO_MEMORY;
     182           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     183           0 :                         goto fail;
     184             :                 }
     185             : 
     186           0 :                 r2->out.result = _wbint_LookupName(p, r2);
     187           0 :                 break;
     188             :         }
     189           0 :         case 4: { /* wbint_Sids2UnixIDs */
     190           0 :                 struct wbint_Sids2UnixIDs *r2 = (struct wbint_Sids2UnixIDs *)r;
     191           0 :                 if (DEBUGLEVEL >= 10) {
     192           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_Sids2UnixIDs, NDR_IN, r2);
     193             :                 }
     194           0 :                 NDR_ZERO_STRUCT(r2->out);
     195           0 :                 r2->out.ids = r2->in.ids;
     196           0 :                 r2->out.result = _wbint_Sids2UnixIDs(p, r2);
     197           0 :                 break;
     198             :         }
     199           0 :         case 5: { /* wbint_UnixIDs2Sids */
     200           0 :                 struct wbint_UnixIDs2Sids *r2 = (struct wbint_UnixIDs2Sids *)r;
     201           0 :                 if (DEBUGLEVEL >= 10) {
     202           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_UnixIDs2Sids, NDR_IN, r2);
     203             :                 }
     204           0 :                 NDR_ZERO_STRUCT(r2->out);
     205           0 :                 r2->out.xids = r2->in.xids;
     206           0 :                 r2->out.sids = talloc_zero_array(r2, struct dom_sid, r2->in.num_ids);
     207           0 :                 if (r2->out.sids == NULL) {
     208           0 :                         status = NT_STATUS_NO_MEMORY;
     209           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     210           0 :                         goto fail;
     211             :                 }
     212             : 
     213           0 :                 r2->out.result = _wbint_UnixIDs2Sids(p, r2);
     214           0 :                 break;
     215             :         }
     216           0 :         case 6: { /* wbint_AllocateUid */
     217           0 :                 struct wbint_AllocateUid *r2 = (struct wbint_AllocateUid *)r;
     218           0 :                 if (DEBUGLEVEL >= 10) {
     219           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_AllocateUid, NDR_IN, r2);
     220             :                 }
     221           0 :                 NDR_ZERO_STRUCT(r2->out);
     222           0 :                 r2->out.uid = talloc_zero(r2, uint64_t);
     223           0 :                 if (r2->out.uid == NULL) {
     224           0 :                         status = NT_STATUS_NO_MEMORY;
     225           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     226           0 :                         goto fail;
     227             :                 }
     228             : 
     229           0 :                 r2->out.result = _wbint_AllocateUid(p, r2);
     230           0 :                 break;
     231             :         }
     232           0 :         case 7: { /* wbint_AllocateGid */
     233           0 :                 struct wbint_AllocateGid *r2 = (struct wbint_AllocateGid *)r;
     234           0 :                 if (DEBUGLEVEL >= 10) {
     235           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_AllocateGid, NDR_IN, r2);
     236             :                 }
     237           0 :                 NDR_ZERO_STRUCT(r2->out);
     238           0 :                 r2->out.gid = talloc_zero(r2, uint64_t);
     239           0 :                 if (r2->out.gid == NULL) {
     240           0 :                         status = NT_STATUS_NO_MEMORY;
     241           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     242           0 :                         goto fail;
     243             :                 }
     244             : 
     245           0 :                 r2->out.result = _wbint_AllocateGid(p, r2);
     246           0 :                 break;
     247             :         }
     248           0 :         case 8: { /* wbint_GetNssInfo */
     249           0 :                 struct wbint_GetNssInfo *r2 = (struct wbint_GetNssInfo *)r;
     250           0 :                 if (DEBUGLEVEL >= 10) {
     251           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_GetNssInfo, NDR_IN, r2);
     252             :                 }
     253           0 :                 NDR_ZERO_STRUCT(r2->out);
     254           0 :                 r2->out.info = r2->in.info;
     255           0 :                 r2->out.result = _wbint_GetNssInfo(p, r2);
     256           0 :                 break;
     257             :         }
     258           0 :         case 9: { /* wbint_LookupUserAliases */
     259           0 :                 struct wbint_LookupUserAliases *r2 = (struct wbint_LookupUserAliases *)r;
     260           0 :                 if (DEBUGLEVEL >= 10) {
     261           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupUserAliases, NDR_IN, r2);
     262             :                 }
     263           0 :                 NDR_ZERO_STRUCT(r2->out);
     264           0 :                 r2->out.rids = talloc_zero(r2, struct wbint_RidArray);
     265           0 :                 if (r2->out.rids == NULL) {
     266           0 :                         status = NT_STATUS_NO_MEMORY;
     267           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     268           0 :                         goto fail;
     269             :                 }
     270             : 
     271           0 :                 r2->out.result = _wbint_LookupUserAliases(p, r2);
     272           0 :                 break;
     273             :         }
     274           0 :         case 10: { /* wbint_LookupUserGroups */
     275           0 :                 struct wbint_LookupUserGroups *r2 = (struct wbint_LookupUserGroups *)r;
     276           0 :                 if (DEBUGLEVEL >= 10) {
     277           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupUserGroups, NDR_IN, r2);
     278             :                 }
     279           0 :                 NDR_ZERO_STRUCT(r2->out);
     280           0 :                 r2->out.sids = talloc_zero(r2, struct wbint_SidArray);
     281           0 :                 if (r2->out.sids == NULL) {
     282           0 :                         status = NT_STATUS_NO_MEMORY;
     283           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     284           0 :                         goto fail;
     285             :                 }
     286             : 
     287           0 :                 r2->out.result = _wbint_LookupUserGroups(p, r2);
     288           0 :                 break;
     289             :         }
     290           0 :         case 11: { /* wbint_QuerySequenceNumber */
     291           0 :                 struct wbint_QuerySequenceNumber *r2 = (struct wbint_QuerySequenceNumber *)r;
     292           0 :                 if (DEBUGLEVEL >= 10) {
     293           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QuerySequenceNumber, NDR_IN, r2);
     294             :                 }
     295           0 :                 NDR_ZERO_STRUCT(r2->out);
     296           0 :                 r2->out.sequence = talloc_zero(r2, uint32_t);
     297           0 :                 if (r2->out.sequence == NULL) {
     298           0 :                         status = NT_STATUS_NO_MEMORY;
     299           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     300           0 :                         goto fail;
     301             :                 }
     302             : 
     303           0 :                 r2->out.result = _wbint_QuerySequenceNumber(p, r2);
     304           0 :                 break;
     305             :         }
     306           0 :         case 12: { /* wbint_LookupGroupMembers */
     307           0 :                 struct wbint_LookupGroupMembers *r2 = (struct wbint_LookupGroupMembers *)r;
     308           0 :                 if (DEBUGLEVEL >= 10) {
     309           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupGroupMembers, NDR_IN, r2);
     310             :                 }
     311           0 :                 NDR_ZERO_STRUCT(r2->out);
     312           0 :                 r2->out.members = talloc_zero(r2, struct wbint_Principals);
     313           0 :                 if (r2->out.members == NULL) {
     314           0 :                         status = NT_STATUS_NO_MEMORY;
     315           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     316           0 :                         goto fail;
     317             :                 }
     318             : 
     319           0 :                 r2->out.result = _wbint_LookupGroupMembers(p, r2);
     320           0 :                 break;
     321             :         }
     322           0 :         case 13: { /* wbint_QueryGroupList */
     323           0 :                 struct wbint_QueryGroupList *r2 = (struct wbint_QueryGroupList *)r;
     324           0 :                 if (DEBUGLEVEL >= 10) {
     325           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QueryGroupList, NDR_IN, r2);
     326             :                 }
     327           0 :                 NDR_ZERO_STRUCT(r2->out);
     328           0 :                 r2->out.groups = talloc_zero(r2, struct wbint_Principals);
     329           0 :                 if (r2->out.groups == NULL) {
     330           0 :                         status = NT_STATUS_NO_MEMORY;
     331           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     332           0 :                         goto fail;
     333             :                 }
     334             : 
     335           0 :                 r2->out.result = _wbint_QueryGroupList(p, r2);
     336           0 :                 break;
     337             :         }
     338           0 :         case 14: { /* wbint_QueryUserRidList */
     339           0 :                 struct wbint_QueryUserRidList *r2 = (struct wbint_QueryUserRidList *)r;
     340           0 :                 if (DEBUGLEVEL >= 10) {
     341           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QueryUserRidList, NDR_IN, r2);
     342             :                 }
     343           0 :                 NDR_ZERO_STRUCT(r2->out);
     344           0 :                 r2->out.rids = talloc_zero(r2, struct wbint_RidArray);
     345           0 :                 if (r2->out.rids == NULL) {
     346           0 :                         status = NT_STATUS_NO_MEMORY;
     347           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     348           0 :                         goto fail;
     349             :                 }
     350             : 
     351           0 :                 r2->out.result = _wbint_QueryUserRidList(p, r2);
     352           0 :                 break;
     353             :         }
     354           0 :         case 15: { /* wbint_DsGetDcName */
     355           0 :                 struct wbint_DsGetDcName *r2 = (struct wbint_DsGetDcName *)r;
     356           0 :                 if (DEBUGLEVEL >= 10) {
     357           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_DsGetDcName, NDR_IN, r2);
     358             :                 }
     359           0 :                 NDR_ZERO_STRUCT(r2->out);
     360           0 :                 r2->out.dc_info = talloc_zero(r2, struct netr_DsRGetDCNameInfo *);
     361           0 :                 if (r2->out.dc_info == NULL) {
     362           0 :                         status = NT_STATUS_NO_MEMORY;
     363           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     364           0 :                         goto fail;
     365             :                 }
     366             : 
     367           0 :                 r2->out.result = _wbint_DsGetDcName(p, r2);
     368           0 :                 break;
     369             :         }
     370           0 :         case 16: { /* wbint_LookupRids */
     371           0 :                 struct wbint_LookupRids *r2 = (struct wbint_LookupRids *)r;
     372           0 :                 if (DEBUGLEVEL >= 10) {
     373           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupRids, NDR_IN, r2);
     374             :                 }
     375           0 :                 NDR_ZERO_STRUCT(r2->out);
     376           0 :                 r2->out.domain_name = talloc_zero(r2, const char *);
     377           0 :                 if (r2->out.domain_name == NULL) {
     378           0 :                         status = NT_STATUS_NO_MEMORY;
     379           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     380           0 :                         goto fail;
     381             :                 }
     382             : 
     383           0 :                 r2->out.names = talloc_zero(r2, struct wbint_Principals);
     384           0 :                 if (r2->out.names == NULL) {
     385           0 :                         status = NT_STATUS_NO_MEMORY;
     386           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     387           0 :                         goto fail;
     388             :                 }
     389             : 
     390           0 :                 r2->out.result = _wbint_LookupRids(p, r2);
     391           0 :                 break;
     392             :         }
     393           0 :         case 17: { /* wbint_CheckMachineAccount */
     394           0 :                 struct wbint_CheckMachineAccount *r2 = (struct wbint_CheckMachineAccount *)r;
     395           0 :                 if (DEBUGLEVEL >= 10) {
     396           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_CheckMachineAccount, NDR_IN, r2);
     397             :                 }
     398           0 :                 r2->out.result = _wbint_CheckMachineAccount(p, r2);
     399           0 :                 break;
     400             :         }
     401           0 :         case 18: { /* wbint_ChangeMachineAccount */
     402           0 :                 struct wbint_ChangeMachineAccount *r2 = (struct wbint_ChangeMachineAccount *)r;
     403           0 :                 if (DEBUGLEVEL >= 10) {
     404           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_ChangeMachineAccount, NDR_IN, r2);
     405             :                 }
     406           0 :                 r2->out.result = _wbint_ChangeMachineAccount(p, r2);
     407           0 :                 break;
     408             :         }
     409           0 :         case 19: { /* wbint_PingDc */
     410           0 :                 struct wbint_PingDc *r2 = (struct wbint_PingDc *)r;
     411           0 :                 if (DEBUGLEVEL >= 10) {
     412           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_PingDc, NDR_IN, r2);
     413             :                 }
     414           0 :                 NDR_ZERO_STRUCT(r2->out);
     415           0 :                 r2->out.dcname = talloc_zero(r2, const char *);
     416           0 :                 if (r2->out.dcname == NULL) {
     417           0 :                         status = NT_STATUS_NO_MEMORY;
     418           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     419           0 :                         goto fail;
     420             :                 }
     421             : 
     422           0 :                 r2->out.result = _wbint_PingDc(p, r2);
     423           0 :                 break;
     424             :         }
     425           0 :         case 20: { /* winbind_SamLogon */
     426           0 :                 struct winbind_SamLogon *r2 = (struct winbind_SamLogon *)r;
     427           0 :                 if (DEBUGLEVEL >= 10) {
     428           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_SamLogon, NDR_IN, r2);
     429             :                 }
     430           0 :                 NDR_ZERO_STRUCT(r2->out);
     431           0 :                 r2->out.result = _winbind_SamLogon(p, r2);
     432           0 :                 break;
     433             :         }
     434           0 :         case 21: { /* winbind_DsrUpdateReadOnlyServerDnsRecords */
     435           0 :                 struct winbind_DsrUpdateReadOnlyServerDnsRecords *r2 = (struct winbind_DsrUpdateReadOnlyServerDnsRecords *)r;
     436           0 :                 if (DEBUGLEVEL >= 10) {
     437           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_DsrUpdateReadOnlyServerDnsRecords, NDR_IN, r2);
     438             :                 }
     439           0 :                 NDR_ZERO_STRUCT(r2->out);
     440           0 :                 r2->out.dns_names = r2->in.dns_names;
     441           0 :                 r2->out.result = _winbind_DsrUpdateReadOnlyServerDnsRecords(p, r2);
     442           0 :                 break;
     443             :         }
     444           0 :         case 22: { /* winbind_LogonControl */
     445           0 :                 struct winbind_LogonControl *r2 = (struct winbind_LogonControl *)r;
     446           0 :                 if (DEBUGLEVEL >= 10) {
     447           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_LogonControl, NDR_IN, r2);
     448             :                 }
     449           0 :                 NDR_ZERO_STRUCT(r2->out);
     450           0 :                 r2->out.query = talloc_zero(r2, union netr_CONTROL_QUERY_INFORMATION);
     451           0 :                 if (r2->out.query == NULL) {
     452           0 :                         status = NT_STATUS_NO_MEMORY;
     453           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     454           0 :                         goto fail;
     455             :                 }
     456             : 
     457           0 :                 r2->out.result = _winbind_LogonControl(p, r2);
     458           0 :                 break;
     459             :         }
     460           0 :         case 23: { /* winbind_GetForestTrustInformation */
     461           0 :                 struct winbind_GetForestTrustInformation *r2 = (struct winbind_GetForestTrustInformation *)r;
     462           0 :                 if (DEBUGLEVEL >= 10) {
     463           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_GetForestTrustInformation, NDR_IN, r2);
     464             :                 }
     465           0 :                 NDR_ZERO_STRUCT(r2->out);
     466           0 :                 r2->out.forest_trust_info = talloc_zero(r2, struct lsa_ForestTrustInformation *);
     467           0 :                 if (r2->out.forest_trust_info == NULL) {
     468           0 :                         status = NT_STATUS_NO_MEMORY;
     469           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     470           0 :                         goto fail;
     471             :                 }
     472             : 
     473           0 :                 r2->out.result = _winbind_GetForestTrustInformation(p, r2);
     474           0 :                 break;
     475             :         }
     476           0 :         case 24: { /* winbind_SendToSam */
     477           0 :                 struct winbind_SendToSam *r2 = (struct winbind_SendToSam *)r;
     478           0 :                 if (DEBUGLEVEL >= 10) {
     479           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_SendToSam, NDR_IN, r2);
     480             :                 }
     481           0 :                 r2->out.result = _winbind_SendToSam(p, r2);
     482           0 :                 break;
     483             :         }
     484           0 :         default:
     485           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     486           0 :                 break;
     487             :         }
     488             : 
     489           0 : fail:
     490             :         /* Unimpersonate */
     491           0 :         if (impersonated) {
     492           0 :                 unbecome_authenticated_pipe_user();
     493             :         }
     494             : 
     495           0 :         p->dce_call = NULL;
     496           0 :         p->mem_ctx = NULL;
     497             :         /* Restore session info */
     498           0 :         p->session_info = pipe_session_info;
     499           0 :         p->auth.auth_type = 0;
     500           0 :         p->auth.auth_level = 0;
     501           0 :         p->auth.auth_context_id = 0;
     502             :         /* Check pipes struct fault state */
     503           0 :         if (p->fault_state != 0) {
     504           0 :                 dce_call->fault_code = p->fault_state;
     505             :         }
     506           0 :         if (dce_call->fault_code != 0) {
     507           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     508             :         }
     509             : 
     510           0 :         return status;
     511             : }
     512             : 
     513           0 : NTSTATUS winbind__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     514             : {
     515           0 :         return winbind__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     516             : }
     517             : 
     518           0 : NTSTATUS winbind__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     519             : {
     520           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     521             : 
     522           0 :         switch (opnum) {
     523           0 :         case 0: { /* wbint_Ping */
     524           0 :                 struct wbint_Ping *r2 = (struct wbint_Ping *)r;
     525           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     526           0 :                         DEBUG(5,("function wbint_Ping replied async\n"));
     527             :                 }
     528           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     529           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_Ping, NDR_OUT | NDR_SET_VALUES, r2);
     530             :                 }
     531           0 :                 if (dce_call->fault_code != 0) {
     532           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_Ping\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     533             :                 }
     534           0 :                 break;
     535             :         }
     536           0 :         case 1: { /* wbint_LookupSid */
     537           0 :                 struct wbint_LookupSid *r2 = (struct wbint_LookupSid *)r;
     538           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     539           0 :                         DEBUG(5,("function wbint_LookupSid replied async\n"));
     540             :                 }
     541           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     542           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupSid, NDR_OUT | NDR_SET_VALUES, r2);
     543             :                 }
     544           0 :                 if (dce_call->fault_code != 0) {
     545           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupSid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     546             :                 }
     547           0 :                 break;
     548             :         }
     549           0 :         case 2: { /* wbint_LookupSids */
     550           0 :                 struct wbint_LookupSids *r2 = (struct wbint_LookupSids *)r;
     551           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     552           0 :                         DEBUG(5,("function wbint_LookupSids replied async\n"));
     553             :                 }
     554           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     555           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupSids, NDR_OUT | NDR_SET_VALUES, r2);
     556             :                 }
     557           0 :                 if (dce_call->fault_code != 0) {
     558           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupSids\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     559             :                 }
     560           0 :                 break;
     561             :         }
     562           0 :         case 3: { /* wbint_LookupName */
     563           0 :                 struct wbint_LookupName *r2 = (struct wbint_LookupName *)r;
     564           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     565           0 :                         DEBUG(5,("function wbint_LookupName replied async\n"));
     566             :                 }
     567           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     568           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupName, NDR_OUT | NDR_SET_VALUES, r2);
     569             :                 }
     570           0 :                 if (dce_call->fault_code != 0) {
     571           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupName\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     572             :                 }
     573           0 :                 break;
     574             :         }
     575           0 :         case 4: { /* wbint_Sids2UnixIDs */
     576           0 :                 struct wbint_Sids2UnixIDs *r2 = (struct wbint_Sids2UnixIDs *)r;
     577           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     578           0 :                         DEBUG(5,("function wbint_Sids2UnixIDs replied async\n"));
     579             :                 }
     580           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     581           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_Sids2UnixIDs, NDR_OUT | NDR_SET_VALUES, r2);
     582             :                 }
     583           0 :                 if (dce_call->fault_code != 0) {
     584           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_Sids2UnixIDs\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     585             :                 }
     586           0 :                 break;
     587             :         }
     588           0 :         case 5: { /* wbint_UnixIDs2Sids */
     589           0 :                 struct wbint_UnixIDs2Sids *r2 = (struct wbint_UnixIDs2Sids *)r;
     590           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     591           0 :                         DEBUG(5,("function wbint_UnixIDs2Sids replied async\n"));
     592             :                 }
     593           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     594           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_UnixIDs2Sids, NDR_OUT | NDR_SET_VALUES, r2);
     595             :                 }
     596           0 :                 if (dce_call->fault_code != 0) {
     597           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_UnixIDs2Sids\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     598             :                 }
     599           0 :                 break;
     600             :         }
     601           0 :         case 6: { /* wbint_AllocateUid */
     602           0 :                 struct wbint_AllocateUid *r2 = (struct wbint_AllocateUid *)r;
     603           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     604           0 :                         DEBUG(5,("function wbint_AllocateUid replied async\n"));
     605             :                 }
     606           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     607           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_AllocateUid, NDR_OUT | NDR_SET_VALUES, r2);
     608             :                 }
     609           0 :                 if (dce_call->fault_code != 0) {
     610           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_AllocateUid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     611             :                 }
     612           0 :                 break;
     613             :         }
     614           0 :         case 7: { /* wbint_AllocateGid */
     615           0 :                 struct wbint_AllocateGid *r2 = (struct wbint_AllocateGid *)r;
     616           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     617           0 :                         DEBUG(5,("function wbint_AllocateGid replied async\n"));
     618             :                 }
     619           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     620           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_AllocateGid, NDR_OUT | NDR_SET_VALUES, r2);
     621             :                 }
     622           0 :                 if (dce_call->fault_code != 0) {
     623           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_AllocateGid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     624             :                 }
     625           0 :                 break;
     626             :         }
     627           0 :         case 8: { /* wbint_GetNssInfo */
     628           0 :                 struct wbint_GetNssInfo *r2 = (struct wbint_GetNssInfo *)r;
     629           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     630           0 :                         DEBUG(5,("function wbint_GetNssInfo replied async\n"));
     631             :                 }
     632           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     633           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_GetNssInfo, NDR_OUT | NDR_SET_VALUES, r2);
     634             :                 }
     635           0 :                 if (dce_call->fault_code != 0) {
     636           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_GetNssInfo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     637             :                 }
     638           0 :                 break;
     639             :         }
     640           0 :         case 9: { /* wbint_LookupUserAliases */
     641           0 :                 struct wbint_LookupUserAliases *r2 = (struct wbint_LookupUserAliases *)r;
     642           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     643           0 :                         DEBUG(5,("function wbint_LookupUserAliases replied async\n"));
     644             :                 }
     645           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     646           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupUserAliases, NDR_OUT | NDR_SET_VALUES, r2);
     647             :                 }
     648           0 :                 if (dce_call->fault_code != 0) {
     649           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupUserAliases\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     650             :                 }
     651           0 :                 break;
     652             :         }
     653           0 :         case 10: { /* wbint_LookupUserGroups */
     654           0 :                 struct wbint_LookupUserGroups *r2 = (struct wbint_LookupUserGroups *)r;
     655           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     656           0 :                         DEBUG(5,("function wbint_LookupUserGroups replied async\n"));
     657             :                 }
     658           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     659           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupUserGroups, NDR_OUT | NDR_SET_VALUES, r2);
     660             :                 }
     661           0 :                 if (dce_call->fault_code != 0) {
     662           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupUserGroups\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     663             :                 }
     664           0 :                 break;
     665             :         }
     666           0 :         case 11: { /* wbint_QuerySequenceNumber */
     667           0 :                 struct wbint_QuerySequenceNumber *r2 = (struct wbint_QuerySequenceNumber *)r;
     668           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     669           0 :                         DEBUG(5,("function wbint_QuerySequenceNumber replied async\n"));
     670             :                 }
     671           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     672           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QuerySequenceNumber, NDR_OUT | NDR_SET_VALUES, r2);
     673             :                 }
     674           0 :                 if (dce_call->fault_code != 0) {
     675           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_QuerySequenceNumber\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     676             :                 }
     677           0 :                 break;
     678             :         }
     679           0 :         case 12: { /* wbint_LookupGroupMembers */
     680           0 :                 struct wbint_LookupGroupMembers *r2 = (struct wbint_LookupGroupMembers *)r;
     681           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     682           0 :                         DEBUG(5,("function wbint_LookupGroupMembers replied async\n"));
     683             :                 }
     684           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     685           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupGroupMembers, NDR_OUT | NDR_SET_VALUES, r2);
     686             :                 }
     687           0 :                 if (dce_call->fault_code != 0) {
     688           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupGroupMembers\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     689             :                 }
     690           0 :                 break;
     691             :         }
     692           0 :         case 13: { /* wbint_QueryGroupList */
     693           0 :                 struct wbint_QueryGroupList *r2 = (struct wbint_QueryGroupList *)r;
     694           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     695           0 :                         DEBUG(5,("function wbint_QueryGroupList replied async\n"));
     696             :                 }
     697           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     698           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QueryGroupList, NDR_OUT | NDR_SET_VALUES, r2);
     699             :                 }
     700           0 :                 if (dce_call->fault_code != 0) {
     701           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_QueryGroupList\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     702             :                 }
     703           0 :                 break;
     704             :         }
     705           0 :         case 14: { /* wbint_QueryUserRidList */
     706           0 :                 struct wbint_QueryUserRidList *r2 = (struct wbint_QueryUserRidList *)r;
     707           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     708           0 :                         DEBUG(5,("function wbint_QueryUserRidList replied async\n"));
     709             :                 }
     710           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     711           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_QueryUserRidList, NDR_OUT | NDR_SET_VALUES, r2);
     712             :                 }
     713           0 :                 if (dce_call->fault_code != 0) {
     714           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_QueryUserRidList\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     715             :                 }
     716           0 :                 break;
     717             :         }
     718           0 :         case 15: { /* wbint_DsGetDcName */
     719           0 :                 struct wbint_DsGetDcName *r2 = (struct wbint_DsGetDcName *)r;
     720           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     721           0 :                         DEBUG(5,("function wbint_DsGetDcName replied async\n"));
     722             :                 }
     723           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     724           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_DsGetDcName, NDR_OUT | NDR_SET_VALUES, r2);
     725             :                 }
     726           0 :                 if (dce_call->fault_code != 0) {
     727           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_DsGetDcName\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     728             :                 }
     729           0 :                 break;
     730             :         }
     731           0 :         case 16: { /* wbint_LookupRids */
     732           0 :                 struct wbint_LookupRids *r2 = (struct wbint_LookupRids *)r;
     733           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     734           0 :                         DEBUG(5,("function wbint_LookupRids replied async\n"));
     735             :                 }
     736           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     737           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_LookupRids, NDR_OUT | NDR_SET_VALUES, r2);
     738             :                 }
     739           0 :                 if (dce_call->fault_code != 0) {
     740           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_LookupRids\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     741             :                 }
     742           0 :                 break;
     743             :         }
     744           0 :         case 17: { /* wbint_CheckMachineAccount */
     745           0 :                 struct wbint_CheckMachineAccount *r2 = (struct wbint_CheckMachineAccount *)r;
     746           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     747           0 :                         DEBUG(5,("function wbint_CheckMachineAccount replied async\n"));
     748             :                 }
     749           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     750           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_CheckMachineAccount, NDR_OUT | NDR_SET_VALUES, r2);
     751             :                 }
     752           0 :                 if (dce_call->fault_code != 0) {
     753           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_CheckMachineAccount\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     754             :                 }
     755           0 :                 break;
     756             :         }
     757           0 :         case 18: { /* wbint_ChangeMachineAccount */
     758           0 :                 struct wbint_ChangeMachineAccount *r2 = (struct wbint_ChangeMachineAccount *)r;
     759           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     760           0 :                         DEBUG(5,("function wbint_ChangeMachineAccount replied async\n"));
     761             :                 }
     762           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     763           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_ChangeMachineAccount, NDR_OUT | NDR_SET_VALUES, r2);
     764             :                 }
     765           0 :                 if (dce_call->fault_code != 0) {
     766           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_ChangeMachineAccount\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     767             :                 }
     768           0 :                 break;
     769             :         }
     770           0 :         case 19: { /* wbint_PingDc */
     771           0 :                 struct wbint_PingDc *r2 = (struct wbint_PingDc *)r;
     772           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     773           0 :                         DEBUG(5,("function wbint_PingDc replied async\n"));
     774             :                 }
     775           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     776           0 :                         NDR_PRINT_FUNCTION_DEBUG(wbint_PingDc, NDR_OUT | NDR_SET_VALUES, r2);
     777             :                 }
     778           0 :                 if (dce_call->fault_code != 0) {
     779           0 :                         DBG_WARNING("dcerpc_fault %s in wbint_PingDc\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     780             :                 }
     781           0 :                 break;
     782             :         }
     783           0 :         case 20: { /* winbind_SamLogon */
     784           0 :                 struct winbind_SamLogon *r2 = (struct winbind_SamLogon *)r;
     785           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     786           0 :                         DEBUG(5,("function winbind_SamLogon replied async\n"));
     787             :                 }
     788           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     789           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_SamLogon, NDR_OUT | NDR_SET_VALUES, r2);
     790             :                 }
     791           0 :                 if (dce_call->fault_code != 0) {
     792           0 :                         DBG_WARNING("dcerpc_fault %s in winbind_SamLogon\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     793             :                 }
     794           0 :                 break;
     795             :         }
     796           0 :         case 21: { /* winbind_DsrUpdateReadOnlyServerDnsRecords */
     797           0 :                 struct winbind_DsrUpdateReadOnlyServerDnsRecords *r2 = (struct winbind_DsrUpdateReadOnlyServerDnsRecords *)r;
     798           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     799           0 :                         DEBUG(5,("function winbind_DsrUpdateReadOnlyServerDnsRecords replied async\n"));
     800             :                 }
     801           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     802           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_DsrUpdateReadOnlyServerDnsRecords, NDR_OUT | NDR_SET_VALUES, r2);
     803             :                 }
     804           0 :                 if (dce_call->fault_code != 0) {
     805           0 :                         DBG_WARNING("dcerpc_fault %s in winbind_DsrUpdateReadOnlyServerDnsRecords\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     806             :                 }
     807           0 :                 break;
     808             :         }
     809           0 :         case 22: { /* winbind_LogonControl */
     810           0 :                 struct winbind_LogonControl *r2 = (struct winbind_LogonControl *)r;
     811           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     812           0 :                         DEBUG(5,("function winbind_LogonControl replied async\n"));
     813             :                 }
     814           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     815           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_LogonControl, NDR_OUT | NDR_SET_VALUES, r2);
     816             :                 }
     817           0 :                 if (dce_call->fault_code != 0) {
     818           0 :                         DBG_WARNING("dcerpc_fault %s in winbind_LogonControl\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     819             :                 }
     820           0 :                 break;
     821             :         }
     822           0 :         case 23: { /* winbind_GetForestTrustInformation */
     823           0 :                 struct winbind_GetForestTrustInformation *r2 = (struct winbind_GetForestTrustInformation *)r;
     824           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     825           0 :                         DEBUG(5,("function winbind_GetForestTrustInformation replied async\n"));
     826             :                 }
     827           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     828           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_GetForestTrustInformation, NDR_OUT | NDR_SET_VALUES, r2);
     829             :                 }
     830           0 :                 if (dce_call->fault_code != 0) {
     831           0 :                         DBG_WARNING("dcerpc_fault %s in winbind_GetForestTrustInformation\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     832             :                 }
     833           0 :                 break;
     834             :         }
     835           0 :         case 24: { /* winbind_SendToSam */
     836           0 :                 struct winbind_SendToSam *r2 = (struct winbind_SendToSam *)r;
     837           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     838           0 :                         DEBUG(5,("function winbind_SendToSam replied async\n"));
     839             :                 }
     840           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     841           0 :                         NDR_PRINT_FUNCTION_DEBUG(winbind_SendToSam, NDR_OUT | NDR_SET_VALUES, r2);
     842             :                 }
     843           0 :                 if (dce_call->fault_code != 0) {
     844           0 :                         DBG_WARNING("dcerpc_fault %s in winbind_SendToSam\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     845             :                 }
     846           0 :                 break;
     847             :         }
     848           0 :         default:
     849           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     850           0 :                 break;
     851             :         }
     852             : 
     853           0 :         if (dce_call->fault_code != 0) {
     854           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     855             :         }
     856             : 
     857           0 :         return NT_STATUS_OK;
     858             : }
     859             : 
     860           0 : NTSTATUS winbind__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     861             : {
     862             :         enum ndr_err_code ndr_err;
     863           0 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     864             : 
     865           0 :         ndr_err = ndr_table_winbind.calls[opnum].ndr_push(push, NDR_OUT, r);
     866           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     867           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     868           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     869             :         }
     870             : 
     871           0 :         return NT_STATUS_OK;
     872             : }
     873             : 
     874           0 : NTSTATUS winbind__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     875             : {
     876           0 :         return winbind__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     877             : }
     878             : 
     879             : static const struct dcesrv_interface dcesrv_winbind_interface = {
     880             :         .name      = "winbind",
     881             :         .syntax_id = {{0xbf09192c,0xed60,0x4928,{0x9d,0xff},{0xd0,0xd7,0xbc,0xb0,0x3e,0xd8}},1.0},
     882             :         .bind      = winbind__op_bind,
     883             :         .unbind    = winbind__op_unbind,
     884             :         .ndr_pull  = winbind__op_ndr_pull,
     885             :         .dispatch  = winbind__op_dispatch,
     886             :         .reply     = winbind__op_reply,
     887             :         .ndr_push  = winbind__op_ndr_push,
     888             :         .local     = winbind__op_local,
     889             : #ifdef DCESRV_INTERFACE_WINBIND_FLAGS
     890             :         .flags     = DCESRV_INTERFACE_WINBIND_FLAGS
     891             : #else
     892             :         .flags     = 0
     893             : #endif
     894             : };
     895             : 
     896          73 : static NTSTATUS winbind__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
     897          73 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
     898             :         NTSTATUS status;
     899             : 
     900             :         /* If service is disabled, do not register */
     901          73 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
     902           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
     903             :         }
     904             : 
     905             :         /* If service is embedded, register only for ncacn_np
     906             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
     907             :          */
     908          73 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
     909           0 :                 DBG_INFO("Interface 'winbind' not registered in endpoint '%s' as service is embedded\n", name);
     910           0 :                 return NT_STATUS_NOT_SUPPORTED;
     911             :         }
     912             : 
     913             :         /*
     914             :          * If rpc service is external then change the default ncalrpc endpoint,
     915             :          * otherwise if the rpc daemon running this service is configured in
     916             :          * fork mode the forked process will race with main smbd to accept the
     917             :          * connections in the default ncalrpc socket, and the forked process
     918             :          * may not have the requested interface registered.
     919             :          * For example, in the ad_member test environment:
     920             :          *
     921             :          *   rpc_server:lsarpc = external
     922             :          *   rpc_server:samr = external
     923             :          *   rpc_server:netlogon = disabled
     924             :          *   rpc_daemon:lsasd = fork
     925             :          *
     926             :          * With these settings both, the main smbd and all the preforked lsasd
     927             :          * processes would be listening in the default ncalrpc socket if it is
     928             :          * not changed. If a client connection is accepted by one of the lsasd
     929             :          * worker processes and the client asks for an interface not registered
     930             :          * in these processes (winreg for example) it will get an error.
     931             :          */
     932          73 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
     933          43 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "WINBIND");
     934          43 :                 if (!NT_STATUS_IS_OK(status)) {
     935           0 :                         return status;
     936             :                 }
     937             :         }
     938             : 
     939          73 :         return NT_STATUS_OK;
     940             : }
     941             : 
     942          73 : static NTSTATUS winbind__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     943             : {
     944             :         uint32_t i;
     945             :         NTSTATUS ret;
     946             :         struct dcerpc_binding *binding;
     947          73 :         struct dcerpc_binding *binding2 = NULL;
     948             : 
     949             : #ifdef DCESRV_INTERFACE_WINBIND_NCACN_NP_SECONDARY_ENDPOINT
     950             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_WINBIND_NCACN_NP_SECONDARY_ENDPOINT;
     951             : #else
     952          73 :         const char *ncacn_np_secondary_endpoint = NULL;
     953             : #endif
     954             : 
     955         146 :         for (i=0;i<ndr_table_winbind.endpoints->count;i++) {
     956          73 :                 const char *name = ndr_table_winbind.endpoints->names[i];
     957             : 
     958          73 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
     959          73 :                 if (NT_STATUS_IS_ERR(ret)) {
     960           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
     961           0 :                         return ret;
     962             :                 }
     963             : 
     964          73 :                 ret = winbind__check_register_in_endpoint("winbind", binding);
     965          73 :                 if (NT_STATUS_IS_ERR(ret)) {
     966           0 :                         talloc_free(binding);
     967           0 :                         continue;
     968             :                 }
     969             : 
     970          71 :                 if (ncacn_np_secondary_endpoint != NULL) {
     971           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
     972           0 :                         if (NT_STATUS_IS_ERR(ret)) {
     973           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
     974           0 :                                 TALLOC_FREE(binding);
     975           0 :                                 return ret;
     976             :                         }
     977             :                 }
     978             : 
     979          73 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_winbind_interface, NULL);
     980          73 :                 TALLOC_FREE(binding);
     981          71 :                 TALLOC_FREE(binding2);
     982          73 :                 if (!NT_STATUS_IS_OK(ret)) {
     983           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     984           0 :                         return ret;
     985             :                 }
     986             :         }
     987             : 
     988          73 :         return NT_STATUS_OK;
     989             : }
     990             : 
     991           0 : static NTSTATUS winbind__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     992             : {
     993           0 :         return NT_STATUS_OK;
     994             : }
     995             : 
     996           0 : static bool winbind__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     997             : {
     998           0 :         if (dcesrv_winbind_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_winbind_interface.syntax_id.uuid, uuid)) {
     999           0 :                 memcpy(iface,&dcesrv_winbind_interface, sizeof(*iface));
    1000           0 :                 return true;
    1001             :         }
    1002             : 
    1003           0 :         return false;
    1004             : }
    1005             : 
    1006           0 : static bool winbind__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
    1007             : {
    1008           0 :         if (strcmp(dcesrv_winbind_interface.name, name)==0) {
    1009           0 :                 memcpy(iface, &dcesrv_winbind_interface, sizeof(*iface));
    1010           0 :                 return true;
    1011             :         }
    1012             : 
    1013           0 :         return false;
    1014             : }
    1015             : 
    1016             : static const struct dcesrv_endpoint_server winbind_ep_server = {
    1017             :         /* fill in our name */
    1018             :         .name = "winbind",
    1019             : 
    1020             :         /* Initialization flag */
    1021             :         .initialized = false,
    1022             : 
    1023             :         /* fill in all the operations */
    1024             : #ifdef DCESRV_INTERFACE_WINBIND_INIT_SERVER
    1025             :         .init_server = DCESRV_INTERFACE_WINBIND_INIT_SERVER,
    1026             : #else
    1027             :         .init_server = winbind__op_init_server,
    1028             : #endif
    1029             : #ifdef DCESRV_INTERFACE_WINBIND_SHUTDOWN_SERVER
    1030             :         .shutdown_server = DCESRV_INTERFACE_WINBIND_SHUTDOWN_SERVER,
    1031             : #else
    1032             :         .shutdown_server = winbind__op_shutdown_server,
    1033             : #endif
    1034             :         .interface_by_uuid = winbind__op_interface_by_uuid,
    1035             :         .interface_by_name = winbind__op_interface_by_name
    1036             : };
    1037             : 
    1038          73 : const struct dcesrv_endpoint_server *winbind_get_ep_server(void)
    1039             : {
    1040          73 :         return &winbind_ep_server;
    1041             : }

Generated by: LCOV version 1.13