LCOV - code coverage report
Current view: top level - source3/rpc_server - rpcd_classic.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 40 47 85.1 %
Date: 2024-04-21 15:09:00 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         101 : 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         101 :         size_t num_ifaces = ARRAY_SIZE(ifaces);
      57             : 
      58         101 :         switch(lp_server_role()) {
      59          18 :         case ROLE_ACTIVE_DIRECTORY_DC:
      60             :                 /*
      61             :                  * On the AD DC wkssvc is provided by the 'samba'
      62             :                  * binary from source4/
      63             :                  */
      64          18 :                 num_ifaces -= 1;
      65          18 :                 break;
      66          83 :         default:
      67          83 :                 break;
      68             :         }
      69             : 
      70         101 :         *pifaces = ifaces;
      71         101 :         return num_ifaces;
      72             : 
      73             : }
      74             : 
      75         126 : 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         126 :         size_t num_servers = ARRAY_SIZE(ep_servers);
      83             :         NTSTATUS status;
      84             :         bool ok;
      85             : 
      86         126 :         ep_servers[0] = srvsvc_get_ep_server();
      87         126 :         ep_servers[1] = netdfs_get_ep_server();
      88         126 :         ep_servers[2] = initshutdown_get_ep_server();
      89         126 :         ep_servers[3] = svcctl_get_ep_server();
      90         126 :         ep_servers[4] = ntsvcs_get_ep_server();
      91         126 :         ep_servers[5] = eventlog_get_ep_server();
      92         126 :         ep_servers[6] = wkssvc_get_ep_server();
      93             : 
      94         126 :         switch(lp_server_role()) {
      95          33 :         case ROLE_ACTIVE_DIRECTORY_DC:
      96             :                 /*
      97             :                  * On the AD DC wkssvc is provided by the 'samba'
      98             :                  * binary from source4/
      99             :                  */
     100          33 :                 num_servers -= 1;
     101          33 :                 break;
     102          93 :         default:
     103          93 :                 break;
     104             :         }
     105             : 
     106         126 :         ok = secrets_init();
     107         126 :         if (!ok) {
     108           0 :                 DBG_ERR("secrets_init() failed\n");
     109           0 :                 exit(1);
     110             :         }
     111             : 
     112         126 :         ok = locking_init();
     113         126 :         if (!ok) {
     114           0 :                 DBG_ERR("locking_init() failed\n");
     115           0 :                 exit(1);
     116             :         }
     117             : 
     118         126 :         status = share_info_db_init();
     119         126 :         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         126 :         lp_load_with_shares(get_dyn_CONFIGFILE());
     125             : 
     126         126 :         mangle_reset_cache();
     127             : 
     128         126 :         status = dcesrv_register_default_auth_types_machine_principal(dce_ctx);
     129         126 :         if (!NT_STATUS_IS_OK(status)) {
     130           0 :                 return status;
     131             :         }
     132             : 
     133         126 :         *_ep_servers = ep_servers;
     134         126 :         *_num_ep_servers = num_servers;
     135         126 :         return NT_STATUS_OK;
     136             : }
     137             : 
     138         227 : int main(int argc, const char *argv[])
     139             : {
     140         227 :         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