LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_fsrvp_scompat.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 223 378 59.0 %
Date: 2021-09-23 10:06:22 Functions: 10 15 66.7 %

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_fsrvp.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_fsrvp_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             : /* FileServerVssAgent - dcerpc server boilerplate generated by pidl */
      15           2 : static NTSTATUS FileServerVssAgent__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      16             : {
      17           2 :         struct pipes_struct *p = NULL;
      18             : 
      19             :         /* Retrieve pipes struct */
      20           2 :         p = dcesrv_get_pipes_struct(context->conn);
      21           2 :         p->pipe_bound = true;
      22             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_BIND
      23             :         return DCESRV_INTERFACE_FILESERVERVSSAGENT_BIND(context,iface);
      24             : #else
      25           2 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29           1 : static void FileServerVssAgent__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_UNBIND
      32             :         DCESRV_INTERFACE_FILESERVERVSSAGENT_UNBIND(context, iface);
      33             : #else
      34           1 :         return;
      35             : #endif
      36             : }
      37             : 
      38         237 : NTSTATUS FileServerVssAgent__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         237 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      42             : 
      43         237 :         dce_call->fault_code = 0;
      44             : 
      45         237 :         if (opnum >= ndr_table_FileServerVssAgent.num_calls) {
      46           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      47           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      48             :         }
      49             : 
      50         237 :         *r = talloc_named(mem_ctx, ndr_table_FileServerVssAgent.calls[opnum].struct_size, "struct %s", ndr_table_FileServerVssAgent.calls[opnum].name);
      51         237 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      52             : 
      53             :         /* unravel the NDR for the packet */
      54         237 :         ndr_err = ndr_table_FileServerVssAgent.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      55         237 :         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         237 :         return NT_STATUS_OK;
      61             : }
      62             : 
      63         237 : static NTSTATUS FileServerVssAgent__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
      64             : {
      65         237 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      66         237 :         struct pipes_struct *p = NULL;
      67         237 :         struct auth_session_info *pipe_session_info = NULL;
      68         237 :         NTSTATUS status = NT_STATUS_OK;
      69         237 :         bool impersonated = false;
      70             : 
      71             :         /* Retrieve pipes struct */
      72         237 :         p = dcesrv_get_pipes_struct(dce_call->conn);
      73             :         /* Update pipes struct opnum */
      74         237 :         p->opnum = opnum;
      75         237 :         p->dce_call = dce_call;
      76         237 :         p->mem_ctx = mem_ctx;
      77             :         /* Update pipes struct session info */
      78         237 :         pipe_session_info = p->session_info;
      79         237 :         p->session_info = dce_call->auth_state->session_info;
      80         237 :         p->auth.auth_type = dce_call->auth_state->auth_type;
      81         237 :         p->auth.auth_level = dce_call->auth_state->auth_level;
      82         237 :         p->auth.auth_context_id = dce_call->auth_state->auth_context_id;
      83             :         /* Reset pipes struct fault state */
      84         237 :         p->fault_state = 0;
      85             : 
      86             :         /* Impersonate */
      87         237 :         if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
      88         237 :                 impersonated = become_authenticated_pipe_user(p->session_info);
      89         237 :                 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         237 :         switch (opnum) {
      97          28 :         case 0: { /* fss_GetSupportedVersion */
      98          28 :                 struct fss_GetSupportedVersion *r2 = (struct fss_GetSupportedVersion *)r;
      99          28 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_GetSupportedVersion, NDR_IN, r2);
     101             :                 }
     102          28 :                 NDR_ZERO_STRUCT(r2->out);
     103          28 :                 r2->out.MinVersion = talloc_zero(r2, uint32_t);
     104          28 :                 if (r2->out.MinVersion == NULL) {
     105           0 :                         status = NT_STATUS_NO_MEMORY;
     106           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     107           0 :                         goto fail;
     108             :                 }
     109             : 
     110          28 :                 r2->out.MaxVersion = talloc_zero(r2, uint32_t);
     111          28 :                 if (r2->out.MaxVersion == NULL) {
     112           0 :                         status = NT_STATUS_NO_MEMORY;
     113           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     114           0 :                         goto fail;
     115             :                 }
     116             : 
     117          28 :                 r2->out.result = _fss_GetSupportedVersion(p, r2);
     118          28 :                 break;
     119             :         }
     120          28 :         case 1: { /* fss_SetContext */
     121          28 :                 struct fss_SetContext *r2 = (struct fss_SetContext *)r;
     122          28 :                 if (DEBUGLEVEL >= 10) {
     123           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_SetContext, NDR_IN, r2);
     124             :                 }
     125          28 :                 r2->out.result = _fss_SetContext(p, r2);
     126          28 :                 break;
     127             :         }
     128          26 :         case 2: { /* fss_StartShadowCopySet */
     129          26 :                 struct fss_StartShadowCopySet *r2 = (struct fss_StartShadowCopySet *)r;
     130          26 :                 if (DEBUGLEVEL >= 10) {
     131           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_StartShadowCopySet, NDR_IN, r2);
     132             :                 }
     133          26 :                 NDR_ZERO_STRUCT(r2->out);
     134          26 :                 r2->out.pShadowCopySetId = talloc_zero(r2, struct GUID);
     135          26 :                 if (r2->out.pShadowCopySetId == NULL) {
     136           0 :                         status = NT_STATUS_NO_MEMORY;
     137           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     138           0 :                         goto fail;
     139             :                 }
     140             : 
     141          26 :                 r2->out.result = _fss_StartShadowCopySet(p, r2);
     142          26 :                 break;
     143             :         }
     144          44 :         case 3: { /* fss_AddToShadowCopySet */
     145          44 :                 struct fss_AddToShadowCopySet *r2 = (struct fss_AddToShadowCopySet *)r;
     146          44 :                 if (DEBUGLEVEL >= 10) {
     147           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_AddToShadowCopySet, NDR_IN, r2);
     148             :                 }
     149          44 :                 NDR_ZERO_STRUCT(r2->out);
     150          44 :                 r2->out.pShadowCopyId = talloc_zero(r2, struct GUID);
     151          44 :                 if (r2->out.pShadowCopyId == NULL) {
     152           0 :                         status = NT_STATUS_NO_MEMORY;
     153           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     154           0 :                         goto fail;
     155             :                 }
     156             : 
     157          44 :                 r2->out.result = _fss_AddToShadowCopySet(p, r2);
     158          44 :                 break;
     159             :         }
     160          18 :         case 4: { /* fss_CommitShadowCopySet */
     161          18 :                 struct fss_CommitShadowCopySet *r2 = (struct fss_CommitShadowCopySet *)r;
     162          18 :                 if (DEBUGLEVEL >= 10) {
     163           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_CommitShadowCopySet, NDR_IN, r2);
     164             :                 }
     165          18 :                 r2->out.result = _fss_CommitShadowCopySet(p, r2);
     166          17 :                 break;
     167             :         }
     168          15 :         case 5: { /* fss_ExposeShadowCopySet */
     169          15 :                 struct fss_ExposeShadowCopySet *r2 = (struct fss_ExposeShadowCopySet *)r;
     170          15 :                 if (DEBUGLEVEL >= 10) {
     171           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_ExposeShadowCopySet, NDR_IN, r2);
     172             :                 }
     173          15 :                 r2->out.result = _fss_ExposeShadowCopySet(p, r2);
     174          15 :                 break;
     175             :         }
     176           0 :         case 6: { /* fss_RecoveryCompleteShadowCopySet */
     177           0 :                 struct fss_RecoveryCompleteShadowCopySet *r2 = (struct fss_RecoveryCompleteShadowCopySet *)r;
     178           0 :                 if (DEBUGLEVEL >= 10) {
     179           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_RecoveryCompleteShadowCopySet, NDR_IN, r2);
     180             :                 }
     181           0 :                 r2->out.result = _fss_RecoveryCompleteShadowCopySet(p, r2);
     182           0 :                 break;
     183             :         }
     184           2 :         case 7: { /* fss_AbortShadowCopySet */
     185           2 :                 struct fss_AbortShadowCopySet *r2 = (struct fss_AbortShadowCopySet *)r;
     186           2 :                 if (DEBUGLEVEL >= 10) {
     187           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_AbortShadowCopySet, NDR_IN, r2);
     188             :                 }
     189           2 :                 r2->out.result = _fss_AbortShadowCopySet(p, r2);
     190           2 :                 break;
     191             :         }
     192          28 :         case 8: { /* fss_IsPathSupported */
     193          28 :                 struct fss_IsPathSupported *r2 = (struct fss_IsPathSupported *)r;
     194          28 :                 if (DEBUGLEVEL >= 10) {
     195           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_IsPathSupported, NDR_IN, r2);
     196             :                 }
     197          28 :                 NDR_ZERO_STRUCT(r2->out);
     198          28 :                 r2->out.SupportedByThisProvider = talloc_zero(r2, uint32_t);
     199          28 :                 if (r2->out.SupportedByThisProvider == NULL) {
     200           0 :                         status = NT_STATUS_NO_MEMORY;
     201           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     202           0 :                         goto fail;
     203             :                 }
     204             : 
     205          28 :                 r2->out.OwnerMachineName = talloc_zero(r2, const char *);
     206          28 :                 if (r2->out.OwnerMachineName == NULL) {
     207           0 :                         status = NT_STATUS_NO_MEMORY;
     208           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     209           0 :                         goto fail;
     210             :                 }
     211             : 
     212          28 :                 r2->out.result = _fss_IsPathSupported(p, r2);
     213          28 :                 break;
     214             :         }
     215           0 :         case 9: { /* fss_IsPathShadowCopied */
     216           0 :                 struct fss_IsPathShadowCopied *r2 = (struct fss_IsPathShadowCopied *)r;
     217           0 :                 if (DEBUGLEVEL >= 10) {
     218           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_IsPathShadowCopied, NDR_IN, r2);
     219             :                 }
     220           0 :                 NDR_ZERO_STRUCT(r2->out);
     221           0 :                 r2->out.ShadowCopyPresent = talloc_zero(r2, uint32_t);
     222           0 :                 if (r2->out.ShadowCopyPresent == NULL) {
     223           0 :                         status = NT_STATUS_NO_MEMORY;
     224           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     225           0 :                         goto fail;
     226             :                 }
     227             : 
     228           0 :                 r2->out.ShadowCopyCompatibility = talloc_zero(r2, int32_t);
     229           0 :                 if (r2->out.ShadowCopyCompatibility == NULL) {
     230           0 :                         status = NT_STATUS_NO_MEMORY;
     231           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     232           0 :                         goto fail;
     233             :                 }
     234             : 
     235           0 :                 r2->out.result = _fss_IsPathShadowCopied(p, r2);
     236           0 :                 break;
     237             :         }
     238          14 :         case 10: { /* fss_GetShareMapping */
     239          14 :                 struct fss_GetShareMapping *r2 = (struct fss_GetShareMapping *)r;
     240          14 :                 if (DEBUGLEVEL >= 10) {
     241           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_GetShareMapping, NDR_IN, r2);
     242             :                 }
     243          14 :                 NDR_ZERO_STRUCT(r2->out);
     244          14 :                 r2->out.ShareMapping = talloc_zero(r2, union fssagent_share_mapping);
     245          14 :                 if (r2->out.ShareMapping == NULL) {
     246           0 :                         status = NT_STATUS_NO_MEMORY;
     247           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     248           0 :                         goto fail;
     249             :                 }
     250             : 
     251          14 :                 r2->out.result = _fss_GetShareMapping(p, r2);
     252          14 :                 break;
     253             :         }
     254          14 :         case 11: { /* fss_DeleteShareMapping */
     255          14 :                 struct fss_DeleteShareMapping *r2 = (struct fss_DeleteShareMapping *)r;
     256          14 :                 if (DEBUGLEVEL >= 10) {
     257           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_DeleteShareMapping, NDR_IN, r2);
     258             :                 }
     259          14 :                 r2->out.result = _fss_DeleteShareMapping(p, r2);
     260          14 :                 break;
     261             :         }
     262          20 :         case 12: { /* fss_PrepareShadowCopySet */
     263          20 :                 struct fss_PrepareShadowCopySet *r2 = (struct fss_PrepareShadowCopySet *)r;
     264          20 :                 if (DEBUGLEVEL >= 10) {
     265           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_PrepareShadowCopySet, NDR_IN, r2);
     266             :                 }
     267          20 :                 r2->out.result = _fss_PrepareShadowCopySet(p, r2);
     268          20 :                 break;
     269             :         }
     270           0 :         default:
     271           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     272           0 :                 break;
     273             :         }
     274             : 
     275         236 : fail:
     276             :         /* Unimpersonate */
     277         236 :         if (impersonated) {
     278         236 :                 unbecome_authenticated_pipe_user();
     279             :         }
     280             : 
     281         236 :         p->dce_call = NULL;
     282         236 :         p->mem_ctx = NULL;
     283             :         /* Restore session info */
     284         236 :         p->session_info = pipe_session_info;
     285         236 :         p->auth.auth_type = 0;
     286         236 :         p->auth.auth_level = 0;
     287         236 :         p->auth.auth_context_id = 0;
     288             :         /* Check pipes struct fault state */
     289         236 :         if (p->fault_state != 0) {
     290           0 :                 dce_call->fault_code = p->fault_state;
     291             :         }
     292         236 :         if (dce_call->fault_code != 0) {
     293           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     294             :         }
     295             : 
     296         236 :         return status;
     297             : }
     298             : 
     299         237 : NTSTATUS FileServerVssAgent__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     300             : {
     301         237 :         return FileServerVssAgent__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     302             : }
     303             : 
     304         236 : NTSTATUS FileServerVssAgent__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     305             : {
     306         236 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     307             : 
     308         236 :         switch (opnum) {
     309          28 :         case 0: { /* fss_GetSupportedVersion */
     310          28 :                 struct fss_GetSupportedVersion *r2 = (struct fss_GetSupportedVersion *)r;
     311          28 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     312           0 :                         DEBUG(5,("function fss_GetSupportedVersion replied async\n"));
     313             :                 }
     314          28 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     315           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_GetSupportedVersion, NDR_OUT | NDR_SET_VALUES, r2);
     316             :                 }
     317          28 :                 if (dce_call->fault_code != 0) {
     318           0 :                         DBG_WARNING("dcerpc_fault %s in fss_GetSupportedVersion\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     319             :                 }
     320          28 :                 break;
     321             :         }
     322          28 :         case 1: { /* fss_SetContext */
     323          28 :                 struct fss_SetContext *r2 = (struct fss_SetContext *)r;
     324          28 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     325           0 :                         DEBUG(5,("function fss_SetContext replied async\n"));
     326             :                 }
     327          28 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     328           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_SetContext, NDR_OUT | NDR_SET_VALUES, r2);
     329             :                 }
     330          28 :                 if (dce_call->fault_code != 0) {
     331           0 :                         DBG_WARNING("dcerpc_fault %s in fss_SetContext\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     332             :                 }
     333          28 :                 break;
     334             :         }
     335          26 :         case 2: { /* fss_StartShadowCopySet */
     336          26 :                 struct fss_StartShadowCopySet *r2 = (struct fss_StartShadowCopySet *)r;
     337          26 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     338           0 :                         DEBUG(5,("function fss_StartShadowCopySet replied async\n"));
     339             :                 }
     340          26 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     341           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_StartShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     342             :                 }
     343          26 :                 if (dce_call->fault_code != 0) {
     344           0 :                         DBG_WARNING("dcerpc_fault %s in fss_StartShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     345             :                 }
     346          26 :                 break;
     347             :         }
     348          44 :         case 3: { /* fss_AddToShadowCopySet */
     349          44 :                 struct fss_AddToShadowCopySet *r2 = (struct fss_AddToShadowCopySet *)r;
     350          44 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     351           0 :                         DEBUG(5,("function fss_AddToShadowCopySet replied async\n"));
     352             :                 }
     353          44 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     354           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_AddToShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     355             :                 }
     356          44 :                 if (dce_call->fault_code != 0) {
     357           0 :                         DBG_WARNING("dcerpc_fault %s in fss_AddToShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     358             :                 }
     359          44 :                 break;
     360             :         }
     361          17 :         case 4: { /* fss_CommitShadowCopySet */
     362          17 :                 struct fss_CommitShadowCopySet *r2 = (struct fss_CommitShadowCopySet *)r;
     363          17 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     364           0 :                         DEBUG(5,("function fss_CommitShadowCopySet replied async\n"));
     365             :                 }
     366          17 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     367           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_CommitShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     368             :                 }
     369          17 :                 if (dce_call->fault_code != 0) {
     370           0 :                         DBG_WARNING("dcerpc_fault %s in fss_CommitShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     371             :                 }
     372          17 :                 break;
     373             :         }
     374          15 :         case 5: { /* fss_ExposeShadowCopySet */
     375          15 :                 struct fss_ExposeShadowCopySet *r2 = (struct fss_ExposeShadowCopySet *)r;
     376          15 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     377           0 :                         DEBUG(5,("function fss_ExposeShadowCopySet replied async\n"));
     378             :                 }
     379          15 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     380           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_ExposeShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     381             :                 }
     382          15 :                 if (dce_call->fault_code != 0) {
     383           0 :                         DBG_WARNING("dcerpc_fault %s in fss_ExposeShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     384             :                 }
     385          15 :                 break;
     386             :         }
     387           0 :         case 6: { /* fss_RecoveryCompleteShadowCopySet */
     388           0 :                 struct fss_RecoveryCompleteShadowCopySet *r2 = (struct fss_RecoveryCompleteShadowCopySet *)r;
     389           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     390           0 :                         DEBUG(5,("function fss_RecoveryCompleteShadowCopySet replied async\n"));
     391             :                 }
     392           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     393           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_RecoveryCompleteShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     394             :                 }
     395           0 :                 if (dce_call->fault_code != 0) {
     396           0 :                         DBG_WARNING("dcerpc_fault %s in fss_RecoveryCompleteShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     397             :                 }
     398           0 :                 break;
     399             :         }
     400           2 :         case 7: { /* fss_AbortShadowCopySet */
     401           2 :                 struct fss_AbortShadowCopySet *r2 = (struct fss_AbortShadowCopySet *)r;
     402           2 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     403           0 :                         DEBUG(5,("function fss_AbortShadowCopySet replied async\n"));
     404             :                 }
     405           2 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     406           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_AbortShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     407             :                 }
     408           2 :                 if (dce_call->fault_code != 0) {
     409           0 :                         DBG_WARNING("dcerpc_fault %s in fss_AbortShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     410             :                 }
     411           2 :                 break;
     412             :         }
     413          28 :         case 8: { /* fss_IsPathSupported */
     414          28 :                 struct fss_IsPathSupported *r2 = (struct fss_IsPathSupported *)r;
     415          28 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     416           0 :                         DEBUG(5,("function fss_IsPathSupported replied async\n"));
     417             :                 }
     418          28 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     419           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_IsPathSupported, NDR_OUT | NDR_SET_VALUES, r2);
     420             :                 }
     421          28 :                 if (dce_call->fault_code != 0) {
     422           0 :                         DBG_WARNING("dcerpc_fault %s in fss_IsPathSupported\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     423             :                 }
     424          28 :                 break;
     425             :         }
     426           0 :         case 9: { /* fss_IsPathShadowCopied */
     427           0 :                 struct fss_IsPathShadowCopied *r2 = (struct fss_IsPathShadowCopied *)r;
     428           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     429           0 :                         DEBUG(5,("function fss_IsPathShadowCopied replied async\n"));
     430             :                 }
     431           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     432           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_IsPathShadowCopied, NDR_OUT | NDR_SET_VALUES, r2);
     433             :                 }
     434           0 :                 if (dce_call->fault_code != 0) {
     435           0 :                         DBG_WARNING("dcerpc_fault %s in fss_IsPathShadowCopied\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     436             :                 }
     437           0 :                 break;
     438             :         }
     439          14 :         case 10: { /* fss_GetShareMapping */
     440          14 :                 struct fss_GetShareMapping *r2 = (struct fss_GetShareMapping *)r;
     441          14 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     442           0 :                         DEBUG(5,("function fss_GetShareMapping replied async\n"));
     443             :                 }
     444          14 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     445           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_GetShareMapping, NDR_OUT | NDR_SET_VALUES, r2);
     446             :                 }
     447          14 :                 if (dce_call->fault_code != 0) {
     448           0 :                         DBG_WARNING("dcerpc_fault %s in fss_GetShareMapping\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     449             :                 }
     450          14 :                 break;
     451             :         }
     452          14 :         case 11: { /* fss_DeleteShareMapping */
     453          14 :                 struct fss_DeleteShareMapping *r2 = (struct fss_DeleteShareMapping *)r;
     454          14 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     455           0 :                         DEBUG(5,("function fss_DeleteShareMapping replied async\n"));
     456             :                 }
     457          14 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     458           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_DeleteShareMapping, NDR_OUT | NDR_SET_VALUES, r2);
     459             :                 }
     460          14 :                 if (dce_call->fault_code != 0) {
     461           0 :                         DBG_WARNING("dcerpc_fault %s in fss_DeleteShareMapping\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     462             :                 }
     463          14 :                 break;
     464             :         }
     465          20 :         case 12: { /* fss_PrepareShadowCopySet */
     466          20 :                 struct fss_PrepareShadowCopySet *r2 = (struct fss_PrepareShadowCopySet *)r;
     467          20 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     468           0 :                         DEBUG(5,("function fss_PrepareShadowCopySet replied async\n"));
     469             :                 }
     470          20 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     471           0 :                         NDR_PRINT_FUNCTION_DEBUG(fss_PrepareShadowCopySet, NDR_OUT | NDR_SET_VALUES, r2);
     472             :                 }
     473          20 :                 if (dce_call->fault_code != 0) {
     474           0 :                         DBG_WARNING("dcerpc_fault %s in fss_PrepareShadowCopySet\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     475             :                 }
     476          20 :                 break;
     477             :         }
     478           0 :         default:
     479           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     480           0 :                 break;
     481             :         }
     482             : 
     483         236 :         if (dce_call->fault_code != 0) {
     484           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     485             :         }
     486             : 
     487         236 :         return NT_STATUS_OK;
     488             : }
     489             : 
     490         236 : NTSTATUS FileServerVssAgent__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     491             : {
     492             :         enum ndr_err_code ndr_err;
     493         236 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     494             : 
     495         236 :         ndr_err = ndr_table_FileServerVssAgent.calls[opnum].ndr_push(push, NDR_OUT, r);
     496         236 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     497           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     498           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     499             :         }
     500             : 
     501         236 :         return NT_STATUS_OK;
     502             : }
     503             : 
     504           0 : NTSTATUS FileServerVssAgent__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     505             : {
     506           0 :         return FileServerVssAgent__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     507             : }
     508             : 
     509             : static const struct dcesrv_interface dcesrv_FileServerVssAgent_interface = {
     510             :         .name      = "FileServerVssAgent",
     511             :         .syntax_id = {{0xa8e0653c,0x2744,0x4389,{0xa6,0x1d},{0x73,0x73,0xdf,0x8b,0x22,0x92}},1.0},
     512             :         .bind      = FileServerVssAgent__op_bind,
     513             :         .unbind    = FileServerVssAgent__op_unbind,
     514             :         .ndr_pull  = FileServerVssAgent__op_ndr_pull,
     515             :         .dispatch  = FileServerVssAgent__op_dispatch,
     516             :         .reply     = FileServerVssAgent__op_reply,
     517             :         .ndr_push  = FileServerVssAgent__op_ndr_push,
     518             :         .local     = FileServerVssAgent__op_local,
     519             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_FLAGS
     520             :         .flags     = DCESRV_INTERFACE_FILESERVERVSSAGENT_FLAGS
     521             : #else
     522             :         .flags     = 0
     523             : #endif
     524             : };
     525             : 
     526           2 : static NTSTATUS FileServerVssAgent__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
     527           2 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
     528             :         NTSTATUS status;
     529             : 
     530             :         /* If service is disabled, do not register */
     531           2 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
     532           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
     533             :         }
     534             : 
     535             :         /* If service is embedded, register only for ncacn_np
     536             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
     537             :          */
     538           2 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
     539           0 :                 DBG_INFO("Interface 'FileServerVssAgent' not registered in endpoint '%s' as service is embedded\n", name);
     540           0 :                 return NT_STATUS_NOT_SUPPORTED;
     541             :         }
     542             : 
     543             :         /*
     544             :          * If rpc service is external then change the default ncalrpc endpoint,
     545             :          * otherwise if the rpc daemon running this service is configured in
     546             :          * fork mode the forked process will race with main smbd to accept the
     547             :          * connections in the default ncalrpc socket, and the forked process
     548             :          * may not have the requested interface registered.
     549             :          * For example, in the ad_member test environment:
     550             :          *
     551             :          *   rpc_server:lsarpc = external
     552             :          *   rpc_server:samr = external
     553             :          *   rpc_server:netlogon = disabled
     554             :          *   rpc_daemon:lsasd = fork
     555             :          *
     556             :          * With these settings both, the main smbd and all the preforked lsasd
     557             :          * processes would be listening in the default ncalrpc socket if it is
     558             :          * not changed. If a client connection is accepted by one of the lsasd
     559             :          * worker processes and the client asks for an interface not registered
     560             :          * in these processes (winreg for example) it will get an error.
     561             :          */
     562           2 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
     563           0 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "FILESERVERVSSAGENT");
     564           0 :                 if (!NT_STATUS_IS_OK(status)) {
     565           0 :                         return status;
     566             :                 }
     567             :         }
     568             : 
     569           2 :         return NT_STATUS_OK;
     570             : }
     571             : 
     572           2 : static NTSTATUS FileServerVssAgent__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     573             : {
     574             :         uint32_t i;
     575             :         NTSTATUS ret;
     576             :         struct dcerpc_binding *binding;
     577           2 :         struct dcerpc_binding *binding2 = NULL;
     578             : 
     579             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_NCACN_NP_SECONDARY_ENDPOINT
     580             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_FILESERVERVSSAGENT_NCACN_NP_SECONDARY_ENDPOINT;
     581             : #else
     582           2 :         const char *ncacn_np_secondary_endpoint = NULL;
     583             : #endif
     584             : 
     585           4 :         for (i=0;i<ndr_table_FileServerVssAgent.endpoints->count;i++) {
     586           2 :                 const char *name = ndr_table_FileServerVssAgent.endpoints->names[i];
     587             : 
     588           2 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
     589           2 :                 if (NT_STATUS_IS_ERR(ret)) {
     590           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
     591           0 :                         return ret;
     592             :                 }
     593             : 
     594           2 :                 ret = FileServerVssAgent__check_register_in_endpoint("FileServerVssAgent", binding);
     595           2 :                 if (NT_STATUS_IS_ERR(ret)) {
     596           0 :                         talloc_free(binding);
     597           0 :                         continue;
     598             :                 }
     599             : 
     600           2 :                 if (ncacn_np_secondary_endpoint != NULL) {
     601           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
     602           0 :                         if (NT_STATUS_IS_ERR(ret)) {
     603           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
     604           0 :                                 TALLOC_FREE(binding);
     605           0 :                                 return ret;
     606             :                         }
     607             :                 }
     608             : 
     609           2 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_FileServerVssAgent_interface, NULL);
     610           2 :                 TALLOC_FREE(binding);
     611           2 :                 TALLOC_FREE(binding2);
     612           2 :                 if (!NT_STATUS_IS_OK(ret)) {
     613           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     614           0 :                         return ret;
     615             :                 }
     616             :         }
     617             : 
     618           2 :         return NT_STATUS_OK;
     619             : }
     620             : 
     621           0 : static NTSTATUS FileServerVssAgent__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     622             : {
     623           0 :         return NT_STATUS_OK;
     624             : }
     625             : 
     626           0 : static bool FileServerVssAgent__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     627             : {
     628           0 :         if (dcesrv_FileServerVssAgent_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_FileServerVssAgent_interface.syntax_id.uuid, uuid)) {
     629           0 :                 memcpy(iface,&dcesrv_FileServerVssAgent_interface, sizeof(*iface));
     630           0 :                 return true;
     631             :         }
     632             : 
     633           0 :         return false;
     634             : }
     635             : 
     636           0 : static bool FileServerVssAgent__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     637             : {
     638           0 :         if (strcmp(dcesrv_FileServerVssAgent_interface.name, name)==0) {
     639           0 :                 memcpy(iface, &dcesrv_FileServerVssAgent_interface, sizeof(*iface));
     640           0 :                 return true;
     641             :         }
     642             : 
     643           0 :         return false;
     644             : }
     645             : 
     646             : static const struct dcesrv_endpoint_server FileServerVssAgent_ep_server = {
     647             :         /* fill in our name */
     648             :         .name = "FileServerVssAgent",
     649             : 
     650             :         /* Initialization flag */
     651             :         .initialized = false,
     652             : 
     653             :         /* fill in all the operations */
     654             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_INIT_SERVER
     655             :         .init_server = DCESRV_INTERFACE_FILESERVERVSSAGENT_INIT_SERVER,
     656             : #else
     657             :         .init_server = FileServerVssAgent__op_init_server,
     658             : #endif
     659             : #ifdef DCESRV_INTERFACE_FILESERVERVSSAGENT_SHUTDOWN_SERVER
     660             :         .shutdown_server = DCESRV_INTERFACE_FILESERVERVSSAGENT_SHUTDOWN_SERVER,
     661             : #else
     662             :         .shutdown_server = FileServerVssAgent__op_shutdown_server,
     663             : #endif
     664             :         .interface_by_uuid = FileServerVssAgent__op_interface_by_uuid,
     665             :         .interface_by_name = FileServerVssAgent__op_interface_by_name
     666             : };
     667             : 
     668           2 : const struct dcesrv_endpoint_server *FileServerVssAgent_get_ep_server(void)
     669             : {
     670           2 :         return &FileServerVssAgent_ep_server;
     671             : }

Generated by: LCOV version 1.13