LCOV - code coverage report
Current view: top level - source3/rpc_server - rpcd_classic.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 40 47 85.1 %
Date: 2024-02-29 22:57:05 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_srvsvc.h"
      21             : #include "librpc/gen_ndr/ndr_srvsvc_scompat.h"
      22             : #include "librpc/gen_ndr/ndr_dfs.h"
      23             : #include "librpc/gen_ndr/ndr_dfs_scompat.h"
      24             : #include "librpc/gen_ndr/ndr_wkssvc.h"
      25             : #include "librpc/gen_ndr/ndr_wkssvc_scompat.h"
      26             : #include "librpc/gen_ndr/ndr_svcctl.h"
      27             : #include "librpc/gen_ndr/ndr_svcctl_scompat.h"
      28             : #include "librpc/gen_ndr/ndr_ntsvcs.h"
      29             : #include "librpc/gen_ndr/ndr_ntsvcs_scompat.h"
      30             : #include "librpc/gen_ndr/ndr_eventlog.h"
      31             : #include "librpc/gen_ndr/ndr_eventlog_scompat.h"
      32             : #include "librpc/gen_ndr/ndr_initshutdown.h"
      33             : #include "librpc/gen_ndr/ndr_initshutdown_scompat.h"
      34             : #include "source3/include/secrets.h"
      35             : #include "locking/share_mode_lock.h"
      36             : #include "source3/smbd/proto.h"
      37             : 
      38         100 : static size_t classic_interfaces(
      39             :         const struct ndr_interface_table ***pifaces,
      40             :         void *private_data)
      41             : {
      42             :         static const struct ndr_interface_table *ifaces[] = {
      43             :                 &ndr_table_srvsvc,
      44             :                 &ndr_table_netdfs,
      45             :                 &ndr_table_initshutdown,
      46             :                 &ndr_table_svcctl,
      47             :                 &ndr_table_ntsvcs,
      48             :                 &ndr_table_eventlog,
      49             :                 /*
      50             :                  * This last item is truncated from the list by the
      51             :                  * num_ifaces -= 1 below.  Take care when adding new
      52             :                  * services.
      53             :                  */
      54             :                 &ndr_table_wkssvc,
      55             :         };
      56         100 :         size_t num_ifaces = ARRAY_SIZE(ifaces);
      57             : 
      58         100 :         switch(lp_server_role()) {
      59          17 :         case ROLE_ACTIVE_DIRECTORY_DC:
      60             :                 /*
      61             :                  * On the AD DC wkssvc is provided by the 'samba'
      62             :                  * binary from source4/
      63             :                  */
      64          17 :                 num_ifaces -= 1;
      65          17 :                 break;
      66          83 :         default:
      67          83 :                 break;
      68             :         }
      69             : 
      70         100 :         *pifaces = ifaces;
      71         100 :         return num_ifaces;
      72             : 
      73             : }
      74             : 
      75         125 : static NTSTATUS classic_servers(
      76             :         struct dcesrv_context *dce_ctx,
      77             :         const struct dcesrv_endpoint_server ***_ep_servers,
      78             :         size_t *_num_ep_servers,
      79             :         void *private_data)
      80             : {
      81             :         static const struct dcesrv_endpoint_server *ep_servers[7] = { NULL };
      82         125 :         size_t num_servers = ARRAY_SIZE(ep_servers);
      83             :         NTSTATUS status;
      84             :         bool ok;
      85             : 
      86         125 :         ep_servers[0] = srvsvc_get_ep_server();
      87         125 :         ep_servers[1] = netdfs_get_ep_server();
      88         125 :         ep_servers[2] = initshutdown_get_ep_server();
      89         125 :         ep_servers[3] = svcctl_get_ep_server();
      90         125 :         ep_servers[4] = ntsvcs_get_ep_server();
      91         125 :         ep_servers[5] = eventlog_get_ep_server();
      92         125 :         ep_servers[6] = wkssvc_get_ep_server();
      93             : 
      94         125 :         switch(lp_server_role()) {
      95          32 :         case ROLE_ACTIVE_DIRECTORY_DC:
      96             :                 /*
      97             :                  * On the AD DC wkssvc is provided by the 'samba'
      98             :                  * binary from source4/
      99             :                  */
     100          32 :                 num_servers -= 1;
     101          32 :                 break;
     102          93 :         default:
     103          93 :                 break;
     104             :         }
     105             : 
     106         125 :         ok = secrets_init();
     107         125 :         if (!ok) {
     108           0 :                 DBG_ERR("secrets_init() failed\n");
     109           0 :                 exit(1);
     110             :         }
     111             : 
     112         125 :         ok = locking_init();
     113         125 :         if (!ok) {
     114           0 :                 DBG_ERR("locking_init() failed\n");
     115           0 :                 exit(1);
     116             :         }
     117             : 
     118         125 :         status = share_info_db_init();
     119         125 :         if (!NT_STATUS_IS_OK(status)) {
     120           0 :                 DBG_ERR("share_info_db_init failed: %s\n", nt_errstr(status));
     121           0 :                 exit(1);
     122             :         }
     123             : 
     124         125 :         lp_load_with_shares(get_dyn_CONFIGFILE());
     125             : 
     126         125 :         mangle_reset_cache();
     127             : 
     128         125 :         status = dcesrv_register_default_auth_types_machine_principal(dce_ctx);
     129         125 :         if (!NT_STATUS_IS_OK(status)) {
     130           0 :                 return status;
     131             :         }
     132             : 
     133         125 :         *_ep_servers = ep_servers;
     134         125 :         *_num_ep_servers = num_servers;
     135         125 :         return NT_STATUS_OK;
     136             : }
     137             : 
     138         225 : int main(int argc, const char *argv[])
     139             : {
     140         225 :         return rpc_worker_main(
     141             :                 argc,
     142             :                 argv,
     143             :                 "rpcd_classic",
     144             :                 5,
     145             :                 60,
     146             :                 classic_interfaces,
     147             :                 classic_servers,
     148             :                 NULL);
     149             : }

Generated by: LCOV version 1.14