diff options
Diffstat (limited to 'source4/torture/rpc/samba3rpc.c')
-rw-r--r-- | source4/torture/rpc/samba3rpc.c | 104 |
1 files changed, 61 insertions, 43 deletions
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index b08cd05bdb..95252e7397 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -806,6 +806,7 @@ static bool join3(struct smbcli_state *cli, */ static bool auth2(struct smbcli_state *cli, + struct loadparm_context *lp_ctx, struct cli_credentials *wks_cred) { TALLOC_CTX *mem_ctx; @@ -829,7 +830,7 @@ static bool auth2(struct smbcli_state *cli, net_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)); + lp_iconv_convenience(lp_ctx)); if (net_pipe == NULL) { d_printf("dcerpc_pipe_init failed\n"); goto done; @@ -984,7 +985,8 @@ static bool schan(struct smbcli_state *cli, generate_random_buffer(chal.data, chal.length); names_blob = NTLMv2_generate_names_blob( - mem_ctx, cli_credentials_get_workstation(user_creds), + mem_ctx, lp_iconv_convenience(lp_ctx), + cli_credentials_get_workstation(user_creds), cli_credentials_get_domain(user_creds)); status = cli_credentials_get_ntlm_response( user_creds, mem_ctx, &flags, chal, names_blob, @@ -1204,7 +1206,7 @@ bool torture_netlogon_samba3(struct torture_context *torture) int j; - if (!auth2(cli, wks_creds)) { + if (!auth2(cli, torture->lp_ctx, wks_creds)) { d_printf("auth2 failed\n"); goto done; } @@ -1283,7 +1285,7 @@ static bool test_join3(struct torture_context *tctx, cmdline_credentials, cli_credentials_get_domain(wks_creds), CRED_SPECIFIED); - if (!auth2(cli, wks_creds)) { + if (!auth2(cli, tctx->lp_ctx, wks_creds)) { d_printf("auth2 failed\n"); goto done; } @@ -1381,6 +1383,7 @@ bool torture_samba3_sessionkey(struct torture_context *torture) */ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_tree *tree, const char *pipe_name, const struct ndr_interface_table *iface, @@ -1391,7 +1394,7 @@ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx, if (!(result = dcerpc_pipe_init( mem_ctx, tree->session->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + lp_iconv_convenience(lp_ctx)))) { return NT_STATUS_NO_MEMORY; } @@ -1507,7 +1510,9 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx, * Find out the user SID on this connection */ -static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree) +static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + struct smbcli_tree *tree) { struct dcerpc_pipe *lsa; struct lsa_GetUserName r; @@ -1515,7 +1520,7 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree) struct lsa_StringPointer authority_name_p; struct dom_sid *result; - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\lsarpc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\lsarpc", &ndr_table_lsarpc, &lsa); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) Could not bind to LSA: %s\n", @@ -1631,7 +1636,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("(%s) whoami on auth'ed connection failed\n", __location__); ret = false; @@ -1658,7 +1663,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("(%s) whoami on anon connection failed\n", __location__); ret = false; @@ -1732,7 +1737,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) goto done; } - if (!(user_sid = whoami(mem_ctx, tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, tree))) { d_printf("(%s) whoami on user connection failed\n", __location__); ret = false; @@ -1870,8 +1875,8 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\pipe\\srvsvc", - &ndr_table_srvsvc, &p); + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, + "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", __location__, nt_errstr(status)); @@ -2007,6 +2012,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture) } static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_session *sess, const char *sharename) { @@ -2028,7 +2034,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, return NULL; } - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", @@ -2060,6 +2066,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx, } static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_session *sess, const char *sharename, struct security_descriptor *sd) @@ -2083,7 +2090,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc", + status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", @@ -2115,6 +2122,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, } bool try_tcon(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct security_descriptor *orig_sd, struct smbcli_session *session, const char *sharename, const struct dom_sid *user_sid, @@ -2162,7 +2170,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx, return false; } - status = set_sharesec(mem_ctx, session, sharename, sd); + status = set_sharesec(mem_ctx, lp_ctx, session, sharename, sd); if (!NT_STATUS_IS_OK(status)) { d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); @@ -2193,7 +2201,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx, done: smbcli_rmdir(rmdir_tree, "sharesec_testdir"); - status = set_sharesec(mem_ctx, session, sharename, orig_sd); + status = set_sharesec(mem_ctx, lp_ctx, session, sharename, orig_sd); if (!NT_STATUS_IS_OK(status)) { d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); @@ -2225,25 +2233,25 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture) return false; } - if (!(user_sid = whoami(mem_ctx, cli->tree))) { + if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) { d_printf("whoami failed\n"); talloc_free(mem_ctx); return false; } - sd = get_sharesec(mem_ctx, cli->session, torture_setting_string(torture, - "share", NULL)); + sd = get_sharesec(mem_ctx, torture->lp_ctx, cli->session, + torture_setting_string(torture, "share", NULL)); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, 0, NT_STATUS_ACCESS_DENIED, NT_STATUS_OK); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, SEC_FILE_READ_DATA, NT_STATUS_OK, NT_STATUS_MEDIA_WRITE_PROTECTED); - ret &= try_tcon(mem_ctx, sd, cli->session, + ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session, torture_setting_string(torture, "share", NULL), user_sid, SEC_FILE_ALL, NT_STATUS_OK, NT_STATUS_OK); @@ -2273,7 +2281,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\lsarpc", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\lsarpc", &ndr_table_lsarpc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2330,6 +2338,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture) } static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, + struct smb_iconv_convenience *iconv_convenience, char **name) { struct rap_WserverGetInfo r; @@ -2339,7 +2348,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, r.in.level = 0; r.in.bufsize = 0xffff; - status = smbcli_rap_netservergetinfo(tree, mem_ctx, &r); + status = smbcli_rap_netservergetinfo(tree, iconv_convenience, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -2347,7 +2356,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, memcpy(servername, r.out.info.info0.name, 16); servername[16] = '\0'; - if (pull_ascii_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), + if (pull_ascii_talloc(mem_ctx, iconv_convenience, name, servername) < 0) { return NT_STATUS_NO_MEMORY; } @@ -2356,7 +2365,8 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, } -static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree, +static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx, + struct smbcli_tree *tree, const char ***printers, int *num_printers) { TALLOC_CTX *mem_ctx; @@ -2372,7 +2382,8 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree, return NT_STATUS_NO_MEMORY; } - status = pipe_bind_smb(mem_ctx, tree, "\\srvsvc", &ndr_table_srvsvc, + status = pipe_bind_smb(mem_ctx, lp_ctx, + tree, "\\srvsvc", &ndr_table_srvsvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("could not bind to srvsvc pipe\n"); @@ -2552,7 +2563,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return false; } - status = get_servername(mem_ctx, cli->tree, &servername); + status = get_servername(mem_ctx, cli->tree, lp_iconv_convenience(torture->lp_ctx), &servername); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); @@ -2560,7 +2571,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return false; } - if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree, + if (!NT_STATUS_IS_OK(find_printers(mem_ctx, torture->lp_ctx, cli->tree, &printers, &num_printers))) { talloc_free(mem_ctx); return false; @@ -2572,7 +2583,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture) return true; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\spoolss", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\spoolss", &ndr_table_spoolss, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2738,7 +2749,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture) return false; } - status = get_servername(mem_ctx, cli->tree, &servername); + status = get_servername(mem_ctx, cli->tree, lp_iconv_convenience(torture->lp_ctx), &servername); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); @@ -2746,7 +2757,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture) return false; } - status = pipe_bind_smb(mem_ctx, cli->tree, "\\wkssvc", + status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\wkssvc", &ndr_table_wkssvc, &p); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, @@ -2995,6 +3006,7 @@ bool torture_samba3_rpc_winreg(struct torture_context *torture) } static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, struct smbcli_state *cli, const char *share, struct srvsvc_NetShareInfo502 **info) @@ -3006,7 +3018,7 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, if (!(p = dcerpc_pipe_init(cli, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + lp_iconv_convenience(lp_ctx)))) { status = NT_STATUS_NO_MEMORY; goto fail; } @@ -3056,6 +3068,7 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx, static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, + struct smb_iconv_convenience *iconv_convenience, struct dcerpc_pipe **pipe_p, struct policy_handle **handle) { @@ -3073,7 +3086,7 @@ static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, if (!(p = dcerpc_pipe_init(result, cli->transport->socket->event.ctx, - lp_iconv_convenience(global_loadparm)))) { + iconv_convenience))) { status = NT_STATUS_NO_MEMORY; goto fail; } @@ -3118,6 +3131,7 @@ static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx, } static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, + struct smb_iconv_convenience *iconv_convenience, const char *sharename) { struct dcerpc_pipe *p; @@ -3132,7 +3146,7 @@ static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, mem_ctx = talloc_new(cli); NT_STATUS_HAVE_NO_MEMORY(mem_ctx); - status = get_hklm_handle(mem_ctx, cli, &p, &hklm); + status = get_hklm_handle(mem_ctx, cli, iconv_convenience, &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); goto fail; @@ -3176,7 +3190,8 @@ static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli, return status; } -static NTSTATUS torture_samba3_deleteshare(struct smbcli_state *cli, +static NTSTATUS torture_samba3_deleteshare(struct torture_context *torture, + struct smbcli_state *cli, const char *sharename) { struct dcerpc_pipe *p; @@ -3188,7 +3203,8 @@ static NTSTATUS torture_samba3_deleteshare(struct smbcli_state *cli, mem_ctx = talloc_new(cli); NT_STATUS_HAVE_NO_MEMORY(mem_ctx); - status = get_hklm_handle(cli, cli, &p, &hklm); + status = get_hklm_handle(cli, cli, lp_iconv_convenience(torture->lp_ctx), + &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); goto fail; @@ -3215,6 +3231,7 @@ static NTSTATUS torture_samba3_deleteshare(struct smbcli_state *cli, } static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, + struct loadparm_context *lp_ctx, const char *sharename, const char *parameter, const char *value) @@ -3227,7 +3244,7 @@ static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, DATA_BLOB val; NTSTATUS status; - status = get_hklm_handle(cli, cli, &p, &hklm); + status = get_hklm_handle(cli, cli, lp_iconv_convenience(lp_ctx), &p, &hklm); if (!NT_STATUS_IS_OK(status)) { d_printf("get_hklm_handle failed: %s\n", nt_errstr(status)); return status;; @@ -3252,7 +3269,8 @@ static NTSTATUS torture_samba3_setconfig(struct smbcli_state *cli, goto done; } - if (!reg_string_to_val(hklm, "REG_SZ", value, &type, &val)) { + if (!reg_string_to_val(hklm, lp_iconv_convenience(lp_ctx), "REG_SZ", + value, &type, &val)) { d_printf("(%s) reg_string_to_val failed\n", __location__); goto done; } @@ -3287,21 +3305,21 @@ bool torture_samba3_regconfig(struct torture_context *torture) return false; } - status = torture_samba3_createshare(cli, "blubber"); + status = torture_samba3_createshare(cli, lp_iconv_convenience(torture->lp_ctx), "blubber"); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_createshare failed: " "%s\n", nt_errstr(status)); goto done; } - status = torture_samba3_setconfig(cli, "blubber", "comment", comment); + status = torture_samba3_setconfig(cli, torture->lp_ctx, "blubber", "comment", comment); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_setconfig failed: " "%s\n", nt_errstr(status)); goto done; } - status = get_shareinfo(torture, cli, "blubber", &i); + status = get_shareinfo(torture, torture->lp_ctx, cli, "blubber", &i); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "get_shareinfo failed: " "%s\n", nt_errstr(status)); @@ -3314,7 +3332,7 @@ bool torture_samba3_regconfig(struct torture_context *torture) goto done; } - status = torture_samba3_deleteshare(cli, "blubber"); + status = torture_samba3_deleteshare(torture, cli, "blubber"); if (!NT_STATUS_IS_OK(status)) { torture_warning(torture, "torture_samba3_deleteshare failed: " "%s\n", nt_errstr(status)); |