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

          Line data    Source code
       1             : /* s3 compat server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_winreg.h"
       3             : #include "bin/default/librpc/gen_ndr/ndr_winreg_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             : /* winreg - dcerpc server boilerplate generated by pidl */
      15         783 : static NTSTATUS winreg__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      16             : {
      17         783 :         struct pipes_struct *p = NULL;
      18             : 
      19             :         /* Retrieve pipes struct */
      20         783 :         p = dcesrv_get_pipes_struct(context->conn);
      21         783 :         p->pipe_bound = true;
      22             : #ifdef DCESRV_INTERFACE_WINREG_BIND
      23             :         return DCESRV_INTERFACE_WINREG_BIND(context,iface);
      24             : #else
      25         783 :         return NT_STATUS_OK;
      26             : #endif
      27             : }
      28             : 
      29         783 : static void winreg__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      30             : {
      31             : #ifdef DCESRV_INTERFACE_WINREG_UNBIND
      32             :         DCESRV_INTERFACE_WINREG_UNBIND(context, iface);
      33             : #else
      34         783 :         return;
      35             : #endif
      36             : }
      37             : 
      38      539859 : NTSTATUS winreg__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      539859 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      42             : 
      43      539859 :         dce_call->fault_code = 0;
      44             : 
      45      539859 :         if (opnum >= ndr_table_winreg.num_calls) {
      46           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      47           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      48             :         }
      49             : 
      50      539859 :         *r = talloc_named(mem_ctx, ndr_table_winreg.calls[opnum].struct_size, "struct %s", ndr_table_winreg.calls[opnum].name);
      51      539859 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      52             : 
      53             :         /* unravel the NDR for the packet */
      54      539859 :         ndr_err = ndr_table_winreg.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      55      539859 :         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      539859 :         return NT_STATUS_OK;
      61             : }
      62             : 
      63      539859 : static NTSTATUS winreg__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
      64             : {
      65      539859 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      66      539859 :         struct pipes_struct *p = NULL;
      67      539859 :         struct auth_session_info *pipe_session_info = NULL;
      68      539859 :         NTSTATUS status = NT_STATUS_OK;
      69      539859 :         bool impersonated = false;
      70             : 
      71             :         /* Retrieve pipes struct */
      72      539859 :         p = dcesrv_get_pipes_struct(dce_call->conn);
      73             :         /* Update pipes struct opnum */
      74      539859 :         p->opnum = opnum;
      75      539859 :         p->dce_call = dce_call;
      76      539859 :         p->mem_ctx = mem_ctx;
      77             :         /* Update pipes struct session info */
      78      539859 :         pipe_session_info = p->session_info;
      79      539859 :         p->session_info = dce_call->auth_state->session_info;
      80      539859 :         p->auth.auth_type = dce_call->auth_state->auth_type;
      81      539859 :         p->auth.auth_level = dce_call->auth_state->auth_level;
      82      539859 :         p->auth.auth_context_id = dce_call->auth_state->auth_context_id;
      83             :         /* Reset pipes struct fault state */
      84      539859 :         p->fault_state = 0;
      85             : 
      86             :         /* Impersonate */
      87      539859 :         if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
      88      106393 :                 impersonated = become_authenticated_pipe_user(p->session_info);
      89      106393 :                 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      539859 :         switch (opnum) {
      97          67 :         case 0: { /* winreg_OpenHKCR */
      98          67 :                 struct winreg_OpenHKCR *r2 = (struct winreg_OpenHKCR *)r;
      99          67 :                 if (DEBUGLEVEL >= 10) {
     100           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCR, NDR_IN, r2);
     101             :                 }
     102          67 :                 NDR_ZERO_STRUCT(r2->out);
     103          67 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     104          67 :                 if (r2->out.handle == NULL) {
     105           0 :                         status = NT_STATUS_NO_MEMORY;
     106           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     107           0 :                         goto fail;
     108             :                 }
     109             : 
     110          67 :                 r2->out.result = _winreg_OpenHKCR(p, r2);
     111          67 :                 break;
     112             :         }
     113          67 :         case 1: { /* winreg_OpenHKCU */
     114          67 :                 struct winreg_OpenHKCU *r2 = (struct winreg_OpenHKCU *)r;
     115          67 :                 if (DEBUGLEVEL >= 10) {
     116           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCU, NDR_IN, r2);
     117             :                 }
     118          67 :                 NDR_ZERO_STRUCT(r2->out);
     119          67 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     120          67 :                 if (r2->out.handle == NULL) {
     121           0 :                         status = NT_STATUS_NO_MEMORY;
     122           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     123           0 :                         goto fail;
     124             :                 }
     125             : 
     126          67 :                 r2->out.result = _winreg_OpenHKCU(p, r2);
     127          67 :                 break;
     128             :         }
     129       43960 :         case 2: { /* winreg_OpenHKLM */
     130       43960 :                 struct winreg_OpenHKLM *r2 = (struct winreg_OpenHKLM *)r;
     131       43960 :                 if (DEBUGLEVEL >= 10) {
     132           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKLM, NDR_IN, r2);
     133             :                 }
     134       43960 :                 NDR_ZERO_STRUCT(r2->out);
     135       43960 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     136       43960 :                 if (r2->out.handle == NULL) {
     137           0 :                         status = NT_STATUS_NO_MEMORY;
     138           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     139           0 :                         goto fail;
     140             :                 }
     141             : 
     142       43960 :                 r2->out.result = _winreg_OpenHKLM(p, r2);
     143       43960 :                 break;
     144             :         }
     145           0 :         case 3: { /* winreg_OpenHKPD */
     146           0 :                 struct winreg_OpenHKPD *r2 = (struct winreg_OpenHKPD *)r;
     147           0 :                 if (DEBUGLEVEL >= 10) {
     148           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPD, NDR_IN, r2);
     149             :                 }
     150           0 :                 NDR_ZERO_STRUCT(r2->out);
     151           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     152           0 :                 if (r2->out.handle == NULL) {
     153           0 :                         status = NT_STATUS_NO_MEMORY;
     154           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     155           0 :                         goto fail;
     156             :                 }
     157             : 
     158           0 :                 r2->out.result = _winreg_OpenHKPD(p, r2);
     159           0 :                 break;
     160             :         }
     161          67 :         case 4: { /* winreg_OpenHKU */
     162          67 :                 struct winreg_OpenHKU *r2 = (struct winreg_OpenHKU *)r;
     163          67 :                 if (DEBUGLEVEL >= 10) {
     164           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKU, NDR_IN, r2);
     165             :                 }
     166          67 :                 NDR_ZERO_STRUCT(r2->out);
     167          67 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     168          67 :                 if (r2->out.handle == NULL) {
     169           0 :                         status = NT_STATUS_NO_MEMORY;
     170           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     171           0 :                         goto fail;
     172             :                 }
     173             : 
     174          67 :                 r2->out.result = _winreg_OpenHKU(p, r2);
     175          67 :                 break;
     176             :         }
     177       89279 :         case 5: { /* winreg_CloseKey */
     178       89279 :                 struct winreg_CloseKey *r2 = (struct winreg_CloseKey *)r;
     179       89279 :                 if (DEBUGLEVEL >= 10) {
     180           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_CloseKey, NDR_IN, r2);
     181             :                 }
     182       89279 :                 NDR_ZERO_STRUCT(r2->out);
     183       89279 :                 r2->out.handle = r2->in.handle;
     184       89279 :                 r2->out.result = _winreg_CloseKey(p, r2);
     185       89279 :                 break;
     186             :         }
     187        6887 :         case 6: { /* winreg_CreateKey */
     188        6887 :                 struct winreg_CreateKey *r2 = (struct winreg_CreateKey *)r;
     189        6887 :                 if (DEBUGLEVEL >= 10) {
     190           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_CreateKey, NDR_IN, r2);
     191             :                 }
     192        6887 :                 NDR_ZERO_STRUCT(r2->out);
     193        6887 :                 r2->out.action_taken = r2->in.action_taken;
     194        6887 :                 r2->out.new_handle = talloc_zero(r2, struct policy_handle);
     195        6887 :                 if (r2->out.new_handle == NULL) {
     196           0 :                         status = NT_STATUS_NO_MEMORY;
     197           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     198           0 :                         goto fail;
     199             :                 }
     200             : 
     201        6887 :                 r2->out.result = _winreg_CreateKey(p, r2);
     202        6887 :                 break;
     203             :         }
     204        3078 :         case 7: { /* winreg_DeleteKey */
     205        3078 :                 struct winreg_DeleteKey *r2 = (struct winreg_DeleteKey *)r;
     206        3078 :                 if (DEBUGLEVEL >= 10) {
     207           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKey, NDR_IN, r2);
     208             :                 }
     209        3078 :                 r2->out.result = _winreg_DeleteKey(p, r2);
     210        3078 :                 break;
     211             :         }
     212        4142 :         case 8: { /* winreg_DeleteValue */
     213        4142 :                 struct winreg_DeleteValue *r2 = (struct winreg_DeleteValue *)r;
     214        4142 :                 if (DEBUGLEVEL >= 10) {
     215           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteValue, NDR_IN, r2);
     216             :                 }
     217        4142 :                 r2->out.result = _winreg_DeleteValue(p, r2);
     218        4142 :                 break;
     219             :         }
     220       66082 :         case 9: { /* winreg_EnumKey */
     221       66082 :                 struct winreg_EnumKey *r2 = (struct winreg_EnumKey *)r;
     222       66082 :                 if (DEBUGLEVEL >= 10) {
     223           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumKey, NDR_IN, r2);
     224             :                 }
     225       66082 :                 NDR_ZERO_STRUCT(r2->out);
     226       66082 :                 r2->out.name = r2->in.name;
     227       66082 :                 r2->out.keyclass = r2->in.keyclass;
     228       66082 :                 r2->out.last_changed_time = r2->in.last_changed_time;
     229       66082 :                 r2->out.result = _winreg_EnumKey(p, r2);
     230       66082 :                 break;
     231             :         }
     232      189933 :         case 10: { /* winreg_EnumValue */
     233      189933 :                 struct winreg_EnumValue *r2 = (struct winreg_EnumValue *)r;
     234      189933 :                 if (DEBUGLEVEL >= 10) {
     235           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumValue, NDR_IN, r2);
     236             :                 }
     237      189933 :                 NDR_ZERO_STRUCT(r2->out);
     238      189933 :                 r2->out.name = r2->in.name;
     239      189933 :                 r2->out.type = r2->in.type;
     240      189933 :                 r2->out.value = r2->in.value;
     241      189933 :                 r2->out.size = r2->in.size;
     242      189933 :                 r2->out.length = r2->in.length;
     243      189933 :                 r2->out.result = _winreg_EnumValue(p, r2);
     244      189933 :                 break;
     245             :         }
     246         536 :         case 11: { /* winreg_FlushKey */
     247         536 :                 struct winreg_FlushKey *r2 = (struct winreg_FlushKey *)r;
     248         536 :                 if (DEBUGLEVEL >= 10) {
     249           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_FlushKey, NDR_IN, r2);
     250             :                 }
     251         536 :                 r2->out.result = _winreg_FlushKey(p, r2);
     252         536 :                 break;
     253             :         }
     254           0 :         case 12: { /* winreg_GetKeySecurity */
     255           0 :                 struct winreg_GetKeySecurity *r2 = (struct winreg_GetKeySecurity *)r;
     256           0 :                 if (DEBUGLEVEL >= 10) {
     257           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetKeySecurity, NDR_IN, r2);
     258             :                 }
     259           0 :                 NDR_ZERO_STRUCT(r2->out);
     260           0 :                 r2->out.sd = r2->in.sd;
     261           0 :                 r2->out.result = _winreg_GetKeySecurity(p, r2);
     262           0 :                 break;
     263             :         }
     264           0 :         case 13: { /* winreg_LoadKey */
     265           0 :                 struct winreg_LoadKey *r2 = (struct winreg_LoadKey *)r;
     266           0 :                 if (DEBUGLEVEL >= 10) {
     267           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_LoadKey, NDR_IN, r2);
     268             :                 }
     269           0 :                 r2->out.result = _winreg_LoadKey(p, r2);
     270           0 :                 break;
     271             :         }
     272         268 :         case 14: { /* winreg_NotifyChangeKeyValue */
     273         268 :                 struct winreg_NotifyChangeKeyValue *r2 = (struct winreg_NotifyChangeKeyValue *)r;
     274         268 :                 if (DEBUGLEVEL >= 10) {
     275           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_NotifyChangeKeyValue, NDR_IN, r2);
     276             :                 }
     277         268 :                 r2->out.result = _winreg_NotifyChangeKeyValue(p, r2);
     278         268 :                 break;
     279             :         }
     280       42507 :         case 15: { /* winreg_OpenKey */
     281       42507 :                 struct winreg_OpenKey *r2 = (struct winreg_OpenKey *)r;
     282       42507 :                 if (DEBUGLEVEL >= 10) {
     283           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenKey, NDR_IN, r2);
     284             :                 }
     285       42507 :                 NDR_ZERO_STRUCT(r2->out);
     286       42507 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     287       42507 :                 if (r2->out.handle == NULL) {
     288           0 :                         status = NT_STATUS_NO_MEMORY;
     289           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     290           0 :                         goto fail;
     291             :                 }
     292             : 
     293       42507 :                 r2->out.result = _winreg_OpenKey(p, r2);
     294       42507 :                 break;
     295             :         }
     296       20297 :         case 16: { /* winreg_QueryInfoKey */
     297       20297 :                 struct winreg_QueryInfoKey *r2 = (struct winreg_QueryInfoKey *)r;
     298       20297 :                 if (DEBUGLEVEL >= 10) {
     299           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryInfoKey, NDR_IN, r2);
     300             :                 }
     301       20297 :                 NDR_ZERO_STRUCT(r2->out);
     302       20297 :                 r2->out.classname = r2->in.classname;
     303       20297 :                 r2->out.num_subkeys = talloc_zero(r2, uint32_t);
     304       20297 :                 if (r2->out.num_subkeys == NULL) {
     305           0 :                         status = NT_STATUS_NO_MEMORY;
     306           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     307           0 :                         goto fail;
     308             :                 }
     309             : 
     310       20297 :                 r2->out.max_subkeylen = talloc_zero(r2, uint32_t);
     311       20297 :                 if (r2->out.max_subkeylen == NULL) {
     312           0 :                         status = NT_STATUS_NO_MEMORY;
     313           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     314           0 :                         goto fail;
     315             :                 }
     316             : 
     317       20297 :                 r2->out.max_classlen = talloc_zero(r2, uint32_t);
     318       20297 :                 if (r2->out.max_classlen == NULL) {
     319           0 :                         status = NT_STATUS_NO_MEMORY;
     320           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     321           0 :                         goto fail;
     322             :                 }
     323             : 
     324       20297 :                 r2->out.num_values = talloc_zero(r2, uint32_t);
     325       20297 :                 if (r2->out.num_values == NULL) {
     326           0 :                         status = NT_STATUS_NO_MEMORY;
     327           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     328           0 :                         goto fail;
     329             :                 }
     330             : 
     331       20297 :                 r2->out.max_valnamelen = talloc_zero(r2, uint32_t);
     332       20297 :                 if (r2->out.max_valnamelen == NULL) {
     333           0 :                         status = NT_STATUS_NO_MEMORY;
     334           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     335           0 :                         goto fail;
     336             :                 }
     337             : 
     338       20297 :                 r2->out.max_valbufsize = talloc_zero(r2, uint32_t);
     339       20297 :                 if (r2->out.max_valbufsize == NULL) {
     340           0 :                         status = NT_STATUS_NO_MEMORY;
     341           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     342           0 :                         goto fail;
     343             :                 }
     344             : 
     345       20297 :                 r2->out.secdescsize = talloc_zero(r2, uint32_t);
     346       20297 :                 if (r2->out.secdescsize == NULL) {
     347           0 :                         status = NT_STATUS_NO_MEMORY;
     348           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     349           0 :                         goto fail;
     350             :                 }
     351             : 
     352       20297 :                 r2->out.last_changed_time = talloc_zero(r2, NTTIME);
     353       20297 :                 if (r2->out.last_changed_time == NULL) {
     354           0 :                         status = NT_STATUS_NO_MEMORY;
     355           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     356           0 :                         goto fail;
     357             :                 }
     358             : 
     359       20297 :                 r2->out.result = _winreg_QueryInfoKey(p, r2);
     360       20297 :                 break;
     361             :         }
     362       57413 :         case 17: { /* winreg_QueryValue */
     363       57413 :                 struct winreg_QueryValue *r2 = (struct winreg_QueryValue *)r;
     364       57413 :                 if (DEBUGLEVEL >= 10) {
     365           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryValue, NDR_IN, r2);
     366             :                 }
     367       57413 :                 NDR_ZERO_STRUCT(r2->out);
     368       57413 :                 r2->out.type = r2->in.type;
     369       57413 :                 r2->out.data = r2->in.data;
     370       57413 :                 r2->out.data_size = r2->in.data_size;
     371       57413 :                 r2->out.data_length = r2->in.data_length;
     372       57413 :                 r2->out.result = _winreg_QueryValue(p, r2);
     373       57413 :                 break;
     374             :         }
     375           0 :         case 18: { /* winreg_ReplaceKey */
     376           0 :                 struct winreg_ReplaceKey *r2 = (struct winreg_ReplaceKey *)r;
     377           0 :                 if (DEBUGLEVEL >= 10) {
     378           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_ReplaceKey, NDR_IN, r2);
     379             :                 }
     380           0 :                 r2->out.result = _winreg_ReplaceKey(p, r2);
     381           0 :                 break;
     382             :         }
     383           0 :         case 19: { /* winreg_RestoreKey */
     384           0 :                 struct winreg_RestoreKey *r2 = (struct winreg_RestoreKey *)r;
     385           0 :                 if (DEBUGLEVEL >= 10) {
     386           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_RestoreKey, NDR_IN, r2);
     387             :                 }
     388           0 :                 r2->out.result = _winreg_RestoreKey(p, r2);
     389           0 :                 break;
     390             :         }
     391           0 :         case 20: { /* winreg_SaveKey */
     392           0 :                 struct winreg_SaveKey *r2 = (struct winreg_SaveKey *)r;
     393           0 :                 if (DEBUGLEVEL >= 10) {
     394           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKey, NDR_IN, r2);
     395             :                 }
     396           0 :                 r2->out.result = _winreg_SaveKey(p, r2);
     397           0 :                 break;
     398             :         }
     399           0 :         case 21: { /* winreg_SetKeySecurity */
     400           0 :                 struct winreg_SetKeySecurity *r2 = (struct winreg_SetKeySecurity *)r;
     401           0 :                 if (DEBUGLEVEL >= 10) {
     402           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetKeySecurity, NDR_IN, r2);
     403             :                 }
     404           0 :                 r2->out.result = _winreg_SetKeySecurity(p, r2);
     405           0 :                 break;
     406             :         }
     407       14832 :         case 22: { /* winreg_SetValue */
     408       14832 :                 struct winreg_SetValue *r2 = (struct winreg_SetValue *)r;
     409       14832 :                 if (DEBUGLEVEL >= 10) {
     410           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetValue, NDR_IN, r2);
     411             :                 }
     412       14832 :                 r2->out.result = _winreg_SetValue(p, r2);
     413       14832 :                 break;
     414             :         }
     415           0 :         case 23: { /* winreg_UnLoadKey */
     416           0 :                 struct winreg_UnLoadKey *r2 = (struct winreg_UnLoadKey *)r;
     417           0 :                 if (DEBUGLEVEL >= 10) {
     418           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_UnLoadKey, NDR_IN, r2);
     419             :                 }
     420           0 :                 r2->out.result = _winreg_UnLoadKey(p, r2);
     421           0 :                 break;
     422             :         }
     423           0 :         case 24: { /* winreg_InitiateSystemShutdown */
     424           0 :                 struct winreg_InitiateSystemShutdown *r2 = (struct winreg_InitiateSystemShutdown *)r;
     425           0 :                 if (DEBUGLEVEL >= 10) {
     426           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdown, NDR_IN, r2);
     427             :                 }
     428           0 :                 r2->out.result = _winreg_InitiateSystemShutdown(p, r2);
     429           0 :                 break;
     430             :         }
     431           0 :         case 25: { /* winreg_AbortSystemShutdown */
     432           0 :                 struct winreg_AbortSystemShutdown *r2 = (struct winreg_AbortSystemShutdown *)r;
     433           0 :                 if (DEBUGLEVEL >= 10) {
     434           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_AbortSystemShutdown, NDR_IN, r2);
     435             :                 }
     436           0 :                 r2->out.result = _winreg_AbortSystemShutdown(p, r2);
     437           0 :                 break;
     438             :         }
     439         268 :         case 26: { /* winreg_GetVersion */
     440         268 :                 struct winreg_GetVersion *r2 = (struct winreg_GetVersion *)r;
     441         268 :                 if (DEBUGLEVEL >= 10) {
     442           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetVersion, NDR_IN, r2);
     443             :                 }
     444         268 :                 NDR_ZERO_STRUCT(r2->out);
     445         268 :                 r2->out.version = talloc_zero(r2, uint32_t);
     446         268 :                 if (r2->out.version == NULL) {
     447           0 :                         status = NT_STATUS_NO_MEMORY;
     448           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     449           0 :                         goto fail;
     450             :                 }
     451             : 
     452         268 :                 r2->out.result = _winreg_GetVersion(p, r2);
     453         268 :                 break;
     454             :         }
     455           0 :         case 27: { /* winreg_OpenHKCC */
     456           0 :                 struct winreg_OpenHKCC *r2 = (struct winreg_OpenHKCC *)r;
     457           0 :                 if (DEBUGLEVEL >= 10) {
     458           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCC, NDR_IN, r2);
     459             :                 }
     460           0 :                 NDR_ZERO_STRUCT(r2->out);
     461           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     462           0 :                 if (r2->out.handle == NULL) {
     463           0 :                         status = NT_STATUS_NO_MEMORY;
     464           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     465           0 :                         goto fail;
     466             :                 }
     467             : 
     468           0 :                 r2->out.result = _winreg_OpenHKCC(p, r2);
     469           0 :                 break;
     470             :         }
     471           0 :         case 28: { /* winreg_OpenHKDD */
     472           0 :                 struct winreg_OpenHKDD *r2 = (struct winreg_OpenHKDD *)r;
     473           0 :                 if (DEBUGLEVEL >= 10) {
     474           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKDD, NDR_IN, r2);
     475             :                 }
     476           0 :                 NDR_ZERO_STRUCT(r2->out);
     477           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     478           0 :                 if (r2->out.handle == NULL) {
     479           0 :                         status = NT_STATUS_NO_MEMORY;
     480           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     481           0 :                         goto fail;
     482             :                 }
     483             : 
     484           0 :                 r2->out.result = _winreg_OpenHKDD(p, r2);
     485           0 :                 break;
     486             :         }
     487          88 :         case 29: { /* winreg_QueryMultipleValues */
     488          88 :                 struct winreg_QueryMultipleValues *r2 = (struct winreg_QueryMultipleValues *)r;
     489          88 :                 if (DEBUGLEVEL >= 10) {
     490           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues, NDR_IN, r2);
     491             :                 }
     492          88 :                 NDR_ZERO_STRUCT(r2->out);
     493          88 :                 r2->out.buffer = r2->in.buffer;
     494          88 :                 r2->out.buffer_size = r2->in.buffer_size;
     495          88 :                 r2->out.values_out = talloc_zero_array(r2, struct QueryMultipleValue, r2->in.num_values);
     496          88 :                 if (r2->out.values_out == NULL) {
     497           0 :                         status = NT_STATUS_NO_MEMORY;
     498           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     499           0 :                         goto fail;
     500             :                 }
     501             : 
     502          88 :                 r2->out.result = _winreg_QueryMultipleValues(p, r2);
     503          88 :                 break;
     504             :         }
     505           0 :         case 30: { /* winreg_InitiateSystemShutdownEx */
     506           0 :                 struct winreg_InitiateSystemShutdownEx *r2 = (struct winreg_InitiateSystemShutdownEx *)r;
     507           0 :                 if (DEBUGLEVEL >= 10) {
     508           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdownEx, NDR_IN, r2);
     509             :                 }
     510           0 :                 r2->out.result = _winreg_InitiateSystemShutdownEx(p, r2);
     511           0 :                 break;
     512             :         }
     513           0 :         case 31: { /* winreg_SaveKeyEx */
     514           0 :                 struct winreg_SaveKeyEx *r2 = (struct winreg_SaveKeyEx *)r;
     515           0 :                 if (DEBUGLEVEL >= 10) {
     516           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKeyEx, NDR_IN, r2);
     517             :                 }
     518           0 :                 r2->out.result = _winreg_SaveKeyEx(p, r2);
     519           0 :                 break;
     520             :         }
     521           0 :         case 32: { /* winreg_OpenHKPT */
     522           0 :                 struct winreg_OpenHKPT *r2 = (struct winreg_OpenHKPT *)r;
     523           0 :                 if (DEBUGLEVEL >= 10) {
     524           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPT, NDR_IN, r2);
     525             :                 }
     526           0 :                 NDR_ZERO_STRUCT(r2->out);
     527           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     528           0 :                 if (r2->out.handle == NULL) {
     529           0 :                         status = NT_STATUS_NO_MEMORY;
     530           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     531           0 :                         goto fail;
     532             :                 }
     533             : 
     534           0 :                 r2->out.result = _winreg_OpenHKPT(p, r2);
     535           0 :                 break;
     536             :         }
     537           0 :         case 33: { /* winreg_OpenHKPN */
     538           0 :                 struct winreg_OpenHKPN *r2 = (struct winreg_OpenHKPN *)r;
     539           0 :                 if (DEBUGLEVEL >= 10) {
     540           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPN, NDR_IN, r2);
     541             :                 }
     542           0 :                 NDR_ZERO_STRUCT(r2->out);
     543           0 :                 r2->out.handle = talloc_zero(r2, struct policy_handle);
     544           0 :                 if (r2->out.handle == NULL) {
     545           0 :                         status = NT_STATUS_NO_MEMORY;
     546           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     547           0 :                         goto fail;
     548             :                 }
     549             : 
     550           0 :                 r2->out.result = _winreg_OpenHKPN(p, r2);
     551           0 :                 break;
     552             :         }
     553          88 :         case 34: { /* winreg_QueryMultipleValues2 */
     554          88 :                 struct winreg_QueryMultipleValues2 *r2 = (struct winreg_QueryMultipleValues2 *)r;
     555          88 :                 if (DEBUGLEVEL >= 10) {
     556           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues2, NDR_IN, r2);
     557             :                 }
     558          88 :                 NDR_ZERO_STRUCT(r2->out);
     559          88 :                 r2->out.buffer = r2->in.buffer;
     560          88 :                 r2->out.values_out = talloc_zero_array(r2, struct QueryMultipleValue, r2->in.num_values);
     561          88 :                 if (r2->out.values_out == NULL) {
     562           0 :                         status = NT_STATUS_NO_MEMORY;
     563           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     564           0 :                         goto fail;
     565             :                 }
     566             : 
     567          88 :                 r2->out.needed = talloc_zero(r2, uint32_t);
     568          88 :                 if (r2->out.needed == NULL) {
     569           0 :                         status = NT_STATUS_NO_MEMORY;
     570           0 :                         p->fault_state = DCERPC_FAULT_CANT_PERFORM;
     571           0 :                         goto fail;
     572             :                 }
     573             : 
     574          88 :                 r2->out.result = _winreg_QueryMultipleValues2(p, r2);
     575          88 :                 break;
     576             :         }
     577           0 :         case 35: { /* winreg_DeleteKeyEx */
     578           0 :                 struct winreg_DeleteKeyEx *r2 = (struct winreg_DeleteKeyEx *)r;
     579           0 :                 if (DEBUGLEVEL >= 10) {
     580           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKeyEx, NDR_IN, r2);
     581             :                 }
     582           0 :                 r2->out.result = _winreg_DeleteKeyEx(p, r2);
     583           0 :                 break;
     584             :         }
     585           0 :         default:
     586           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     587           0 :                 break;
     588             :         }
     589             : 
     590      539859 : fail:
     591             :         /* Unimpersonate */
     592      539859 :         if (impersonated) {
     593      106393 :                 unbecome_authenticated_pipe_user();
     594             :         }
     595             : 
     596      539859 :         p->dce_call = NULL;
     597      539859 :         p->mem_ctx = NULL;
     598             :         /* Restore session info */
     599      539859 :         p->session_info = pipe_session_info;
     600      539859 :         p->auth.auth_type = 0;
     601      539859 :         p->auth.auth_level = 0;
     602      539859 :         p->auth.auth_context_id = 0;
     603             :         /* Check pipes struct fault state */
     604      539859 :         if (p->fault_state != 0) {
     605          46 :                 dce_call->fault_code = p->fault_state;
     606             :         }
     607      539859 :         if (dce_call->fault_code != 0) {
     608          46 :                 status = NT_STATUS_NET_WRITE_FAULT;
     609             :         }
     610             : 
     611      539859 :         return status;
     612             : }
     613             : 
     614      106393 : NTSTATUS winreg__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     615             : {
     616      106393 :         return winreg__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
     617             : }
     618             : 
     619      539813 : NTSTATUS winreg__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     620             : {
     621      539813 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     622             : 
     623      539813 :         switch (opnum) {
     624          67 :         case 0: { /* winreg_OpenHKCR */
     625          67 :                 struct winreg_OpenHKCR *r2 = (struct winreg_OpenHKCR *)r;
     626          67 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     627           0 :                         DEBUG(5,("function winreg_OpenHKCR replied async\n"));
     628             :                 }
     629          67 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     630           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCR, NDR_OUT | NDR_SET_VALUES, r2);
     631             :                 }
     632          67 :                 if (dce_call->fault_code != 0) {
     633           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKCR\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     634             :                 }
     635          67 :                 break;
     636             :         }
     637          67 :         case 1: { /* winreg_OpenHKCU */
     638          67 :                 struct winreg_OpenHKCU *r2 = (struct winreg_OpenHKCU *)r;
     639          67 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     640           0 :                         DEBUG(5,("function winreg_OpenHKCU replied async\n"));
     641             :                 }
     642          67 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     643           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCU, NDR_OUT | NDR_SET_VALUES, r2);
     644             :                 }
     645          67 :                 if (dce_call->fault_code != 0) {
     646           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKCU\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     647             :                 }
     648          67 :                 break;
     649             :         }
     650       43960 :         case 2: { /* winreg_OpenHKLM */
     651       43960 :                 struct winreg_OpenHKLM *r2 = (struct winreg_OpenHKLM *)r;
     652       43960 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     653           0 :                         DEBUG(5,("function winreg_OpenHKLM replied async\n"));
     654             :                 }
     655       43960 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     656           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKLM, NDR_OUT | NDR_SET_VALUES, r2);
     657             :                 }
     658       43960 :                 if (dce_call->fault_code != 0) {
     659           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKLM\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     660             :                 }
     661       43956 :                 break;
     662             :         }
     663           0 :         case 3: { /* winreg_OpenHKPD */
     664           0 :                 struct winreg_OpenHKPD *r2 = (struct winreg_OpenHKPD *)r;
     665           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     666           0 :                         DEBUG(5,("function winreg_OpenHKPD replied async\n"));
     667             :                 }
     668           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     669           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPD, NDR_OUT | NDR_SET_VALUES, r2);
     670             :                 }
     671           0 :                 if (dce_call->fault_code != 0) {
     672           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKPD\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     673             :                 }
     674           0 :                 break;
     675             :         }
     676          67 :         case 4: { /* winreg_OpenHKU */
     677          67 :                 struct winreg_OpenHKU *r2 = (struct winreg_OpenHKU *)r;
     678          67 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     679           0 :                         DEBUG(5,("function winreg_OpenHKU replied async\n"));
     680             :                 }
     681          67 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     682           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKU, NDR_OUT | NDR_SET_VALUES, r2);
     683             :                 }
     684          67 :                 if (dce_call->fault_code != 0) {
     685           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKU\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     686             :                 }
     687          67 :                 break;
     688             :         }
     689       89233 :         case 5: { /* winreg_CloseKey */
     690       89233 :                 struct winreg_CloseKey *r2 = (struct winreg_CloseKey *)r;
     691       89233 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     692           0 :                         DEBUG(5,("function winreg_CloseKey replied async\n"));
     693             :                 }
     694       89233 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     695           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_CloseKey, NDR_OUT | NDR_SET_VALUES, r2);
     696             :                 }
     697       89233 :                 if (dce_call->fault_code != 0) {
     698           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_CloseKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     699             :                 }
     700       89213 :                 break;
     701             :         }
     702        6887 :         case 6: { /* winreg_CreateKey */
     703        6887 :                 struct winreg_CreateKey *r2 = (struct winreg_CreateKey *)r;
     704        6887 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     705           0 :                         DEBUG(5,("function winreg_CreateKey replied async\n"));
     706             :                 }
     707        6887 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     708           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_CreateKey, NDR_OUT | NDR_SET_VALUES, r2);
     709             :                 }
     710        6887 :                 if (dce_call->fault_code != 0) {
     711           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_CreateKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     712             :                 }
     713        6871 :                 break;
     714             :         }
     715        3078 :         case 7: { /* winreg_DeleteKey */
     716        3078 :                 struct winreg_DeleteKey *r2 = (struct winreg_DeleteKey *)r;
     717        3078 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     718           0 :                         DEBUG(5,("function winreg_DeleteKey replied async\n"));
     719             :                 }
     720        3078 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     721           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKey, NDR_OUT | NDR_SET_VALUES, r2);
     722             :                 }
     723        3078 :                 if (dce_call->fault_code != 0) {
     724           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_DeleteKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     725             :                 }
     726        3078 :                 break;
     727             :         }
     728        4142 :         case 8: { /* winreg_DeleteValue */
     729        4142 :                 struct winreg_DeleteValue *r2 = (struct winreg_DeleteValue *)r;
     730        4142 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     731           0 :                         DEBUG(5,("function winreg_DeleteValue replied async\n"));
     732             :                 }
     733        4142 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     734           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteValue, NDR_OUT | NDR_SET_VALUES, r2);
     735             :                 }
     736        4142 :                 if (dce_call->fault_code != 0) {
     737           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_DeleteValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     738             :                 }
     739        4142 :                 break;
     740             :         }
     741       66082 :         case 9: { /* winreg_EnumKey */
     742       66082 :                 struct winreg_EnumKey *r2 = (struct winreg_EnumKey *)r;
     743       66082 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     744           0 :                         DEBUG(5,("function winreg_EnumKey replied async\n"));
     745             :                 }
     746       66082 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     747           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumKey, NDR_OUT | NDR_SET_VALUES, r2);
     748             :                 }
     749       66082 :                 if (dce_call->fault_code != 0) {
     750           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_EnumKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     751             :                 }
     752       66074 :                 break;
     753             :         }
     754      189933 :         case 10: { /* winreg_EnumValue */
     755      189933 :                 struct winreg_EnumValue *r2 = (struct winreg_EnumValue *)r;
     756      189933 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     757           0 :                         DEBUG(5,("function winreg_EnumValue replied async\n"));
     758             :                 }
     759      189933 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     760           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_EnumValue, NDR_OUT | NDR_SET_VALUES, r2);
     761             :                 }
     762      189933 :                 if (dce_call->fault_code != 0) {
     763           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_EnumValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     764             :                 }
     765      189933 :                 break;
     766             :         }
     767         536 :         case 11: { /* winreg_FlushKey */
     768         536 :                 struct winreg_FlushKey *r2 = (struct winreg_FlushKey *)r;
     769         536 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     770           0 :                         DEBUG(5,("function winreg_FlushKey replied async\n"));
     771             :                 }
     772         536 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     773           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_FlushKey, NDR_OUT | NDR_SET_VALUES, r2);
     774             :                 }
     775         536 :                 if (dce_call->fault_code != 0) {
     776           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_FlushKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     777             :                 }
     778         536 :                 break;
     779             :         }
     780           0 :         case 12: { /* winreg_GetKeySecurity */
     781           0 :                 struct winreg_GetKeySecurity *r2 = (struct winreg_GetKeySecurity *)r;
     782           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     783           0 :                         DEBUG(5,("function winreg_GetKeySecurity replied async\n"));
     784             :                 }
     785           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     786           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetKeySecurity, NDR_OUT | NDR_SET_VALUES, r2);
     787             :                 }
     788           0 :                 if (dce_call->fault_code != 0) {
     789           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_GetKeySecurity\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     790             :                 }
     791           0 :                 break;
     792             :         }
     793           0 :         case 13: { /* winreg_LoadKey */
     794           0 :                 struct winreg_LoadKey *r2 = (struct winreg_LoadKey *)r;
     795           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     796           0 :                         DEBUG(5,("function winreg_LoadKey replied async\n"));
     797             :                 }
     798           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     799           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_LoadKey, NDR_OUT | NDR_SET_VALUES, r2);
     800             :                 }
     801           0 :                 if (dce_call->fault_code != 0) {
     802           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_LoadKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     803             :                 }
     804           0 :                 break;
     805             :         }
     806         268 :         case 14: { /* winreg_NotifyChangeKeyValue */
     807         268 :                 struct winreg_NotifyChangeKeyValue *r2 = (struct winreg_NotifyChangeKeyValue *)r;
     808         268 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     809           0 :                         DEBUG(5,("function winreg_NotifyChangeKeyValue replied async\n"));
     810             :                 }
     811         268 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     812           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_NotifyChangeKeyValue, NDR_OUT | NDR_SET_VALUES, r2);
     813             :                 }
     814         268 :                 if (dce_call->fault_code != 0) {
     815           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_NotifyChangeKeyValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     816             :                 }
     817         268 :                 break;
     818             :         }
     819       42507 :         case 15: { /* winreg_OpenKey */
     820       42507 :                 struct winreg_OpenKey *r2 = (struct winreg_OpenKey *)r;
     821       42507 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     822           0 :                         DEBUG(5,("function winreg_OpenKey replied async\n"));
     823             :                 }
     824       42507 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     825           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenKey, NDR_OUT | NDR_SET_VALUES, r2);
     826             :                 }
     827       42507 :                 if (dce_call->fault_code != 0) {
     828           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     829             :                 }
     830       42503 :                 break;
     831             :         }
     832       20297 :         case 16: { /* winreg_QueryInfoKey */
     833       20297 :                 struct winreg_QueryInfoKey *r2 = (struct winreg_QueryInfoKey *)r;
     834       20297 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     835           0 :                         DEBUG(5,("function winreg_QueryInfoKey replied async\n"));
     836             :                 }
     837       20297 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     838           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryInfoKey, NDR_OUT | NDR_SET_VALUES, r2);
     839             :                 }
     840       20297 :                 if (dce_call->fault_code != 0) {
     841           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_QueryInfoKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     842             :                 }
     843       20293 :                 break;
     844             :         }
     845       57413 :         case 17: { /* winreg_QueryValue */
     846       57413 :                 struct winreg_QueryValue *r2 = (struct winreg_QueryValue *)r;
     847       57413 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     848           0 :                         DEBUG(5,("function winreg_QueryValue replied async\n"));
     849             :                 }
     850       57413 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     851           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryValue, NDR_OUT | NDR_SET_VALUES, r2);
     852             :                 }
     853       57413 :                 if (dce_call->fault_code != 0) {
     854           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_QueryValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     855             :                 }
     856       57413 :                 break;
     857             :         }
     858           0 :         case 18: { /* winreg_ReplaceKey */
     859           0 :                 struct winreg_ReplaceKey *r2 = (struct winreg_ReplaceKey *)r;
     860           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     861           0 :                         DEBUG(5,("function winreg_ReplaceKey replied async\n"));
     862             :                 }
     863           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     864           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_ReplaceKey, NDR_OUT | NDR_SET_VALUES, r2);
     865             :                 }
     866           0 :                 if (dce_call->fault_code != 0) {
     867           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_ReplaceKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     868             :                 }
     869           0 :                 break;
     870             :         }
     871           0 :         case 19: { /* winreg_RestoreKey */
     872           0 :                 struct winreg_RestoreKey *r2 = (struct winreg_RestoreKey *)r;
     873           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     874           0 :                         DEBUG(5,("function winreg_RestoreKey replied async\n"));
     875             :                 }
     876           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     877           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_RestoreKey, NDR_OUT | NDR_SET_VALUES, r2);
     878             :                 }
     879           0 :                 if (dce_call->fault_code != 0) {
     880           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_RestoreKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     881             :                 }
     882           0 :                 break;
     883             :         }
     884           0 :         case 20: { /* winreg_SaveKey */
     885           0 :                 struct winreg_SaveKey *r2 = (struct winreg_SaveKey *)r;
     886           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     887           0 :                         DEBUG(5,("function winreg_SaveKey replied async\n"));
     888             :                 }
     889           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     890           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKey, NDR_OUT | NDR_SET_VALUES, r2);
     891             :                 }
     892           0 :                 if (dce_call->fault_code != 0) {
     893           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_SaveKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     894             :                 }
     895           0 :                 break;
     896             :         }
     897           0 :         case 21: { /* winreg_SetKeySecurity */
     898           0 :                 struct winreg_SetKeySecurity *r2 = (struct winreg_SetKeySecurity *)r;
     899           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     900           0 :                         DEBUG(5,("function winreg_SetKeySecurity replied async\n"));
     901             :                 }
     902           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     903           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetKeySecurity, NDR_OUT | NDR_SET_VALUES, r2);
     904             :                 }
     905           0 :                 if (dce_call->fault_code != 0) {
     906           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_SetKeySecurity\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     907             :                 }
     908           0 :                 break;
     909             :         }
     910       14832 :         case 22: { /* winreg_SetValue */
     911       14832 :                 struct winreg_SetValue *r2 = (struct winreg_SetValue *)r;
     912       14832 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     913           0 :                         DEBUG(5,("function winreg_SetValue replied async\n"));
     914             :                 }
     915       14832 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     916           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SetValue, NDR_OUT | NDR_SET_VALUES, r2);
     917             :                 }
     918       14832 :                 if (dce_call->fault_code != 0) {
     919           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_SetValue\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     920             :                 }
     921       14768 :                 break;
     922             :         }
     923           0 :         case 23: { /* winreg_UnLoadKey */
     924           0 :                 struct winreg_UnLoadKey *r2 = (struct winreg_UnLoadKey *)r;
     925           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     926           0 :                         DEBUG(5,("function winreg_UnLoadKey replied async\n"));
     927             :                 }
     928           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     929           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_UnLoadKey, NDR_OUT | NDR_SET_VALUES, r2);
     930             :                 }
     931           0 :                 if (dce_call->fault_code != 0) {
     932           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_UnLoadKey\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     933             :                 }
     934           0 :                 break;
     935             :         }
     936           0 :         case 24: { /* winreg_InitiateSystemShutdown */
     937           0 :                 struct winreg_InitiateSystemShutdown *r2 = (struct winreg_InitiateSystemShutdown *)r;
     938           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     939           0 :                         DEBUG(5,("function winreg_InitiateSystemShutdown replied async\n"));
     940             :                 }
     941           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     942           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdown, NDR_OUT | NDR_SET_VALUES, r2);
     943             :                 }
     944           0 :                 if (dce_call->fault_code != 0) {
     945           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_InitiateSystemShutdown\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     946             :                 }
     947           0 :                 break;
     948             :         }
     949           0 :         case 25: { /* winreg_AbortSystemShutdown */
     950           0 :                 struct winreg_AbortSystemShutdown *r2 = (struct winreg_AbortSystemShutdown *)r;
     951           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     952           0 :                         DEBUG(5,("function winreg_AbortSystemShutdown replied async\n"));
     953             :                 }
     954           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     955           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_AbortSystemShutdown, NDR_OUT | NDR_SET_VALUES, r2);
     956             :                 }
     957           0 :                 if (dce_call->fault_code != 0) {
     958           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_AbortSystemShutdown\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     959             :                 }
     960           0 :                 break;
     961             :         }
     962         268 :         case 26: { /* winreg_GetVersion */
     963         268 :                 struct winreg_GetVersion *r2 = (struct winreg_GetVersion *)r;
     964         268 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     965           0 :                         DEBUG(5,("function winreg_GetVersion replied async\n"));
     966             :                 }
     967         268 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     968           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_GetVersion, NDR_OUT | NDR_SET_VALUES, r2);
     969             :                 }
     970         268 :                 if (dce_call->fault_code != 0) {
     971           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_GetVersion\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     972             :                 }
     973         268 :                 break;
     974             :         }
     975           0 :         case 27: { /* winreg_OpenHKCC */
     976           0 :                 struct winreg_OpenHKCC *r2 = (struct winreg_OpenHKCC *)r;
     977           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     978           0 :                         DEBUG(5,("function winreg_OpenHKCC replied async\n"));
     979             :                 }
     980           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     981           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKCC, NDR_OUT | NDR_SET_VALUES, r2);
     982             :                 }
     983           0 :                 if (dce_call->fault_code != 0) {
     984           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKCC\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     985             :                 }
     986           0 :                 break;
     987             :         }
     988           0 :         case 28: { /* winreg_OpenHKDD */
     989           0 :                 struct winreg_OpenHKDD *r2 = (struct winreg_OpenHKDD *)r;
     990           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     991           0 :                         DEBUG(5,("function winreg_OpenHKDD replied async\n"));
     992             :                 }
     993           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     994           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKDD, NDR_OUT | NDR_SET_VALUES, r2);
     995             :                 }
     996           0 :                 if (dce_call->fault_code != 0) {
     997           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKDD\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
     998             :                 }
     999           0 :                 break;
    1000             :         }
    1001          88 :         case 29: { /* winreg_QueryMultipleValues */
    1002          88 :                 struct winreg_QueryMultipleValues *r2 = (struct winreg_QueryMultipleValues *)r;
    1003          88 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1004           0 :                         DEBUG(5,("function winreg_QueryMultipleValues replied async\n"));
    1005             :                 }
    1006          88 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1007           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues, NDR_OUT | NDR_SET_VALUES, r2);
    1008             :                 }
    1009          88 :                 if (dce_call->fault_code != 0) {
    1010           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_QueryMultipleValues\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1011             :                 }
    1012          88 :                 break;
    1013             :         }
    1014           0 :         case 30: { /* winreg_InitiateSystemShutdownEx */
    1015           0 :                 struct winreg_InitiateSystemShutdownEx *r2 = (struct winreg_InitiateSystemShutdownEx *)r;
    1016           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1017           0 :                         DEBUG(5,("function winreg_InitiateSystemShutdownEx replied async\n"));
    1018             :                 }
    1019           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1020           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_InitiateSystemShutdownEx, NDR_OUT | NDR_SET_VALUES, r2);
    1021             :                 }
    1022           0 :                 if (dce_call->fault_code != 0) {
    1023           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_InitiateSystemShutdownEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1024             :                 }
    1025           0 :                 break;
    1026             :         }
    1027           0 :         case 31: { /* winreg_SaveKeyEx */
    1028           0 :                 struct winreg_SaveKeyEx *r2 = (struct winreg_SaveKeyEx *)r;
    1029           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1030           0 :                         DEBUG(5,("function winreg_SaveKeyEx replied async\n"));
    1031             :                 }
    1032           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1033           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_SaveKeyEx, NDR_OUT | NDR_SET_VALUES, r2);
    1034             :                 }
    1035           0 :                 if (dce_call->fault_code != 0) {
    1036           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_SaveKeyEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1037             :                 }
    1038           0 :                 break;
    1039             :         }
    1040           0 :         case 32: { /* winreg_OpenHKPT */
    1041           0 :                 struct winreg_OpenHKPT *r2 = (struct winreg_OpenHKPT *)r;
    1042           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1043           0 :                         DEBUG(5,("function winreg_OpenHKPT replied async\n"));
    1044             :                 }
    1045           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1046           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPT, NDR_OUT | NDR_SET_VALUES, r2);
    1047             :                 }
    1048           0 :                 if (dce_call->fault_code != 0) {
    1049           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKPT\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1050             :                 }
    1051           0 :                 break;
    1052             :         }
    1053           0 :         case 33: { /* winreg_OpenHKPN */
    1054           0 :                 struct winreg_OpenHKPN *r2 = (struct winreg_OpenHKPN *)r;
    1055           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1056           0 :                         DEBUG(5,("function winreg_OpenHKPN replied async\n"));
    1057             :                 }
    1058           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1059           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_OpenHKPN, NDR_OUT | NDR_SET_VALUES, r2);
    1060             :                 }
    1061           0 :                 if (dce_call->fault_code != 0) {
    1062           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_OpenHKPN\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1063             :                 }
    1064           0 :                 break;
    1065             :         }
    1066          88 :         case 34: { /* winreg_QueryMultipleValues2 */
    1067          88 :                 struct winreg_QueryMultipleValues2 *r2 = (struct winreg_QueryMultipleValues2 *)r;
    1068          88 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1069           0 :                         DEBUG(5,("function winreg_QueryMultipleValues2 replied async\n"));
    1070             :                 }
    1071          88 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1072           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_QueryMultipleValues2, NDR_OUT | NDR_SET_VALUES, r2);
    1073             :                 }
    1074          88 :                 if (dce_call->fault_code != 0) {
    1075           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_QueryMultipleValues2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1076             :                 }
    1077          88 :                 break;
    1078             :         }
    1079           0 :         case 35: { /* winreg_DeleteKeyEx */
    1080           0 :                 struct winreg_DeleteKeyEx *r2 = (struct winreg_DeleteKeyEx *)r;
    1081           0 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
    1082           0 :                         DEBUG(5,("function winreg_DeleteKeyEx replied async\n"));
    1083             :                 }
    1084           0 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
    1085           0 :                         NDR_PRINT_FUNCTION_DEBUG(winreg_DeleteKeyEx, NDR_OUT | NDR_SET_VALUES, r2);
    1086             :                 }
    1087           0 :                 if (dce_call->fault_code != 0) {
    1088           0 :                         DBG_WARNING("dcerpc_fault %s in winreg_DeleteKeyEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
    1089             :                 }
    1090           0 :                 break;
    1091             :         }
    1092           0 :         default:
    1093           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
    1094           0 :                 break;
    1095             :         }
    1096             : 
    1097      539813 :         if (dce_call->fault_code != 0) {
    1098           0 :                 return NT_STATUS_NET_WRITE_FAULT;
    1099             :         }
    1100             : 
    1101      539813 :         return NT_STATUS_OK;
    1102             : }
    1103             : 
    1104      539813 : NTSTATUS winreg__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
    1105             : {
    1106             :         enum ndr_err_code ndr_err;
    1107      539813 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
    1108             : 
    1109      539813 :         ndr_err = ndr_table_winreg.calls[opnum].ndr_push(push, NDR_OUT, r);
    1110      539813 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    1111           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
    1112           0 :                 return NT_STATUS_NET_WRITE_FAULT;
    1113             :         }
    1114             : 
    1115      539813 :         return NT_STATUS_OK;
    1116             : }
    1117             : 
    1118      433466 : NTSTATUS winreg__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
    1119             : {
    1120      433466 :         return winreg__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
    1121             : }
    1122             : 
    1123             : static const struct dcesrv_interface dcesrv_winreg_interface = {
    1124             :         .name      = "winreg",
    1125             :         .syntax_id = {{0x338cd001,0x2244,0x31f1,{0xaa,0xaa},{0x90,0x00,0x38,0x00,0x10,0x03}},1.0},
    1126             :         .bind      = winreg__op_bind,
    1127             :         .unbind    = winreg__op_unbind,
    1128             :         .ndr_pull  = winreg__op_ndr_pull,
    1129             :         .dispatch  = winreg__op_dispatch,
    1130             :         .reply     = winreg__op_reply,
    1131             :         .ndr_push  = winreg__op_ndr_push,
    1132             :         .local     = winreg__op_local,
    1133             : #ifdef DCESRV_INTERFACE_WINREG_FLAGS
    1134             :         .flags     = DCESRV_INTERFACE_WINREG_FLAGS
    1135             : #else
    1136             :         .flags     = 0
    1137             : #endif
    1138             : };
    1139             : 
    1140         204 : static NTSTATUS winreg__check_register_in_endpoint(const char *name, struct dcerpc_binding *binding) {
    1141         204 :         enum dcerpc_transport_t transport = dcerpc_binding_get_transport(binding);
    1142             :         NTSTATUS status;
    1143             : 
    1144             :         /* If service is disabled, do not register */
    1145         204 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_DISABLED) {
    1146           0 :                 return NT_STATUS_NOT_IMPLEMENTED;
    1147             :         }
    1148             : 
    1149             :         /* If service is embedded, register only for ncacn_np
    1150             :          * see 8466b3c85e4b835e57e41776853093f4a0edc8b8
    1151             :          */
    1152         204 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EMBEDDED && (transport != NCACN_NP && transport != NCALRPC)) {
    1153          68 :                 DBG_INFO("Interface 'winreg' not registered in endpoint '%s' as service is embedded\n", name);
    1154          68 :                 return NT_STATUS_NOT_SUPPORTED;
    1155             :         }
    1156             : 
    1157             :         /*
    1158             :          * If rpc service is external then change the default ncalrpc endpoint,
    1159             :          * otherwise if the rpc daemon running this service is configured in
    1160             :          * fork mode the forked process will race with main smbd to accept the
    1161             :          * connections in the default ncalrpc socket, and the forked process
    1162             :          * may not have the requested interface registered.
    1163             :          * For example, in the ad_member test environment:
    1164             :          *
    1165             :          *   rpc_server:lsarpc = external
    1166             :          *   rpc_server:samr = external
    1167             :          *   rpc_server:netlogon = disabled
    1168             :          *   rpc_daemon:lsasd = fork
    1169             :          *
    1170             :          * With these settings both, the main smbd and all the preforked lsasd
    1171             :          * processes would be listening in the default ncalrpc socket if it is
    1172             :          * not changed. If a client connection is accepted by one of the lsasd
    1173             :          * worker processes and the client asks for an interface not registered
    1174             :          * in these processes (winreg for example) it will get an error.
    1175             :          */
    1176         136 :         if (rpc_service_mode(name) == RPC_SERVICE_MODE_EXTERNAL && transport == NCALRPC) {
    1177           0 :                 status = dcerpc_binding_set_string_option(binding, "endpoint", "WINREG");
    1178           0 :                 if (!NT_STATUS_IS_OK(status)) {
    1179           0 :                         return status;
    1180             :                 }
    1181             :         }
    1182             : 
    1183         136 :         return NT_STATUS_OK;
    1184             : }
    1185             : 
    1186          68 : static NTSTATUS winreg__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
    1187             : {
    1188             :         uint32_t i;
    1189             :         NTSTATUS ret;
    1190             :         struct dcerpc_binding *binding;
    1191          68 :         struct dcerpc_binding *binding2 = NULL;
    1192             : 
    1193             : #ifdef DCESRV_INTERFACE_WINREG_NCACN_NP_SECONDARY_ENDPOINT
    1194             :         const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_WINREG_NCACN_NP_SECONDARY_ENDPOINT;
    1195             : #else
    1196          68 :         const char *ncacn_np_secondary_endpoint = NULL;
    1197             : #endif
    1198             : 
    1199         272 :         for (i=0;i<ndr_table_winreg.endpoints->count;i++) {
    1200         204 :                 const char *name = ndr_table_winreg.endpoints->names[i];
    1201             : 
    1202         204 :                 ret = dcerpc_parse_binding(dce_ctx, name, &binding);
    1203         204 :                 if (NT_STATUS_IS_ERR(ret)) {
    1204           0 :                         DBG_ERR("Failed to parse binding string '%s'\n", name);
    1205           0 :                         return ret;
    1206             :                 }
    1207             : 
    1208         204 :                 ret = winreg__check_register_in_endpoint("winreg", binding);
    1209         204 :                 if (NT_STATUS_IS_ERR(ret)) {
    1210          68 :                         talloc_free(binding);
    1211          68 :                         continue;
    1212             :                 }
    1213             : 
    1214         132 :                 if (ncacn_np_secondary_endpoint != NULL) {
    1215           0 :                         ret = dcerpc_parse_binding(dce_ctx, ncacn_np_secondary_endpoint, &binding2);
    1216           0 :                         if (NT_STATUS_IS_ERR(ret)) {
    1217           0 :                                 DBG_ERR("Failed to parse 2nd binding string '%s'\n", ncacn_np_secondary_endpoint);
    1218           0 :                                 TALLOC_FREE(binding);
    1219           0 :                                 return ret;
    1220             :                         }
    1221             :                 }
    1222             : 
    1223         136 :                 ret = dcesrv_interface_register_b(dce_ctx, binding, binding2, &dcesrv_winreg_interface, NULL);
    1224         136 :                 TALLOC_FREE(binding);
    1225         132 :                 TALLOC_FREE(binding2);
    1226         136 :                 if (!NT_STATUS_IS_OK(ret)) {
    1227           0 :                         DBG_ERR("Failed to register endpoint '%s'\n",name);
    1228           0 :                         return ret;
    1229             :                 }
    1230             :         }
    1231             : 
    1232          68 :         return NT_STATUS_OK;
    1233             : }
    1234             : 
    1235          19 : static NTSTATUS winreg__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
    1236             : {
    1237          19 :         return NT_STATUS_OK;
    1238             : }
    1239             : 
    1240           0 : static bool winreg__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
    1241             : {
    1242           0 :         if (dcesrv_winreg_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_winreg_interface.syntax_id.uuid, uuid)) {
    1243           0 :                 memcpy(iface,&dcesrv_winreg_interface, sizeof(*iface));
    1244           0 :                 return true;
    1245             :         }
    1246             : 
    1247           0 :         return false;
    1248             : }
    1249             : 
    1250           0 : static bool winreg__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
    1251             : {
    1252           0 :         if (strcmp(dcesrv_winreg_interface.name, name)==0) {
    1253           0 :                 memcpy(iface, &dcesrv_winreg_interface, sizeof(*iface));
    1254           0 :                 return true;
    1255             :         }
    1256             : 
    1257           0 :         return false;
    1258             : }
    1259             : 
    1260             : static const struct dcesrv_endpoint_server winreg_ep_server = {
    1261             :         /* fill in our name */
    1262             :         .name = "winreg",
    1263             : 
    1264             :         /* Initialization flag */
    1265             :         .initialized = false,
    1266             : 
    1267             :         /* fill in all the operations */
    1268             : #ifdef DCESRV_INTERFACE_WINREG_INIT_SERVER
    1269             :         .init_server = DCESRV_INTERFACE_WINREG_INIT_SERVER,
    1270             : #else
    1271             :         .init_server = winreg__op_init_server,
    1272             : #endif
    1273             : #ifdef DCESRV_INTERFACE_WINREG_SHUTDOWN_SERVER
    1274             :         .shutdown_server = DCESRV_INTERFACE_WINREG_SHUTDOWN_SERVER,
    1275             : #else
    1276             :         .shutdown_server = winreg__op_shutdown_server,
    1277             : #endif
    1278             :         .interface_by_uuid = winreg__op_interface_by_uuid,
    1279             :         .interface_by_name = winreg__op_interface_by_name
    1280             : };
    1281             : 
    1282          68 : const struct dcesrv_endpoint_server *winreg_get_ep_server(void)
    1283             : {
    1284          68 :         return &winreg_ep_server;
    1285             : }

Generated by: LCOV version 1.13