LCOV - code coverage report
Current view: top level - source4/torture/rpc - join.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 17 25 68.0 %
Date: 2021-09-23 10:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "includes.h"
       2             : #include "libcli/libcli.h"
       3             : 
       4             : #include "torture/rpc/torture_rpc.h"
       5             : 
       6             : #include "libcli/resolve/resolve.h"
       7             : #include "param/param.h"
       8             : 
       9             : #define TORTURE_NETBIOS_NAME "smbtorturejoin"
      10             : 
      11             : 
      12          23 : bool torture_rpc_join(struct torture_context *torture)
      13             : {
      14             :         NTSTATUS status;
      15             :         struct test_join *tj;
      16             :         struct cli_credentials *machine_account;
      17             :         struct smbcli_state *cli;
      18          23 :         const char *host = torture_setting_string(torture, "host", NULL);
      19             :         struct smbcli_options options;
      20             :         struct smbcli_session_options session_options;
      21             : 
      22             :         /* Join domain as a member server. */
      23          23 :         tj = torture_join_domain(torture,
      24             :                                  TORTURE_NETBIOS_NAME,
      25             :                                  ACB_WSTRUST,
      26             :                                  &machine_account);
      27             : 
      28          23 :         if (!tj) {
      29           0 :                 DEBUG(0, ("%s failed to join domain as workstation\n",
      30             :                           TORTURE_NETBIOS_NAME));
      31           0 :                 return false;
      32             :         }
      33             : 
      34          23 :         lpcfg_smbcli_options(torture->lp_ctx, &options);
      35          23 :         lpcfg_smbcli_session_options(torture->lp_ctx, &session_options);
      36             : 
      37          23 :         status = smbcli_full_connection(tj, &cli, host,
      38             :                                         lpcfg_smb_ports(torture->lp_ctx),
      39             :                                         "IPC$", NULL,
      40             :                                         lpcfg_socket_options(torture->lp_ctx),
      41             :                                         machine_account,
      42             :                                         lpcfg_resolve_context(torture->lp_ctx),
      43             :                                         torture->ev, &options, &session_options,
      44             :                                         lpcfg_gensec_settings(torture, torture->lp_ctx));
      45          23 :         if (!NT_STATUS_IS_OK(status)) {
      46           0 :                 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
      47             :                           TORTURE_NETBIOS_NAME));
      48           0 :                 return false;   
      49             :         }
      50          23 :         smbcli_tdis(cli);
      51             :         
      52             :         /* Leave domain. */                          
      53          23 :         torture_leave_domain(torture, tj);
      54             :         
      55             :         /* Join domain as a domain controller. */
      56          23 :         tj = torture_join_domain(torture, TORTURE_NETBIOS_NAME,
      57             :                                  ACB_SVRTRUST,
      58             :                                  &machine_account);
      59          23 :         if (!tj) {
      60           0 :                 DEBUG(0, ("%s failed to join domain as domain controller\n",
      61             :                           TORTURE_NETBIOS_NAME));
      62           0 :                 return false;
      63             :         }
      64             : 
      65          23 :         status = smbcli_full_connection(tj, &cli, host,
      66             :                                         lpcfg_smb_ports(torture->lp_ctx),
      67             :                                         "IPC$", NULL,
      68             :                                         lpcfg_socket_options(torture->lp_ctx),
      69             :                                         machine_account,
      70             :                                         lpcfg_resolve_context(torture->lp_ctx),
      71             :                                         torture->ev, &options, &session_options,
      72             :                                         lpcfg_gensec_settings(torture, torture->lp_ctx));
      73          23 :         if (!NT_STATUS_IS_OK(status)) {
      74           0 :                 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
      75             :                           TORTURE_NETBIOS_NAME));
      76           0 :                 return false;   
      77             :         }
      78             : 
      79          23 :         smbcli_tdis(cli);
      80             : 
      81             :         /* Leave domain. */
      82          23 :         torture_leave_domain(torture, tj);
      83             : 
      84          23 :         return true;
      85             : }
      86             : 

Generated by: LCOV version 1.13