LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_eventlog_scompat.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 185 574 32.2 %
Date: 2021-09-23 10:06:22 Functions: 12 15 80.0 %

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_eventlog.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_eventlog_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             : /* eventlog - dcerpc server boilerplate generated by pidl */
      15           4 : static NTSTATUS eventlog__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      16             : {
      17           4 :         struct pipes_struct *p = NULL;
      18             : 
      19             :         /* Retrieve pipes struct */
      20           4 :         p = dcesrv_get_pipes_struct(context->conn);
      21           4 :         p->pipe_bound = true;
      22             : #ifdef DCESRV_INTERFACE_EVENTLOG_BIND
      23             :         return DCESRV_INTERFACE_EVENTLOG_BIND(context,iface);
      24             : #else
      25           4 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29           4 : static void eventlog__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_EVENTLOG_UNBIND
      32             :         DCESRV_INTERFACE_EVENTLOG_UNBIND(context, iface);
      33             : #else
      34           4 :         return;
      35             : #endif
      36             : }
      37             : 
      38          52 : NTSTATUS eventlog__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          52 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      42             : 
      43          52 :         dce_call->fault_code = 0;
      44             : 
      45          52 :         if (opnum >= ndr_table_eventlog.num_calls) {
      46           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      47           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      48             :         }
      49             : 
      50          52 :         *r = talloc_named(mem_ctx, ndr_table_eventlog.calls[opnum].struct_size, "struct %s", ndr_table_eventlog.calls[opnum].name);
      51          52 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      52             : 
      53             :         /* unravel the NDR for the packet */
      54          52 :         ndr_err = ndr_table_eventlog.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      55          52 :         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          52 :         return NT_STATUS_OK;
      61             : }
      62             : 
      63          52 : static NTSTATUS eventlog__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
      64             : {
      65          52 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      66          52 :         struct pipes_struct *p = NULL;
      67          52 :         struct auth_session_info *pipe_session_info = NULL;
      68          52 :         NTSTATUS status = NT_STATUS_OK;
      69          52 :         bool impersonated = false;
      70             : 
      71             :         /* Retrieve pipes struct */
      72          52 :         p = dcesrv_get_pipes_struct(dce_call->conn);
      73             :         /* Update pipes struct opnum */
      74          52 :         p->opnum = opnum;
      75          52 :         p->dce_call = dce_call;
      76          52 :         p->mem_ctx = mem_ctx;
      77             :         /* Update pipes struct session info */
      78          52 :         pipe_session_info = p->session_info;
      79          52 :         p->session_info = dce_call->auth_state->session_info;
      80          52 :         p->auth.auth_type = dce_call->auth_state->auth_type;
      81          52 :         p->auth.auth_level = dce_call->auth_state->auth_level;
      82          52 :         p->auth.auth_context_id = dce_call->auth_state->auth_context_id;
      83             :         /* Reset pipes struct fault state */
      84          52 :         p->fault_state = 0;
      85             : 
      86             :         /* Impersonate */
      87          52 :         if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
      88          52 :                 impersonated = become_authenticated_pipe_user(p->session_info);
      89          52 :                 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          52 :         switch (opnum) {
      97           0 :         case 0: { /* eventlog_ClearEventLogW */
      98           0 :                 struct eventlog_ClearEventLogW *r2 = (struct eventlog_ClearEventLogW *)r;
      99           0 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ClearEventLogW, NDR_IN, r2);
     101             :                 }
     102           0 :                 r2->out.result = _eventlog_ClearEventLogW(p, r2);
     103           0 :                 break;
     104             :         }
     105           0 :         case 1: { /* eventlog_BackupEventLogW */
     106           0 :                 struct eventlog_BackupEventLogW *r2 = (struct eventlog_BackupEventLogW *)r;
     107           0 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_BackupEventLogW, NDR_IN, r2);
     109             :                 }
     110           0 :                 r2->out.result = _eventlog_BackupEventLogW(p, r2);
     111           0 :                 break;
     112             :         }
     113          12 :         case 2: { /* eventlog_CloseEventLog */
     114          12 :                 struct eventlog_CloseEventLog *r2 = (struct eventlog_CloseEventLog *)r;
     115          12 :                 if (DEBUGLEVEL >= 10) {
     116           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_CloseEventLog, NDR_IN, r2);
     117             :                 }
     118          12 :                 NDR_ZERO_STRUCT(r2->out);
     119          12 :                 r2->out.handle = r2->in.handle;
     120          12 :                 r2->out.result = _eventlog_CloseEventLog(p, r2);
     121          12 :                 break;
     122             :         }
     123           0 :         case 3: { /* eventlog_DeregisterEventSource */
     124           0 :                 struct eventlog_DeregisterEventSource *r2 = (struct eventlog_DeregisterEventSource *)r;
     125           0 :                 if (DEBUGLEVEL >= 10) {
     126           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_DeregisterEventSource, NDR_IN, r2);
     127             :                 }
     128           0 :                 NDR_ZERO_STRUCT(r2->out);
     129           0 :                 r2->out.handle = r2->in.handle;
     130           0 :                 r2->out.result = _eventlog_DeregisterEventSource(p, r2);
     131           0 :                 break;
     132             :         }
     133           2 :         case 4: { /* eventlog_GetNumRecords */
     134           2 :                 struct eventlog_GetNumRecords *r2 = (struct eventlog_GetNumRecords *)r;
     135           2 :                 if (DEBUGLEVEL >= 10) {
     136           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetNumRecords, NDR_IN, r2);
     137             :                 }
     138           2 :                 NDR_ZERO_STRUCT(r2->out);
     139           2 :                 r2->out.number = talloc_zero(r2, uint32_t);
     140           2 :                 if (r2->out.number == NULL) {
     141           0 :                         status = NT_STATUS_NO_MEMORY;
     142           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     143           0 :                         goto fail;
     144             :                 }
     145             : 
     146           2 :                 r2->out.result = _eventlog_GetNumRecords(p, r2);
     147           2 :                 break;
     148             :         }
     149           0 :         case 5: { /* eventlog_GetOldestRecord */
     150           0 :                 struct eventlog_GetOldestRecord *r2 = (struct eventlog_GetOldestRecord *)r;
     151           0 :                 if (DEBUGLEVEL >= 10) {
     152           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetOldestRecord, NDR_IN, r2);
     153             :                 }
     154           0 :                 NDR_ZERO_STRUCT(r2->out);
     155           0 :                 r2->out.oldest_entry = talloc_zero(r2, uint32_t);
     156           0 :                 if (r2->out.oldest_entry == NULL) {
     157           0 :                         status = NT_STATUS_NO_MEMORY;
     158           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     159           0 :                         goto fail;
     160             :                 }
     161             : 
     162           0 :                 r2->out.result = _eventlog_GetOldestRecord(p, r2);
     163           0 :                 break;
     164             :         }
     165           0 :         case 6: { /* eventlog_ChangeNotify */
     166           0 :                 struct eventlog_ChangeNotify *r2 = (struct eventlog_ChangeNotify *)r;
     167           0 :                 if (DEBUGLEVEL >= 10) {
     168           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ChangeNotify, NDR_IN, r2);
     169             :                 }
     170           0 :                 r2->out.result = _eventlog_ChangeNotify(p, r2);
     171           0 :                 break;
     172             :         }
     173          24 :         case 7: { /* eventlog_OpenEventLogW */
     174          24 :                 struct eventlog_OpenEventLogW *r2 = (struct eventlog_OpenEventLogW *)r;
     175          24 :                 if (DEBUGLEVEL >= 10) {
     176           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenEventLogW, NDR_IN, r2);
     177             :                 }
     178          24 :                 NDR_ZERO_STRUCT(r2->out);
     179          24 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     180          24 :                 if (r2->out.handle == NULL) {
     181           0 :                         status = NT_STATUS_NO_MEMORY;
     182           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     183           0 :                         goto fail;
     184             :                 }
     185             : 
     186          24 :                 r2->out.result = _eventlog_OpenEventLogW(p, r2);
     187          24 :                 break;
     188             :         }
     189           0 :         case 8: { /* eventlog_RegisterEventSourceW */
     190           0 :                 struct eventlog_RegisterEventSourceW *r2 = (struct eventlog_RegisterEventSourceW *)r;
     191           0 :                 if (DEBUGLEVEL >= 10) {
     192           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterEventSourceW, NDR_IN, r2);
     193             :                 }
     194           0 :                 NDR_ZERO_STRUCT(r2->out);
     195           0 :                 r2->out.log_handle = talloc_zero(r2, struct policy_handle);
     196           0 :                 if (r2->out.log_handle == NULL) {
     197           0 :                         status = NT_STATUS_NO_MEMORY;
     198           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     199           0 :                         goto fail;
     200             :                 }
     201             : 
     202           0 :                 r2->out.result = _eventlog_RegisterEventSourceW(p, r2);
     203           0 :                 break;
     204             :         }
     205           0 :         case 9: { /* eventlog_OpenBackupEventLogW */
     206           0 :                 struct eventlog_OpenBackupEventLogW *r2 = (struct eventlog_OpenBackupEventLogW *)r;
     207           0 :                 if (DEBUGLEVEL >= 10) {
     208           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenBackupEventLogW, NDR_IN, r2);
     209             :                 }
     210           0 :                 NDR_ZERO_STRUCT(r2->out);
     211           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     212           0 :                 if (r2->out.handle == NULL) {
     213           0 :                         status = NT_STATUS_NO_MEMORY;
     214           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     215           0 :                         goto fail;
     216             :                 }
     217             : 
     218           0 :                 r2->out.result = _eventlog_OpenBackupEventLogW(p, r2);
     219           0 :                 break;
     220             :         }
     221           4 :         case 10: { /* eventlog_ReadEventLogW */
     222           4 :                 struct eventlog_ReadEventLogW *r2 = (struct eventlog_ReadEventLogW *)r;
     223           4 :                 if (DEBUGLEVEL >= 10) {
     224           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReadEventLogW, NDR_IN, r2);
     225             :                 }
     226           4 :                 NDR_ZERO_STRUCT(r2->out);
     227           4 :                 r2->out.data = talloc_zero_array(r2, uint8_t, r2->in.number_of_bytes);
     228           4 :                 if (r2->out.data == NULL) {
     229           0 :                         status = NT_STATUS_NO_MEMORY;
     230           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     231           0 :                         goto fail;
     232             :                 }
     233             : 
     234           4 :                 r2->out.sent_size = talloc_zero(r2, uint32_t);
     235           4 :                 if (r2->out.sent_size == NULL) {
     236           0 :                         status = NT_STATUS_NO_MEMORY;
     237           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     238           0 :                         goto fail;
     239             :                 }
     240             : 
     241           4 :                 r2->out.real_size = talloc_zero(r2, uint32_t);
     242           4 :                 if (r2->out.real_size == NULL) {
     243           0 :                         status = NT_STATUS_NO_MEMORY;
     244           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     245           0 :                         goto fail;
     246             :                 }
     247             : 
     248           4 :                 r2->out.result = _eventlog_ReadEventLogW(p, r2);
     249           4 :                 break;
     250             :         }
     251           2 :         case 11: { /* eventlog_ReportEventW */
     252           2 :                 struct eventlog_ReportEventW *r2 = (struct eventlog_ReportEventW *)r;
     253           2 :                 if (DEBUGLEVEL >= 10) {
     254           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventW, NDR_IN, r2);
     255             :                 }
     256           2 :                 NDR_ZERO_STRUCT(r2->out);
     257           2 :                 r2->out.record_number = r2->in.record_number;
     258           2 :                 r2->out.time_written = r2->in.time_written;
     259           2 :                 r2->out.result = _eventlog_ReportEventW(p, r2);
     260           2 :                 break;
     261             :         }
     262           0 :         case 12: { /* eventlog_ClearEventLogA */
     263           0 :                 struct eventlog_ClearEventLogA *r2 = (struct eventlog_ClearEventLogA *)r;
     264           0 :                 if (DEBUGLEVEL >= 10) {
     265           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ClearEventLogA, NDR_IN, r2);
     266             :                 }
     267           0 :                 r2->out.result = _eventlog_ClearEventLogA(p, r2);
     268           0 :                 break;
     269             :         }
     270           0 :         case 13: { /* eventlog_BackupEventLogA */
     271           0 :                 struct eventlog_BackupEventLogA *r2 = (struct eventlog_BackupEventLogA *)r;
     272           0 :                 if (DEBUGLEVEL >= 10) {
     273           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_BackupEventLogA, NDR_IN, r2);
     274             :                 }
     275           0 :                 r2->out.result = _eventlog_BackupEventLogA(p, r2);
     276           0 :                 break;
     277             :         }
     278           0 :         case 14: { /* eventlog_OpenEventLogA */
     279           0 :                 struct eventlog_OpenEventLogA *r2 = (struct eventlog_OpenEventLogA *)r;
     280           0 :                 if (DEBUGLEVEL >= 10) {
     281           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenEventLogA, NDR_IN, r2);
     282             :                 }
     283           0 :                 r2->out.result = _eventlog_OpenEventLogA(p, r2);
     284           0 :                 break;
     285             :         }
     286           0 :         case 15: { /* eventlog_RegisterEventSourceA */
     287           0 :                 struct eventlog_RegisterEventSourceA *r2 = (struct eventlog_RegisterEventSourceA *)r;
     288           0 :                 if (DEBUGLEVEL >= 10) {
     289           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterEventSourceA, NDR_IN, r2);
     290             :                 }
     291           0 :                 r2->out.result = _eventlog_RegisterEventSourceA(p, r2);
     292           0 :                 break;
     293             :         }
     294           0 :         case 16: { /* eventlog_OpenBackupEventLogA */
     295           0 :                 struct eventlog_OpenBackupEventLogA *r2 = (struct eventlog_OpenBackupEventLogA *)r;
     296           0 :                 if (DEBUGLEVEL >= 10) {
     297           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenBackupEventLogA, NDR_IN, r2);
     298             :                 }
     299           0 :                 r2->out.result = _eventlog_OpenBackupEventLogA(p, r2);
     300           0 :                 break;
     301             :         }
     302           0 :         case 17: { /* eventlog_ReadEventLogA */
     303           0 :                 struct eventlog_ReadEventLogA *r2 = (struct eventlog_ReadEventLogA *)r;
     304           0 :                 if (DEBUGLEVEL >= 10) {
     305           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReadEventLogA, NDR_IN, r2);
     306             :                 }
     307           0 :                 r2->out.result = _eventlog_ReadEventLogA(p, r2);
     308           0 :                 break;
     309             :         }
     310           0 :         case 18: { /* eventlog_ReportEventA */
     311           0 :                 struct eventlog_ReportEventA *r2 = (struct eventlog_ReportEventA *)r;
     312           0 :                 if (DEBUGLEVEL >= 10) {
     313           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventA, NDR_IN, r2);
     314             :                 }
     315           0 :                 r2->out.result = _eventlog_ReportEventA(p, r2);
     316           0 :                 break;
     317             :         }
     318           0 :         case 19: { /* eventlog_RegisterClusterSvc */
     319           0 :                 struct eventlog_RegisterClusterSvc *r2 = (struct eventlog_RegisterClusterSvc *)r;
     320           0 :                 if (DEBUGLEVEL >= 10) {
     321           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterClusterSvc, NDR_IN, r2);
     322             :                 }
     323           0 :                 r2->out.result = _eventlog_RegisterClusterSvc(p, r2);
     324           0 :                 break;
     325             :         }
     326           0 :         case 20: { /* eventlog_DeregisterClusterSvc */
     327           0 :                 struct eventlog_DeregisterClusterSvc *r2 = (struct eventlog_DeregisterClusterSvc *)r;
     328           0 :                 if (DEBUGLEVEL >= 10) {
     329           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_DeregisterClusterSvc, NDR_IN, r2);
     330             :                 }
     331           0 :                 r2->out.result = _eventlog_DeregisterClusterSvc(p, r2);
     332           0 :                 break;
     333             :         }
     334           0 :         case 21: { /* eventlog_WriteClusterEvents */
     335           0 :                 struct eventlog_WriteClusterEvents *r2 = (struct eventlog_WriteClusterEvents *)r;
     336           0 :                 if (DEBUGLEVEL >= 10) {
     337           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_WriteClusterEvents, NDR_IN, r2);
     338             :                 }
     339           0 :                 r2->out.result = _eventlog_WriteClusterEvents(p, r2);
     340           0 :                 break;
     341             :         }
     342           6 :         case 22: { /* eventlog_GetLogInformation */
     343           6 :                 struct eventlog_GetLogInformation *r2 = (struct eventlog_GetLogInformation *)r;
     344           6 :                 if (DEBUGLEVEL >= 10) {
     345           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetLogInformation, NDR_IN, r2);
     346             :                 }
     347           6 :                 NDR_ZERO_STRUCT(r2->out);
     348           6 :                 r2->out.buffer = talloc_zero_array(r2, uint8_t, r2->in.buf_size);
     349           6 :                 if (r2->out.buffer == NULL) {
     350           0 :                         status = NT_STATUS_NO_MEMORY;
     351           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     352           0 :                         goto fail;
     353             :                 }
     354             : 
     355           6 :                 r2->out.bytes_needed = talloc_zero(r2, uint32_t);
     356           6 :                 if (r2->out.bytes_needed == NULL) {
     357           0 :                         status = NT_STATUS_NO_MEMORY;
     358           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     359           0 :                         goto fail;
     360             :                 }
     361             : 
     362           6 :                 r2->out.result = _eventlog_GetLogInformation(p, r2);
     363           6 :                 break;
     364             :         }
     365           2 :         case 23: { /* eventlog_FlushEventLog */
     366           2 :                 struct eventlog_FlushEventLog *r2 = (struct eventlog_FlushEventLog *)r;
     367           2 :                 if (DEBUGLEVEL >= 10) {
     368           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_FlushEventLog, NDR_IN, r2);
     369             :                 }
     370           2 :                 r2->out.result = _eventlog_FlushEventLog(p, r2);
     371           2 :                 break;
     372             :         }
     373           0 :         case 24: { /* eventlog_ReportEventAndSourceW */
     374           0 :                 struct eventlog_ReportEventAndSourceW *r2 = (struct eventlog_ReportEventAndSourceW *)r;
     375           0 :                 if (DEBUGLEVEL >= 10) {
     376           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventAndSourceW, NDR_IN, r2);
     377             :                 }
     378           0 :                 NDR_ZERO_STRUCT(r2->out);
     379           0 :                 r2->out.record_number = r2->in.record_number;
     380           0 :                 r2->out.time_written = r2->in.time_written;
     381           0 :                 r2->out.result = _eventlog_ReportEventAndSourceW(p, r2);
     382           0 :                 break;
     383             :         }
     384           0 :         default:
     385           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     386           0 :                 break;
     387             :         }
     388             : 
     389          52 : fail:
     390             :         /* Unimpersonate */
     391          52 :         if (impersonated) {
     392          52 :                 unbecome_authenticated_pipe_user();
     393             :         }
     394             : 
     395          52 :         p->dce_call = NULL;
     396          52 :         p->mem_ctx = NULL;
     397             :         /* Restore session info */
     398          52 :         p->session_info = pipe_session_info;
     399          52 :         p->auth.auth_type = 0;
     400          52 :         p->auth.auth_level = 0;
     401          52 :         p->auth.auth_context_id = 0;
     402             :         /* Check pipes struct fault state */
     403          52 :         if (p->fault_state != 0) {
     404           0 :                 dce_call->fault_code = p->fault_state;
     405             :         }
     406          52 :         if (dce_call->fault_code != 0) {
     407           0 :                 status = NT_STATUS_NET_WRITE_FAULT;
     408             :         }
     409             : 
     410          52 :         return status;
     411             : }
     412             : 
     413          52 : NTSTATUS eventlog__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     414             : {
     415          52 :         return eventlog__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     416             : }
     417             : 
     418          52 : NTSTATUS eventlog__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     419             : {
     420          52 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     421             : 
     422          52 :         switch (opnum) {
     423           0 :         case 0: { /* eventlog_ClearEventLogW */
     424           0 :                 struct eventlog_ClearEventLogW *r2 = (struct eventlog_ClearEventLogW *)r;
     425           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     426           0 :                         DEBUG(5,("function eventlog_ClearEventLogW replied async\n"));
     427             :                 }
     428           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     429           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ClearEventLogW, NDR_OUT | NDR_SET_VALUES, r2);
     430             :                 }
     431           0 :                 if (dce_call->fault_code != 0) {
     432           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ClearEventLogW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     433             :                 }
     434           0 :                 break;
     435             :         }
     436           0 :         case 1: { /* eventlog_BackupEventLogW */
     437           0 :                 struct eventlog_BackupEventLogW *r2 = (struct eventlog_BackupEventLogW *)r;
     438           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     439           0 :                         DEBUG(5,("function eventlog_BackupEventLogW replied async\n"));
     440             :                 }
     441           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     442           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_BackupEventLogW, NDR_OUT | NDR_SET_VALUES, r2);
     443             :                 }
     444           0 :                 if (dce_call->fault_code != 0) {
     445           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_BackupEventLogW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     446             :                 }
     447           0 :                 break;
     448             :         }
     449          12 :         case 2: { /* eventlog_CloseEventLog */
     450          12 :                 struct eventlog_CloseEventLog *r2 = (struct eventlog_CloseEventLog *)r;
     451          12 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     452           0 :                         DEBUG(5,("function eventlog_CloseEventLog replied async\n"));
     453             :                 }
     454          12 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     455           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_CloseEventLog, NDR_OUT | NDR_SET_VALUES, r2);
     456             :                 }
     457          12 :                 if (dce_call->fault_code != 0) {
     458           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_CloseEventLog\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     459             :                 }
     460          12 :                 break;
     461             :         }
     462           0 :         case 3: { /* eventlog_DeregisterEventSource */
     463           0 :                 struct eventlog_DeregisterEventSource *r2 = (struct eventlog_DeregisterEventSource *)r;
     464           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     465           0 :                         DEBUG(5,("function eventlog_DeregisterEventSource replied async\n"));
     466             :                 }
     467           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     468           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_DeregisterEventSource, NDR_OUT | NDR_SET_VALUES, r2);
     469             :                 }
     470           0 :                 if (dce_call->fault_code != 0) {
     471           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_DeregisterEventSource\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     472             :                 }
     473           0 :                 break;
     474             :         }
     475           2 :         case 4: { /* eventlog_GetNumRecords */
     476           2 :                 struct eventlog_GetNumRecords *r2 = (struct eventlog_GetNumRecords *)r;
     477           2 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     478           0 :                         DEBUG(5,("function eventlog_GetNumRecords replied async\n"));
     479             :                 }
     480           2 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     481           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetNumRecords, NDR_OUT | NDR_SET_VALUES, r2);
     482             :                 }
     483           2 :                 if (dce_call->fault_code != 0) {
     484           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_GetNumRecords\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     485             :                 }
     486           2 :                 break;
     487             :         }
     488           0 :         case 5: { /* eventlog_GetOldestRecord */
     489           0 :                 struct eventlog_GetOldestRecord *r2 = (struct eventlog_GetOldestRecord *)r;
     490           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     491           0 :                         DEBUG(5,("function eventlog_GetOldestRecord replied async\n"));
     492             :                 }
     493           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     494           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetOldestRecord, NDR_OUT | NDR_SET_VALUES, r2);
     495             :                 }
     496           0 :                 if (dce_call->fault_code != 0) {
     497           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_GetOldestRecord\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     498             :                 }
     499           0 :                 break;
     500             :         }
     501           0 :         case 6: { /* eventlog_ChangeNotify */
     502           0 :                 struct eventlog_ChangeNotify *r2 = (struct eventlog_ChangeNotify *)r;
     503           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     504           0 :                         DEBUG(5,("function eventlog_ChangeNotify replied async\n"));
     505             :                 }
     506           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     507           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ChangeNotify, NDR_OUT | NDR_SET_VALUES, r2);
     508             :                 }
     509           0 :                 if (dce_call->fault_code != 0) {
     510           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ChangeNotify\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     511             :                 }
     512           0 :                 break;
     513             :         }
     514          24 :         case 7: { /* eventlog_OpenEventLogW */
     515          24 :                 struct eventlog_OpenEventLogW *r2 = (struct eventlog_OpenEventLogW *)r;
     516          24 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     517           0 :                         DEBUG(5,("function eventlog_OpenEventLogW replied async\n"));
     518             :                 }
     519          24 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     520           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenEventLogW, NDR_OUT | NDR_SET_VALUES, r2);
     521             :                 }
     522          24 :                 if (dce_call->fault_code != 0) {
     523           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_OpenEventLogW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     524             :                 }
     525          24 :                 break;
     526             :         }
     527           0 :         case 8: { /* eventlog_RegisterEventSourceW */
     528           0 :                 struct eventlog_RegisterEventSourceW *r2 = (struct eventlog_RegisterEventSourceW *)r;
     529           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     530           0 :                         DEBUG(5,("function eventlog_RegisterEventSourceW replied async\n"));
     531             :                 }
     532           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     533           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterEventSourceW, NDR_OUT | NDR_SET_VALUES, r2);
     534             :                 }
     535           0 :                 if (dce_call->fault_code != 0) {
     536           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_RegisterEventSourceW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     537             :                 }
     538           0 :                 break;
     539             :         }
     540           0 :         case 9: { /* eventlog_OpenBackupEventLogW */
     541           0 :                 struct eventlog_OpenBackupEventLogW *r2 = (struct eventlog_OpenBackupEventLogW *)r;
     542           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     543           0 :                         DEBUG(5,("function eventlog_OpenBackupEventLogW replied async\n"));
     544             :                 }
     545           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     546           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenBackupEventLogW, NDR_OUT | NDR_SET_VALUES, r2);
     547             :                 }
     548           0 :                 if (dce_call->fault_code != 0) {
     549           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_OpenBackupEventLogW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     550             :                 }
     551           0 :                 break;
     552             :         }
     553           4 :         case 10: { /* eventlog_ReadEventLogW */
     554           4 :                 struct eventlog_ReadEventLogW *r2 = (struct eventlog_ReadEventLogW *)r;
     555           4 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     556           0 :                         DEBUG(5,("function eventlog_ReadEventLogW replied async\n"));
     557             :                 }
     558           4 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     559           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReadEventLogW, NDR_OUT | NDR_SET_VALUES, r2);
     560             :                 }
     561           4 :                 if (dce_call->fault_code != 0) {
     562           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ReadEventLogW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     563             :                 }
     564           4 :                 break;
     565             :         }
     566           2 :         case 11: { /* eventlog_ReportEventW */
     567           2 :                 struct eventlog_ReportEventW *r2 = (struct eventlog_ReportEventW *)r;
     568           2 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     569           0 :                         DEBUG(5,("function eventlog_ReportEventW replied async\n"));
     570             :                 }
     571           2 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     572           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventW, NDR_OUT | NDR_SET_VALUES, r2);
     573             :                 }
     574           2 :                 if (dce_call->fault_code != 0) {
     575           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ReportEventW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     576             :                 }
     577           2 :                 break;
     578             :         }
     579           0 :         case 12: { /* eventlog_ClearEventLogA */
     580           0 :                 struct eventlog_ClearEventLogA *r2 = (struct eventlog_ClearEventLogA *)r;
     581           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     582           0 :                         DEBUG(5,("function eventlog_ClearEventLogA replied async\n"));
     583             :                 }
     584           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     585           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ClearEventLogA, NDR_OUT | NDR_SET_VALUES, r2);
     586             :                 }
     587           0 :                 if (dce_call->fault_code != 0) {
     588           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ClearEventLogA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     589             :                 }
     590           0 :                 break;
     591             :         }
     592           0 :         case 13: { /* eventlog_BackupEventLogA */
     593           0 :                 struct eventlog_BackupEventLogA *r2 = (struct eventlog_BackupEventLogA *)r;
     594           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     595           0 :                         DEBUG(5,("function eventlog_BackupEventLogA replied async\n"));
     596             :                 }
     597           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     598           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_BackupEventLogA, NDR_OUT | NDR_SET_VALUES, r2);
     599             :                 }
     600           0 :                 if (dce_call->fault_code != 0) {
     601           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_BackupEventLogA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     602             :                 }
     603           0 :                 break;
     604             :         }
     605           0 :         case 14: { /* eventlog_OpenEventLogA */
     606           0 :                 struct eventlog_OpenEventLogA *r2 = (struct eventlog_OpenEventLogA *)r;
     607           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     608           0 :                         DEBUG(5,("function eventlog_OpenEventLogA replied async\n"));
     609             :                 }
     610           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     611           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenEventLogA, NDR_OUT | NDR_SET_VALUES, r2);
     612             :                 }
     613           0 :                 if (dce_call->fault_code != 0) {
     614           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_OpenEventLogA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     615             :                 }
     616           0 :                 break;
     617             :         }
     618           0 :         case 15: { /* eventlog_RegisterEventSourceA */
     619           0 :                 struct eventlog_RegisterEventSourceA *r2 = (struct eventlog_RegisterEventSourceA *)r;
     620           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     621           0 :                         DEBUG(5,("function eventlog_RegisterEventSourceA replied async\n"));
     622             :                 }
     623           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     624           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterEventSourceA, NDR_OUT | NDR_SET_VALUES, r2);
     625             :                 }
     626           0 :                 if (dce_call->fault_code != 0) {
     627           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_RegisterEventSourceA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     628             :                 }
     629           0 :                 break;
     630             :         }
     631           0 :         case 16: { /* eventlog_OpenBackupEventLogA */
     632           0 :                 struct eventlog_OpenBackupEventLogA *r2 = (struct eventlog_OpenBackupEventLogA *)r;
     633           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     634           0 :                         DEBUG(5,("function eventlog_OpenBackupEventLogA replied async\n"));
     635             :                 }
     636           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     637           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_OpenBackupEventLogA, NDR_OUT | NDR_SET_VALUES, r2);
     638             :                 }
     639           0 :                 if (dce_call->fault_code != 0) {
     640           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_OpenBackupEventLogA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     641             :                 }
     642           0 :                 break;
     643             :         }
     644           0 :         case 17: { /* eventlog_ReadEventLogA */
     645           0 :                 struct eventlog_ReadEventLogA *r2 = (struct eventlog_ReadEventLogA *)r;
     646           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     647           0 :                         DEBUG(5,("function eventlog_ReadEventLogA replied async\n"));
     648             :                 }
     649           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     650           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReadEventLogA, NDR_OUT | NDR_SET_VALUES, r2);
     651             :                 }
     652           0 :                 if (dce_call->fault_code != 0) {
     653           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ReadEventLogA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     654             :                 }
     655           0 :                 break;
     656             :         }
     657           0 :         case 18: { /* eventlog_ReportEventA */
     658           0 :                 struct eventlog_ReportEventA *r2 = (struct eventlog_ReportEventA *)r;
     659           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     660           0 :                         DEBUG(5,("function eventlog_ReportEventA replied async\n"));
     661             :                 }
     662           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     663           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventA, NDR_OUT | NDR_SET_VALUES, r2);
     664             :                 }
     665           0 :                 if (dce_call->fault_code != 0) {
     666           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ReportEventA\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     667             :                 }
     668           0 :                 break;
     669             :         }
     670           0 :         case 19: { /* eventlog_RegisterClusterSvc */
     671           0 :                 struct eventlog_RegisterClusterSvc *r2 = (struct eventlog_RegisterClusterSvc *)r;
     672           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     673           0 :                         DEBUG(5,("function eventlog_RegisterClusterSvc replied async\n"));
     674             :                 }
     675           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     676           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_RegisterClusterSvc, NDR_OUT | NDR_SET_VALUES, r2);
     677             :                 }
     678           0 :                 if (dce_call->fault_code != 0) {
     679           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_RegisterClusterSvc\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     680             :                 }
     681           0 :                 break;
     682             :         }
     683           0 :         case 20: { /* eventlog_DeregisterClusterSvc */
     684           0 :                 struct eventlog_DeregisterClusterSvc *r2 = (struct eventlog_DeregisterClusterSvc *)r;
     685           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     686           0 :                         DEBUG(5,("function eventlog_DeregisterClusterSvc replied async\n"));
     687             :                 }
     688           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     689           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_DeregisterClusterSvc, NDR_OUT | NDR_SET_VALUES, r2);
     690             :                 }
     691           0 :                 if (dce_call->fault_code != 0) {
     692           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_DeregisterClusterSvc\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     693             :                 }
     694           0 :                 break;
     695             :         }
     696           0 :         case 21: { /* eventlog_WriteClusterEvents */
     697           0 :                 struct eventlog_WriteClusterEvents *r2 = (struct eventlog_WriteClusterEvents *)r;
     698           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     699           0 :                         DEBUG(5,("function eventlog_WriteClusterEvents replied async\n"));
     700             :                 }
     701           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     702           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_WriteClusterEvents, NDR_OUT | NDR_SET_VALUES, r2);
     703             :                 }
     704           0 :                 if (dce_call->fault_code != 0) {
     705           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_WriteClusterEvents\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     706             :                 }
     707           0 :                 break;
     708             :         }
     709           6 :         case 22: { /* eventlog_GetLogInformation */
     710           6 :                 struct eventlog_GetLogInformation *r2 = (struct eventlog_GetLogInformation *)r;
     711           6 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     712           0 :                         DEBUG(5,("function eventlog_GetLogInformation replied async\n"));
     713             :                 }
     714           6 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     715           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_GetLogInformation, NDR_OUT | NDR_SET_VALUES, r2);
     716             :                 }
     717           6 :                 if (dce_call->fault_code != 0) {
     718           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_GetLogInformation\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     719             :                 }
     720           6 :                 break;
     721             :         }
     722           2 :         case 23: { /* eventlog_FlushEventLog */
     723           2 :                 struct eventlog_FlushEventLog *r2 = (struct eventlog_FlushEventLog *)r;
     724           2 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     725           0 :                         DEBUG(5,("function eventlog_FlushEventLog replied async\n"));
     726             :                 }
     727           2 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     728           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_FlushEventLog, NDR_OUT | NDR_SET_VALUES, r2);
     729             :                 }
     730           2 :                 if (dce_call->fault_code != 0) {
     731           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_FlushEventLog\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     732             :                 }
     733           2 :                 break;
     734             :         }
     735           0 :         case 24: { /* eventlog_ReportEventAndSourceW */
     736           0 :                 struct eventlog_ReportEventAndSourceW *r2 = (struct eventlog_ReportEventAndSourceW *)r;
     737           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     738           0 :                         DEBUG(5,("function eventlog_ReportEventAndSourceW replied async\n"));
     739             :                 }
     740           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     741           0 :                         NDR_PRINT_FUNCTION_DEBUG(eventlog_ReportEventAndSourceW, NDR_OUT | NDR_SET_VALUES, r2);
     742             :                 }
     743           0 :                 if (dce_call->fault_code != 0) {
     744           0 :                         DBG_WARNING("dcerpc_fault %s in eventlog_ReportEventAndSourceW\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     745             :                 }
     746           0 :                 break;
     747             :         }
     748           0 :         default:
     749           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     750           0 :                 break;
     751             :         }
     752             : 
     753          52 :         if (dce_call->fault_code != 0) {
     754           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     755             :         }
     756             : 
     757          52 :         return NT_STATUS_OK;
     758             : }
     759             : 
     760          52 : NTSTATUS eventlog__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     761             : {
     762             :         enum ndr_err_code ndr_err;
     763          52 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     764             : 
     765          52 :         ndr_err = ndr_table_eventlog.calls[opnum].ndr_push(push, NDR_OUT, r);
     766          52 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     767           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     768           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     769             :         }
     770             : 
     771          52 :         return NT_STATUS_OK;
     772             : }
     773             : 
     774           0 : NTSTATUS eventlog__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     775             : {
     776           0 :         return eventlog__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
     777             : }
     778             : 
     779             : static const struct dcesrv_interface dcesrv_eventlog_interface = {
     780             :         .name      = "eventlog",
     781             :         .syntax_id = {{0x82273fdc,0xe32a,0x18c3,{0x3f,0x78},{0x82,0x79,0x29,0xdc,0x23,0xea}},0.0},
     782             :         .bind      = eventlog__op_bind,
     783             :         .unbind    = eventlog__op_unbind,
     784             :         .ndr_pull  = eventlog__op_ndr_pull,
     785             :         .dispatch  = eventlog__op_dispatch,
     786             :         .reply     = eventlog__op_reply,
     787             :         .ndr_push  = eventlog__op_ndr_push,
     788             :         .local     = eventlog__op_local,
     789             : #ifdef DCESRV_INTERFACE_EVENTLOG_FLAGS
     790             :         .flags     = DCESRV_INTERFACE_EVENTLOG_FLAGS
     791             : #else
     792             :         .flags     = 0
     793             : #endif
     794             : };
     795             : 
     796          60 : static NTSTATUS eventlog__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
     797          60 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
     798             :         NTSTATUS status;
     799             : 
     800             :         /* If service is disabled, do not register */
     801          60 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
     802           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
     803             :         }
     804             : 
     805             :         /* If service is embedded, register only for ncacn_np
     806             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
     807             :          */
     808          60 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
     809           0 :                 DBG_INFO("Interface 'eventlog' not registered in endpoint '%s' as service is embedded\n", name);
     810           0 :                 return NT_STATUS_NOT_SUPPORTED;
     811             :         }
     812             : 
     813             :         /*
     814             :          * If rpc service is external then change the default ncalrpc endpoint,
     815             :          * otherwise if the rpc daemon running this service is configured in
     816             :          * fork mode the forked process will race with main smbd to accept the
     817             :          * connections in the default ncalrpc socket, and the forked process
     818             :          * may not have the requested interface registered.
     819             :          * For example, in the ad_member test environment:
     820             :          *
     821             :          *   rpc_server:lsarpc = external
     822             :          *   rpc_server:samr = external
     823             :          *   rpc_server:netlogon = disabled
     824             :          *   rpc_daemon:lsasd = fork
     825             :          *
     826             :          * With these settings both, the main smbd and all the preforked lsasd
     827             :          * processes would be listening in the default ncalrpc socket if it is
     828             :          * not changed. If a client connection is accepted by one of the lsasd
     829             :          * worker processes and the client asks for an interface not registered
     830             :          * in these processes (winreg for example) it will get an error.
     831             :          */
     832          60 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
     833           0 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "EVENTLOG");
     834           0 :                 if (!NT_STATUS_IS_OK(status)) {
     835           0 :                         return status;
     836             :                 }
     837             :         }
     838             : 
     839          60 :         return NT_STATUS_OK;
     840             : }
     841             : 
     842          60 : static NTSTATUS eventlog__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     843             : {
     844             :         uint32_t i;
     845             :         NTSTATUS ret;
     846             :         struct dcerpc_binding *binding;
     847          58 :         struct dcerpc_binding *binding2 = NULL;
     848             : 
     849             : #ifdef DCESRV_INTERFACE_EVENTLOG_NCACN_NP_SECONDARY_ENDPOINT
     850             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_EVENTLOG_NCACN_NP_SECONDARY_ENDPOINT;
     851             : #else
     852          58 :         const char *ncacn_np_secondary_endpoint = NULL;
     853             : #endif
     854             : 
     855         118 :         for (i=0;i<ndr_table_eventlog.endpoints->count;i++) {
     856          60 :                 const char *name = ndr_table_eventlog.endpoints->names[i];
     857             : 
     858          60 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
     859          60 :                 if (NT_STATUS_IS_ERR(ret)) {
     860           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
     861           0 :                         return ret;
     862             :                 }
     863             : 
     864          60 :                 ret = eventlog__check_register_in_endpoint("eventlog", binding);
     865          60 :                 if (NT_STATUS_IS_ERR(ret)) {
     866           0 :                         talloc_free(binding);
     867           0 :                         continue;
     868             :                 }
     869             : 
     870          58 :                 if (ncacn_np_secondary_endpoint != NULL) {
     871           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
     872           0 :                         if (NT_STATUS_IS_ERR(ret)) {
     873           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
     874           0 :                                 TALLOC_FREE(binding);
     875           0 :                                 return ret;
     876             :                         }
     877             :                 }
     878             : 
     879          60 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_eventlog_interface, NULL);
     880          60 :                 TALLOC_FREE(binding);
     881          58 :                 TALLOC_FREE(binding2);
     882          60 :                 if (!NT_STATUS_IS_OK(ret)) {
     883           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
     884           0 :                         return ret;
     885             :                 }
     886             :         }
     887             : 
     888          60 :         return NT_STATUS_OK;
     889             : }
     890             : 
     891          19 : static NTSTATUS eventlog__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     892             : {
     893          19 :         return NT_STATUS_OK;
     894             : }
     895             : 
     896           0 : static bool eventlog__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     897             : {
     898           0 :         if (dcesrv_eventlog_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_eventlog_interface.syntax_id.uuid, uuid)) {
     899           0 :                 memcpy(iface,&dcesrv_eventlog_interface, sizeof(*iface));
     900           0 :                 return true;
     901             :         }
     902             : 
     903           0 :         return false;
     904             : }
     905             : 
     906           0 : static bool eventlog__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     907             : {
     908           0 :         if (strcmp(dcesrv_eventlog_interface.name, name)==0) {
     909           0 :                 memcpy(iface, &dcesrv_eventlog_interface, sizeof(*iface));
     910           0 :                 return true;
     911             :         }
     912             : 
     913           0 :         return false;
     914             : }
     915             : 
     916             : static const struct dcesrv_endpoint_server eventlog_ep_server = {
     917             :         /* fill in our name */
     918             :         .name = "eventlog",
     919             : 
     920             :         /* Initialization flag */
     921             :         .initialized = false,
     922             : 
     923             :         /* fill in all the operations */
     924             : #ifdef DCESRV_INTERFACE_EVENTLOG_INIT_SERVER
     925             :         .init_server = DCESRV_INTERFACE_EVENTLOG_INIT_SERVER,
     926             : #else
     927             :         .init_server = eventlog__op_init_server,
     928             : #endif
     929             : #ifdef DCESRV_INTERFACE_EVENTLOG_SHUTDOWN_SERVER
     930             :         .shutdown_server = DCESRV_INTERFACE_EVENTLOG_SHUTDOWN_SERVER,
     931             : #else
     932             :         .shutdown_server = eventlog__op_shutdown_server,
     933             : #endif
     934             :         .interface_by_uuid = eventlog__op_interface_by_uuid,
     935             :         .interface_by_name = eventlog__op_interface_by_name
     936             : };
     937             : 
     938          60 : const struct dcesrv_endpoint_server *eventlog_get_ep_server(void)
     939             : {
     940          60 :         return &eventlog_ep_server;
     941             : }

Generated by: LCOV version 1.13