LCOV - code coverage report
Current view: top level - source3/rpc_server - rpcd_lsad.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 36 43 83.7 %
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_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         101 : 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         101 :         size_t num_ifaces = ARRAY_SIZE(ifaces);
      47             : 
      48         101 :         switch(lp_server_role()) {
      49          66 :         case ROLE_STANDALONE:
      50             :         case ROLE_DOMAIN_MEMBER:
      51             :                 /* no netlogon for non-dc */
      52          66 :                 num_ifaces -= 1;
      53          66 :                 break;
      54          18 :         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          18 :                 num_ifaces = 0;
      61          18 :                 break;
      62          17 :         default:
      63          17 :                 break;
      64             :         }
      65             : 
      66         101 :         *pifaces = ifaces;
      67         101 :         return num_ifaces;
      68             : }
      69             : 
      70         215 : static NTSTATUS lsad_servers(
      71             :         struct dcesrv_context *dce_ctx,
      72             :         const struct dcesrv_endpoint_server ***_ep_servers,
      73             :         size_t *_num_ep_servers,
      74             :         void *private_data)
      75             : {
      76             :         static const struct dcesrv_endpoint_server *ep_servers[4] = { NULL, };
      77         215 :         size_t num_servers = ARRAY_SIZE(ep_servers);
      78             :         NTSTATUS status;
      79             :         bool ok;
      80             : 
      81         215 :         ep_servers[0] = lsarpc_get_ep_server();
      82         215 :         ep_servers[1] = samr_get_ep_server();
      83         215 :         ep_servers[2] = dssetup_get_ep_server();
      84         215 :         ep_servers[3] = netlogon_get_ep_server();
      85             : 
      86         215 :         ok = secrets_init();
      87         215 :         if (!ok) {
      88           0 :                 DBG_ERR("secrets_init() failed\n");
      89           0 :                 exit(1);
      90             :         }
      91             : 
      92         215 :         status = dcesrv_register_default_auth_types_machine_principal(dce_ctx);
      93         215 :         if (!NT_STATUS_IS_OK(status)) {
      94           0 :                 return status;
      95             :         }
      96             : 
      97         215 :         switch(lp_server_role()) {
      98          88 :         case ROLE_STANDALONE:
      99             :         case ROLE_DOMAIN_MEMBER:
     100             :                 /* no netlogon for non-dc */
     101          88 :                 num_servers -= 1;
     102          88 :                 break;
     103           0 :         case ROLE_ACTIVE_DIRECTORY_DC:
     104             :                 /*
     105             :                  * All these services are provided by the 'samba'
     106             :                  * binary from source4, not this code which is the
     107             :                  * source3 / NT4-like "classic" DC implementation
     108             :                  */
     109           0 :                 num_servers = 0;
     110           0 :                 break;
     111         127 :         default:
     112             :                 /*
     113             :                  * As DC we also register schannel with an
     114             :                  * empty principal
     115             :                  */
     116         127 :                 status = dcesrv_auth_type_principal_register(dce_ctx,
     117             :                                                              DCERPC_AUTH_TYPE_SCHANNEL,
     118             :                                                              "");
     119         127 :                 if (!NT_STATUS_IS_OK(status)) {
     120           0 :                         return status;
     121             :                 }
     122         127 :                 break;
     123             :         }
     124             : 
     125         215 :         *_ep_servers = ep_servers;
     126         215 :         *_num_ep_servers = num_servers;
     127         215 :         return NT_STATUS_OK;
     128             : }
     129             : 
     130         316 : int main(int argc, const char *argv[])
     131             : {
     132         316 :         return rpc_worker_main(
     133             :                 argc,
     134             :                 argv,
     135             :                 "rpcd_lsad",
     136             :                 5,
     137             :                 60,
     138             :                 lsad_interfaces,
     139             :                 lsad_servers,
     140             :                 NULL);
     141             : }

Generated by: LCOV version 1.14