LCOV - code coverage report
Current view: top level - source3/rpc_server - rpcd_epmapper.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 23 27 85.2 %
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 "replace.h"
      19             : #include "rpc_worker.h"
      20             : #include "librpc/gen_ndr/ndr_epmapper.h"
      21             : #include "librpc/gen_ndr/ndr_epmapper_scompat.h"
      22             : #include "param/loadparm.h"
      23             : #include "libds/common/roles.h"
      24             : 
      25         101 : static size_t epmapper_interfaces(
      26             :         const struct ndr_interface_table ***pifaces,
      27             :         void *private_data)
      28             : {
      29             :         static const struct ndr_interface_table *ifaces[] = {
      30             :                 &ndr_table_epmapper,
      31             :         };
      32         101 :         size_t num_ifaces = ARRAY_SIZE(ifaces);
      33             : 
      34         101 :         switch(lp_server_role()) {
      35          18 :         case ROLE_ACTIVE_DIRECTORY_DC:
      36             :                 /*
      37             :                  * On the AD DC epmapper is provided by the 'samba'
      38             :                  * binary from source4/
      39             :                  */
      40          18 :                 num_ifaces = 0;
      41          18 :                 break;
      42          83 :         default:
      43          83 :                 break;
      44             :         }
      45             : 
      46         101 :         *pifaces = ifaces;
      47         101 :         return num_ifaces;
      48             : }
      49             : 
      50          30 : static NTSTATUS epmapper_servers(
      51             :         struct dcesrv_context *dce_ctx,
      52             :         const struct dcesrv_endpoint_server ***_ep_servers,
      53             :         size_t *_num_ep_servers,
      54             :         void *private_data)
      55             : {
      56             :         static const struct dcesrv_endpoint_server *ep_servers[] = { NULL };
      57          30 :         size_t num_servers = ARRAY_SIZE(ep_servers);
      58             :         NTSTATUS status;
      59             : 
      60             :         /*
      61             :          * Windows Server 2022 registers the following auth_types
      62             :          * all with an empty principal name:
      63             :          *
      64             :          *  principle name for proto 9 (spnego) is ''
      65             :          *  principle name for proto 10 (ntlmssp) is ''
      66             :          *  principle name for proto 14 is ''
      67             :          *  principle name for proto 16 (gssapi_krb5) is ''
      68             :          *  principle name for proto 22 is ''
      69             :          *  principle name for proto 30 is ''
      70             :          *  principle name for proto 31 is ''
      71             :          *
      72             :          * We only register what we also support.
      73             :          */
      74          30 :         status = dcesrv_register_default_auth_types(dce_ctx, "");
      75          30 :         if (!NT_STATUS_IS_OK(status)) {
      76           0 :                 return status;
      77             :         }
      78             : 
      79          30 :         ep_servers[0] = epmapper_get_ep_server();
      80             : 
      81          30 :         switch(lp_server_role()) {
      82           0 :         case ROLE_ACTIVE_DIRECTORY_DC:
      83             :                 /*
      84             :                  * On the AD DC epmapper is provided by the 'samba'
      85             :                  * binary from source4/
      86             :                  */
      87           0 :                 num_servers = 0;
      88           0 :                 break;
      89          30 :         default:
      90          30 :                 break;
      91             :         }
      92             : 
      93          30 :         *_ep_servers = ep_servers;
      94          30 :         *_num_ep_servers = num_servers;
      95          30 :         return NT_STATUS_OK;
      96             : }
      97             : 
      98         131 : int main(int argc, const char *argv[])
      99             : {
     100         131 :         return rpc_worker_main(
     101             :                 argc,
     102             :                 argv,
     103             :                 "rpcd_epmapper",
     104             :                 1,
     105             :                 10,
     106             :                 epmapper_interfaces,
     107             :                 epmapper_servers,
     108             :                 NULL);
     109             : }

Generated by: LCOV version 1.14