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