LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - ndr_unixinfo_s.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 105 163 64.4 %
Date: 2024-04-21 15:09:00 Functions: 8 11 72.7 %

          Line data    Source code
       1             : /* server functions auto-generated by pidl */
       2             : #include "bin/default/librpc/gen_ndr/ndr_unixinfo.h"
       3             : #include <util/debug.h>
       4             : 
       5             : NTSTATUS dcerpc_server_unixinfo_init(TALLOC_CTX *);
       6             : 
       7             : /* unixinfo - dcerpc server boilerplate generated by pidl */
       8             : 
       9             : 
      10           3 : static NTSTATUS unixinfo__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      11             : {
      12             : #ifdef DCESRV_INTERFACE_UNIXINFO_BIND
      13             :         return DCESRV_INTERFACE_UNIXINFO_BIND(context,iface);
      14             : #else
      15           3 :         return NT_STATUS_OK;
      16             : #endif
      17             : }
      18             : 
      19           3 : static void unixinfo__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
      20             : {
      21             : #ifdef DCESRV_INTERFACE_UNIXINFO_UNBIND
      22             :         DCESRV_INTERFACE_UNIXINFO_UNBIND(context, iface);
      23             : #else
      24           3 :         return;
      25             : #endif
      26             : }
      27             : 
      28          15 : static NTSTATUS unixinfo__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
      29             : {
      30           0 :         enum ndr_err_code ndr_err;
      31          15 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      32             : 
      33          15 :         dce_call->fault_code = 0;
      34             : 
      35          15 :         if (opnum >= ndr_table_unixinfo.num_calls) {
      36           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
      37           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      38             :         }
      39             : 
      40          30 :         *r = talloc_named(mem_ctx,
      41          15 :                           ndr_table_unixinfo.calls[opnum].struct_size,
      42             :                           "struct %s",
      43          15 :                           ndr_table_unixinfo.calls[opnum].name);
      44          15 :         NT_STATUS_HAVE_NO_MEMORY(*r);
      45             : 
      46             :         /* unravel the NDR for the packet */
      47          15 :         ndr_err = ndr_table_unixinfo.calls[opnum].ndr_pull(pull, NDR_IN, *r);
      48          15 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      49           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
      50           0 :                 return NT_STATUS_NET_WRITE_FAULT;
      51             :         }
      52             : 
      53          15 :         return NT_STATUS_OK;
      54             : }
      55             : 
      56          15 : static NTSTATUS unixinfo__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
      57             : {
      58          15 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
      59             : 
      60          15 :         switch (opnum) {
      61           3 :         case 0: {
      62           3 :                 struct unixinfo_SidToUid *r2 = (struct unixinfo_SidToUid *)r;
      63           3 :                 if (DEBUGLEVEL >= 10) {
      64           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToUid, NDR_IN, r2);
      65             :                 }
      66           3 :                 r2->out.result = dcesrv_unixinfo_SidToUid(dce_call, mem_ctx, r2);
      67           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      68           0 :                         DEBUG(5,("function unixinfo_SidToUid will reply async\n"));
      69             :                 }
      70           3 :                 break;
      71             :         }
      72           3 :         case 1: {
      73           3 :                 struct unixinfo_UidToSid *r2 = (struct unixinfo_UidToSid *)r;
      74           3 :                 if (DEBUGLEVEL >= 10) {
      75           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_UidToSid, NDR_IN, r2);
      76             :                 }
      77           3 :                 r2->out.result = dcesrv_unixinfo_UidToSid(dce_call, mem_ctx, r2);
      78           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      79           0 :                         DEBUG(5,("function unixinfo_UidToSid will reply async\n"));
      80             :                 }
      81           3 :                 break;
      82             :         }
      83           3 :         case 2: {
      84           3 :                 struct unixinfo_SidToGid *r2 = (struct unixinfo_SidToGid *)r;
      85           3 :                 if (DEBUGLEVEL >= 10) {
      86           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToGid, NDR_IN, r2);
      87             :                 }
      88           3 :                 r2->out.result = dcesrv_unixinfo_SidToGid(dce_call, mem_ctx, r2);
      89           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
      90           0 :                         DEBUG(5,("function unixinfo_SidToGid will reply async\n"));
      91             :                 }
      92           3 :                 break;
      93             :         }
      94           3 :         case 3: {
      95           3 :                 struct unixinfo_GidToSid *r2 = (struct unixinfo_GidToSid *)r;
      96           3 :                 if (DEBUGLEVEL >= 10) {
      97           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GidToSid, NDR_IN, r2);
      98             :                 }
      99           3 :                 r2->out.result = dcesrv_unixinfo_GidToSid(dce_call, mem_ctx, r2);
     100           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     101           0 :                         DEBUG(5,("function unixinfo_GidToSid will reply async\n"));
     102             :                 }
     103           3 :                 break;
     104             :         }
     105           3 :         case 4: {
     106           3 :                 struct unixinfo_GetPWUid *r2 = (struct unixinfo_GetPWUid *)r;
     107           3 :                 if (DEBUGLEVEL >= 10) {
     108           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GetPWUid, NDR_IN, r2);
     109             :                 }
     110           3 :                 r2->out.result = dcesrv_unixinfo_GetPWUid(dce_call, mem_ctx, r2);
     111           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     112           0 :                         DEBUG(5,("function unixinfo_GetPWUid will reply async\n"));
     113             :                 }
     114           3 :                 break;
     115             :         }
     116             : 
     117           0 :         default:
     118           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     119           0 :                 break;
     120             :         }
     121             : 
     122          15 :         if (dce_call->fault_code != 0) {
     123           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     124             :         }
     125             : 
     126          15 :         return NT_STATUS_OK;
     127             : }
     128             : 
     129          15 : static NTSTATUS unixinfo__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
     130             : {
     131          15 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     132             : 
     133          15 :         switch (opnum) {
     134           3 :         case 0: {
     135           3 :                 struct unixinfo_SidToUid *r2 = (struct unixinfo_SidToUid *)r;
     136           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     137           0 :                         DEBUG(5,("function unixinfo_SidToUid replied async\n"));
     138             :                 }
     139           3 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     140           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToUid, NDR_OUT | NDR_SET_VALUES, r2);
     141             :                 }
     142           3 :                 if (dce_call->fault_code != 0) {
     143           0 :                         DEBUG(2,("dcerpc_fault %s in unixinfo_SidToUid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     144             :                 }
     145           3 :                 break;
     146             :         }
     147           3 :         case 1: {
     148           3 :                 struct unixinfo_UidToSid *r2 = (struct unixinfo_UidToSid *)r;
     149           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     150           0 :                         DEBUG(5,("function unixinfo_UidToSid replied async\n"));
     151             :                 }
     152           3 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     153           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_UidToSid, NDR_OUT | NDR_SET_VALUES, r2);
     154             :                 }
     155           3 :                 if (dce_call->fault_code != 0) {
     156           0 :                         DEBUG(2,("dcerpc_fault %s in unixinfo_UidToSid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     157             :                 }
     158           3 :                 break;
     159             :         }
     160           3 :         case 2: {
     161           3 :                 struct unixinfo_SidToGid *r2 = (struct unixinfo_SidToGid *)r;
     162           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     163           0 :                         DEBUG(5,("function unixinfo_SidToGid replied async\n"));
     164             :                 }
     165           3 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     166           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToGid, NDR_OUT | NDR_SET_VALUES, r2);
     167             :                 }
     168           3 :                 if (dce_call->fault_code != 0) {
     169           0 :                         DEBUG(2,("dcerpc_fault %s in unixinfo_SidToGid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     170             :                 }
     171           3 :                 break;
     172             :         }
     173           3 :         case 3: {
     174           3 :                 struct unixinfo_GidToSid *r2 = (struct unixinfo_GidToSid *)r;
     175           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     176           0 :                         DEBUG(5,("function unixinfo_GidToSid replied async\n"));
     177             :                 }
     178           3 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     179           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GidToSid, NDR_OUT | NDR_SET_VALUES, r2);
     180             :                 }
     181           3 :                 if (dce_call->fault_code != 0) {
     182           0 :                         DEBUG(2,("dcerpc_fault %s in unixinfo_GidToSid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     183             :                 }
     184           3 :                 break;
     185             :         }
     186           3 :         case 4: {
     187           3 :                 struct unixinfo_GetPWUid *r2 = (struct unixinfo_GetPWUid *)r;
     188           3 :                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
     189           0 :                         DEBUG(5,("function unixinfo_GetPWUid replied async\n"));
     190             :                 }
     191           3 :                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
     192           0 :                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GetPWUid, NDR_OUT | NDR_SET_VALUES, r2);
     193             :                 }
     194           3 :                 if (dce_call->fault_code != 0) {
     195           0 :                         DEBUG(2,("dcerpc_fault %s in unixinfo_GetPWUid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
     196             :                 }
     197           3 :                 break;
     198             :         }
     199             : 
     200           0 :         default:
     201           0 :                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
     202           0 :                 break;
     203             :         }
     204             : 
     205          15 :         if (dce_call->fault_code != 0) {
     206           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     207             :         }
     208             : 
     209          15 :         return NT_STATUS_OK;
     210             : }
     211             : 
     212          15 : static NTSTATUS unixinfo__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
     213             : {
     214           0 :         enum ndr_err_code ndr_err;
     215          15 :         uint16_t opnum = dce_call->pkt.u.request.opnum;
     216             : 
     217          15 :         ndr_err = ndr_table_unixinfo.calls[opnum].ndr_push(push, NDR_OUT, r);
     218          15 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     219           0 :                 dce_call->fault_code = DCERPC_FAULT_NDR;
     220           0 :                 return NT_STATUS_NET_WRITE_FAULT;
     221             :         }
     222             : 
     223          15 :         return NT_STATUS_OK;
     224             : }
     225             : 
     226             : static const struct dcesrv_interface dcesrv_unixinfo_interface = {
     227             :         .name               = "unixinfo",
     228             :         .syntax_id          = {{0x9c54e310,0xa955,0x4885,{0xbd,0x31},{0x78,0x78,0x71,0x47,0xdf,0xa6}},0.0},
     229             :         .bind               = unixinfo__op_bind,
     230             :         .unbind             = unixinfo__op_unbind,
     231             :         .ndr_pull           = unixinfo__op_ndr_pull,
     232             :         .dispatch           = unixinfo__op_dispatch,
     233             :         .reply              = unixinfo__op_reply,
     234             :         .ndr_push           = unixinfo__op_ndr_push,
     235             :         .local              = NULL,
     236             : #ifdef DCESRV_INTERFACE_UNIXINFO_FLAGS
     237             :         .flags              = DCESRV_INTERFACE_UNIXINFO_FLAGS
     238             : #else
     239             :         .flags              = 0
     240             : #endif
     241             : };
     242             : 
     243             : 
     244          64 : static NTSTATUS unixinfo__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     245             : {
     246           2 :         int i;
     247             : #ifdef DCESRV_INTERFACE_UNIXINFO_NCACN_NP_SECONDARY_ENDPOINT
     248             :         const char *ncacn_np_secondary_endpoint =
     249             :                 DCESRV_INTERFACE_UNIXINFO_NCACN_NP_SECONDARY_ENDPOINT;
     250             : #else
     251          64 :         const char *ncacn_np_secondary_endpoint = NULL;
     252             : #endif
     253             : 
     254         256 :         for (i=0;i<ndr_table_unixinfo.endpoints->count;i++) {
     255           6 :                 NTSTATUS ret;
     256         192 :                 const char *name = ndr_table_unixinfo.endpoints->names[i];
     257             : 
     258         192 :                 ret = dcesrv_interface_register(dce_ctx,
     259             :                                                 name,
     260             :                                                 ncacn_np_secondary_endpoint,
     261             :                                                 &dcesrv_unixinfo_interface,
     262             :                                                 NULL);
     263         192 :                 if (!NT_STATUS_IS_OK(ret)) {
     264           0 :                         DEBUG(1,("unixinfo_op_init_server: failed to register endpoint '%s'\n",name));
     265           0 :                         return ret;
     266             :                 }
     267             :         }
     268             : 
     269          64 :         return NT_STATUS_OK;
     270             : }
     271             : 
     272           0 : static NTSTATUS unixinfo__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
     273             : {
     274           0 :         return NT_STATUS_OK;
     275             : }
     276             : 
     277           0 : static bool unixinfo__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
     278             : {
     279           0 :         if (dcesrv_unixinfo_interface.syntax_id.if_version == if_version &&
     280           0 :                 GUID_equal(&dcesrv_unixinfo_interface.syntax_id.uuid, uuid)) {
     281           0 :                 memcpy(iface,&dcesrv_unixinfo_interface, sizeof(*iface));
     282           0 :                 return true;
     283             :         }
     284             : 
     285           0 :         return false;
     286             : }
     287             : 
     288           0 : static bool unixinfo__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
     289             : {
     290           0 :         if (strcmp(dcesrv_unixinfo_interface.name, name)==0) {
     291           0 :                 memcpy(iface, &dcesrv_unixinfo_interface, sizeof(*iface));
     292           0 :                 return true;
     293             :         }
     294             : 
     295           0 :         return false;
     296             : }
     297             : 
     298          66 : NTSTATUS dcerpc_server_unixinfo_init(TALLOC_CTX *ctx)
     299             : {
     300           2 :         NTSTATUS ret;
     301           2 :         static const struct dcesrv_endpoint_server ep_server = {
     302             :             /* fill in our name */
     303             :             .name = "unixinfo",
     304             : 
     305             :             /* Initialization flag */
     306             :             .initialized = false,
     307             : 
     308             :             /* fill in all the operations */
     309             : #ifdef DCESRV_INTERFACE_UNIXINFO_INIT_SERVER
     310             :             .init_server = DCESRV_INTERFACE_UNIXINFO_INIT_SERVER,
     311             : #else
     312             :             .init_server = unixinfo__op_init_server,
     313             : #endif
     314             : #ifdef DCESRV_INTERFACE_UNIXINFO_SHUTDOWN_SERVER
     315             :             .shutdown_server = DCESRV_INTERFACE_UNIXINFO_SHUTDOWN_SERVER,
     316             : #else
     317             :             .shutdown_server = unixinfo__op_shutdown_server,
     318             : #endif
     319             :             .interface_by_uuid = unixinfo__op_interface_by_uuid,
     320             :             .interface_by_name = unixinfo__op_interface_by_name
     321             :         };
     322             :         /* register ourselves with the DCERPC subsystem. */
     323          66 :         ret = dcerpc_register_ep_server(&ep_server);
     324             : 
     325          66 :         if (!NT_STATUS_IS_OK(ret)) {
     326           0 :                 DEBUG(0,("Failed to register 'unixinfo' endpoint server!\n"));
     327           0 :                 return ret;
     328             :         }
     329             : 
     330          66 :         return ret;
     331             : }
     332             : 

Generated by: LCOV version 1.14