LCOV - code coverage report
Current view: top level - source3/rpc_server - rpcd_lsad.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 31 36 86.1 %
Date: 2024-06-13 04:01:37 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *
       4             :  *  This program is free software; you can redistribute it and/or modify
       5             :  *  it under the terms of the GNU General Public License as published by
       6             :  *  the Free Software Foundation; either version 3 of the License, or
       7             :  *  (at your option) any later version.
       8             :  *
       9             :  *  This program is distributed in the hope that it will be useful,
      10             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *  GNU General Public License for more details.
      13             :  *
      14             :  *  You should have received a copy of the GNU General Public License
      15             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "includes.h"
      19             : #include "rpc_worker.h"
      20             : #include "librpc/gen_ndr/ndr_lsa.h"
      21             : #include "librpc/gen_ndr/ndr_lsa_scompat.h"
      22             : #include "librpc/gen_ndr/ndr_samr.h"
      23             : #include "librpc/gen_ndr/ndr_samr_scompat.h"
      24             : #include "librpc/gen_ndr/ndr_netlogon.h"
      25             : #include "librpc/gen_ndr/ndr_netlogon_scompat.h"
      26             : #include "librpc/gen_ndr/ndr_dssetup.h"
      27             : #include "librpc/gen_ndr/ndr_dssetup_scompat.h"
      28             : #include "source3/include/auth.h"
      29             : #include "source3/include/secrets.h"
      30             : 
      31          35 : static size_t lsad_interfaces(
      32             :         const struct ndr_interface_table ***pifaces,
      33             :         void *private_data)
      34             : {
      35             :         static const struct ndr_interface_table *ifaces[] = {
      36             :                 &ndr_table_lsarpc,
      37             :                 &ndr_table_samr,
      38             :                 &ndr_table_dssetup,
      39             :                 /*
      40             :                  * This last item is truncated from the list by the
      41             :                  * num_ifaces -= 1 below for the fileserver.  Take
      42             :                  * care when adding new services.
      43             :                  */
      44             :                 &ndr_table_netlogon,
      45             :         };
      46          35 :         size_t num_ifaces = ARRAY_SIZE(ifaces);
      47             : 
      48          35 :         switch(lp_server_role()) {
      49          29 :         case ROLE_STANDALONE:
      50             :         case ROLE_DOMAIN_MEMBER:
      51             :                 /* no netlogon for non-dc */
      52          29 :                 num_ifaces -= 1;
      53          29 :                 break;
      54           4 :         case ROLE_ACTIVE_DIRECTORY_DC:
      55             :                 /*
      56             :                  * All these services are provided by the 'samba'
      57             :                  * binary from source4, not this code which is the
      58             :                  * source3 / NT4-like "classic" DC implementation
      59             :                  */
      60           4 :                 num_ifaces = 0;
      61           4 :                 break;
      62           2 :         default:
      63           2 :                 break;
      64             :         }
      65             : 
      66          35 :         *pifaces = ifaces;
      67          35 :         return num_ifaces;
      68             : }
      69             : 
      70          59 : static size_t lsad_servers(
      71             :         struct dcesrv_context *dce_ctx,
      72             :         const struct dcesrv_endpoint_server ***_ep_servers,
      73             :         void *private_data)
      74             : {
      75             :         static const struct dcesrv_endpoint_server *ep_servers[4] = { NULL, };
      76          59 :         size_t num_servers = ARRAY_SIZE(ep_servers);
      77             :         bool ok;
      78             : 
      79          59 :         ep_servers[0] = lsarpc_get_ep_server();
      80          59 :         ep_servers[1] = samr_get_ep_server();
      81          59 :         ep_servers[2] = dssetup_get_ep_server();
      82          59 :         ep_servers[3] = netlogon_get_ep_server();
      83             : 
      84          59 :         ok = secrets_init();
      85          59 :         if (!ok) {
      86           0 :                 DBG_ERR("secrets_init() failed\n");
      87           0 :                 exit(1);
      88             :         }
      89             : 
      90          59 :         switch(lp_server_role()) {
      91          52 :         case ROLE_STANDALONE:
      92             :         case ROLE_DOMAIN_MEMBER:
      93             :                 /* no netlogon for non-dc */
      94          52 :                 num_servers -= 1;
      95          52 :                 break;
      96           0 :         case ROLE_ACTIVE_DIRECTORY_DC:
      97             :                 /*
      98             :                  * All these services are provided by the 'samba'
      99             :                  * binary from source4, not this code which is the
     100             :                  * source3 / NT4-like "classic" DC implementation
     101             :                  */
     102           0 :                 num_servers = 0;
     103           0 :                 break;
     104           7 :         default:
     105           7 :                 break;
     106             :         }
     107             : 
     108          59 :         *_ep_servers = ep_servers;
     109          59 :         return num_servers;
     110             : }
     111             : 
     112          94 : int main(int argc, const char *argv[])
     113             : {
     114          94 :         return rpc_worker_main(
     115             :                 argc,
     116             :                 argv,
     117             :                 "rpcd_lsad",
     118             :                 5,
     119             :                 60,
     120             :                 lsad_interfaces,
     121             :                 lsad_servers,
     122             :                 NULL);
     123             : }

Generated by: LCOV version 1.13