LCOV - code coverage report
Current view: top level - librpc/rpc - dcesrv_mgmt.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 51 55 92.7 %
Date: 2024-02-28 12:06:22 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    endpoint server for the mgmt pipe
       5             : 
       6             :    Copyright (C) Jelmer Vernooij 2006
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "librpc/rpc/dcesrv_core.h"
      24             : #include "librpc/rpc/dcesrv_core_proto.h"
      25             : #include "librpc/gen_ndr/ndr_mgmt.h"
      26             : 
      27             : #define DCESRV_INTERFACE_MGMT_BIND(context, iface) \
      28             :        dcesrv_interface_mgmt_bind(context, iface)
      29             : /*
      30             :  * This #define allows the mgmt interface to accept invalid
      31             :  * association groups, because association groups are to coordinate
      32             :  * handles, and handles are not used in mgmt. This in turn avoids
      33             :  * the need to coordinate these across multiple possible NETLOGON
      34             :  * processes, as an mgmt interface is added to each
      35             :  */
      36             : 
      37             : #define DCESRV_INTERFACE_MGMT_FLAGS DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED
      38             : 
      39         629 : static NTSTATUS dcesrv_interface_mgmt_bind(struct dcesrv_connection_context *context,
      40             :                                              const struct dcesrv_interface *iface)
      41             : {
      42         629 :         return dcesrv_interface_bind_allow_connect(context, iface);
      43             : }
      44             : 
      45             : /*
      46             :   mgmt_inq_if_ids
      47             : */
      48         465 : static WERROR dcesrv_mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
      49             :                        struct mgmt_inq_if_ids *r)
      50             : {
      51         465 :         const struct dcesrv_endpoint *ep = dce_call->conn->endpoint;
      52         465 :         struct dcesrv_if_list *l = NULL;
      53         465 :         struct rpc_if_id_vector_t *vector = NULL;
      54             : 
      55         465 :         vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
      56         465 :         if (vector == NULL) {
      57           0 :                 return WERR_NOT_ENOUGH_MEMORY;
      58             :         }
      59             : 
      60         465 :         vector->count = 0;
      61         465 :         vector->if_id = NULL;
      62             : 
      63        1450 :         for (l = ep->interface_list; l; l = l->next) {
      64           0 :                 bool filter;
      65             : 
      66         985 :                 filter = ndr_syntax_id_equal(&l->iface->syntax_id, &ndr_table_mgmt.syntax_id);
      67         985 :                 if (filter) {
      68             :                         /*
      69             :                          * We should not return the mgmt syntax itself here
      70             :                          */
      71         465 :                         continue;
      72             :                 }
      73             : 
      74         520 :                 vector->count++;
      75         520 :                 vector->if_id = talloc_realloc(vector, vector->if_id, struct ndr_syntax_id_p, vector->count);
      76         520 :                 if (vector->if_id == NULL) {
      77           0 :                         return WERR_NOT_ENOUGH_MEMORY;
      78             :                 }
      79         520 :                 vector->if_id[vector->count-1].id = &l->iface->syntax_id;
      80             :         }
      81             : 
      82         465 :         *r->out.if_id_vector = vector;
      83         465 :         return WERR_OK;
      84             : }
      85             : 
      86             : 
      87             : /*
      88             :   mgmt_inq_stats
      89             : */
      90         181 : static WERROR dcesrv_mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
      91             :                        struct mgmt_inq_stats *r)
      92             : {
      93         181 :         if (r->in.max_count != MGMT_STATS_ARRAY_MAX_SIZE)
      94          36 :                 return WERR_NOT_SUPPORTED;
      95             : 
      96         145 :         r->out.statistics->statistics = talloc_zero_array(mem_ctx,
      97             :                                                           uint32_t,
      98             :                                                           r->in.max_count);
      99         145 :         if (r->out.statistics->statistics == NULL) {
     100           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     101             :         }
     102         145 :         r->out.statistics->count = r->in.max_count;
     103             :         /* FIXME */
     104         145 :         r->out.statistics->statistics[MGMT_STATS_CALLS_IN] = 0;
     105         145 :         r->out.statistics->statistics[MGMT_STATS_CALLS_OUT] = 0;
     106         145 :         r->out.statistics->statistics[MGMT_STATS_PKTS_IN] = 0;
     107         145 :         r->out.statistics->statistics[MGMT_STATS_PKTS_OUT] = 0;
     108             : 
     109         145 :         return WERR_OK;
     110             : }
     111             : 
     112             : 
     113             : /*
     114             :   mgmt_is_server_listening
     115             : */
     116         163 : static uint32_t dcesrv_mgmt_is_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     117             :                        struct mgmt_is_server_listening *r)
     118             : {
     119         163 :         *r->out.status = 0;
     120         163 :         return 1;
     121             : }
     122             : 
     123             : 
     124             : /*
     125             :   mgmt_stop_server_listening
     126             : */
     127         175 : static WERROR dcesrv_mgmt_stop_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     128             :                        struct mgmt_stop_server_listening *r)
     129             : {
     130         175 :         return WERR_ACCESS_DENIED;
     131             : }
     132             : 
     133             : 
     134             : /*
     135             :   mgmt_inq_princ_name
     136             : */
     137       37006 : static WERROR dcesrv_mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     138             :                        struct mgmt_inq_princ_name *r)
     139             : {
     140       37006 :         const char *principal = NULL;
     141             : 
     142       37006 :         if (r->in.princ_name_size < 1) {
     143         102 :                 DCESRV_FAULT(DCERPC_FAULT_BAD_STUB_DATA);
     144             :         }
     145             : 
     146       36904 :         r->out.princ_name = "";
     147             : 
     148       36904 :         principal = dcesrv_auth_type_principal_find(dce_call->conn->dce_ctx,
     149       36904 :                                                     r->in.authn_proto);
     150       36904 :         if (principal == NULL) {
     151       35472 :                 return WERR_RPC_S_UNKNOWN_AUTHN_SERVICE;
     152             :         }
     153             : 
     154        1432 :         if (strlen(principal) + 1 > r->in.princ_name_size) {
     155        1218 :                 return WERR_INSUFFICIENT_BUFFER;
     156             :         }
     157             : 
     158         214 :         r->out.princ_name = principal;
     159         214 :         return WERR_OK;
     160             : }
     161             : 
     162             : 
     163             : /* include the generated boilerplate */
     164             : #include "librpc/gen_ndr/ndr_mgmt_s.c"
     165             : 
     166        4321 : const struct dcesrv_interface *dcesrv_get_mgmt_interface(void)
     167             : {
     168        4321 :         return &dcesrv_mgmt_interface;
     169             : }

Generated by: LCOV version 1.14