Remove more uses of global_loadparm.
[jelmer/samba4-debian.git] / source / torture / rpc / samba3rpc.c
index 496453e1812c13c30ee2c2903425d0b957f99ad1..1386f61c2b1adbfa658f317be48d6b076466776b 100644 (file)
@@ -50,6 +50,7 @@
 #include "libcli/security/proto.h"
 #include "param/param.h"
 #include "lib/registry/registry.h"
+#include "libcli/resolve/resolve.h"
 
 /*
  * This tests a RPC call using an invalid vuid
@@ -70,6 +71,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
        struct dcerpc_pipe *lsa_pipe;
        struct cli_credentials *anon_creds;
        struct smb_composite_sesssetup setup;
+       struct smbcli_options options;
 
        mem_ctx = talloc_init("torture_bind_authcontext");
 
@@ -78,18 +80,22 @@ bool torture_bind_authcontext(struct torture_context *torture)
                return false;
        }
 
+       lp_smbcli_options(torture->lp_ctx, &options);
+
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
-                                       NULL);
+                                       lp_resolve_context(torture->lp_ctx),
+                                       NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
                goto done;
        }
 
-       lsa_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx);
+       lsa_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx,
+                                   lp_iconv_convenience(torture->lp_ctx));
        if (lsa_pipe == NULL) {
                d_printf("dcerpc_pipe_init failed\n");
                goto done;
@@ -206,7 +212,8 @@ static bool bindtest(struct smbcli_state *cli,
        }
 
        lsa_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx);
+                                   cli->transport->socket->event.ctx,
+                                   lp_iconv_convenience(lp_ctx));
        if (lsa_pipe == NULL) {
                d_printf("dcerpc_pipe_init failed\n");
                goto done;
@@ -278,6 +285,7 @@ bool torture_bind_samba3(struct torture_context *torture)
        NTSTATUS status;
        bool ret = false;
        struct smbcli_state *cli;
+       struct smbcli_options options;
 
        mem_ctx = talloc_init("torture_bind_authcontext");
 
@@ -286,11 +294,14 @@ bool torture_bind_samba3(struct torture_context *torture)
                return false;
        }
 
+       lp_smbcli_options(torture->lp_ctx, &options);
+
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
-                                       NULL);
+                                       lp_resolve_context(torture->lp_ctx),
+                                       NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -346,7 +357,8 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
        uint32_t user_rid,access_granted;
 
        samr_pipe = dcerpc_pipe_init(mem_ctx,
-                                    cli->transport->socket->event.ctx);
+                                    cli->transport->socket->event.ctx,
+                                    lp_iconv_convenience(lp_ctx));
        if (samr_pipe == NULL) {
                d_printf("dcerpc_pipe_init failed\n");
                status = NT_STATUS_NO_MEMORY;
@@ -517,7 +529,7 @@ static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
                                username, domain_name, &samr_pipe, &wks_handle,
                                user_sid);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("get_wks_handle failed: %s\n", nt_errstr(status));
+               d_printf("get_usr_handle failed: %s\n", nt_errstr(status));
                goto done;
        }
 
@@ -794,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;
@@ -816,7 +829,8 @@ static bool auth2(struct smbcli_state *cli,
        }
 
        net_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx);
+                                   cli->transport->socket->event.ctx,
+                                   lp_iconv_convenience(lp_ctx));
        if (net_pipe == NULL) {
                d_printf("dcerpc_pipe_init failed\n");
                goto done;
@@ -918,7 +932,8 @@ static bool schan(struct smbcli_state *cli,
        }
 
        net_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx);
+                                   cli->transport->socket->event.ctx,
+                                   lp_iconv_convenience(lp_ctx));
        if (net_pipe == NULL) {
                d_printf("dcerpc_pipe_init failed\n");
                goto done;
@@ -970,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,
@@ -1126,6 +1142,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
        struct cli_credentials *wks_creds;
        const char *wks_name;
        int i;
+       struct smbcli_options options;
 
        wks_name = torture_setting_string(torture, "wksname", NULL);
        if (wks_name == NULL) {
@@ -1144,10 +1161,14 @@ bool torture_netlogon_samba3(struct torture_context *torture)
                goto done;
        }
 
+       lp_smbcli_options(torture->lp_ctx, &options);
+
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
-                                       "IPC$", NULL, anon_creds, NULL);
+                                       "IPC$", NULL, anon_creds, 
+                                       lp_resolve_context(torture->lp_ctx),
+                                       NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1185,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;
                }
@@ -1225,11 +1246,16 @@ static bool test_join3(struct torture_context *tctx,
        bool ret = false;
        struct smbcli_state *cli;
        struct cli_credentials *wks_creds;
+       struct smbcli_options options;
+
+       lp_smbcli_options(tctx->lp_ctx, &options);
 
        status = smbcli_full_connection(tctx, &cli,
                                        torture_setting_string(tctx, "host", NULL),
                                        lp_smb_ports(tctx->lp_ctx),
-                                       "IPC$", NULL, smb_creds, NULL);
+                                       "IPC$", NULL, smb_creds, 
+                                       lp_resolve_context(tctx->lp_ctx),
+                                       NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1259,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;
        }
@@ -1357,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,
@@ -1366,7 +1393,8 @@ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
 
        if (!(result = dcerpc_pipe_init(
-                     mem_ctx, tree->session->transport->socket->event.ctx))) {
+                     mem_ctx, tree->session->transport->socket->event.ctx, 
+                     lp_iconv_convenience(lp_ctx)))) {
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -1482,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;
@@ -1490,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",
@@ -1585,15 +1615,20 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
        struct cli_credentials *anon_creds;
        struct cli_credentials *user_creds;
        char *domain_name;
+       struct smbcli_options options;
 
        if (!(mem_ctx = talloc_new(torture))) {
                return false;
        }
 
+       lp_smbcli_options(torture->lp_ctx, &options);
+
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
                lp_smb_ports(torture->lp_ctx),
-               "IPC$", NULL, cmdline_credentials, NULL);
+               "IPC$", NULL, cmdline_credentials, 
+               lp_resolve_context(torture->lp_ctx),
+               NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1601,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;
@@ -1618,7 +1653,9 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
                lp_smb_ports(torture->lp_ctx),
-               "IPC$", NULL, anon_creds, NULL);
+               "IPC$", NULL, anon_creds, 
+               lp_resolve_context(torture->lp_ctx),
+               NULL, &options);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1626,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;
@@ -1700,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;
@@ -1838,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));
@@ -1901,7 +1938,8 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
        }
 
        if (!(net_pipe = dcerpc_pipe_init(
-                     mem_ctx, cli->transport->socket->event.ctx))) {
+                     mem_ctx, cli->transport->socket->event.ctx,
+                     lp_iconv_convenience(torture->lp_ctx)))) {
                d_printf("dcerpc_pipe_init failed\n");
                goto done;
        }
@@ -1974,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)
 {
@@ -1995,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",
@@ -2027,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)
@@ -2050,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",
@@ -2082,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,
@@ -2129,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));
@@ -2160,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));
@@ -2192,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);
 
@@ -2240,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__,
@@ -2297,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;
@@ -2306,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;
        }
@@ -2314,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, global_smb_iconv_convenience, 
+       if (pull_ascii_talloc(mem_ctx, iconv_convenience, 
                              name, servername) < 0) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -2323,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;
@@ -2339,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");
@@ -2519,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));
@@ -2527,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;
@@ -2539,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__,
@@ -2705,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));
@@ -2713,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__,
@@ -2962,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)
@@ -2972,7 +3017,8 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
 
        if (!(p = dcerpc_pipe_init(cli,
-                                  cli->transport->socket->event.ctx))) {
+                                  cli->transport->socket->event.ctx,
+                                  lp_iconv_convenience(lp_ctx)))) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
@@ -3022,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)
 {
@@ -3038,7 +3085,8 @@ static NTSTATUS get_hklm_handle(TALLOC_CTX *mem_ctx,
        }
 
        if (!(p = dcerpc_pipe_init(result,
-                                  cli->transport->socket->event.ctx))) {
+                                  cli->transport->socket->event.ctx,
+                                  iconv_convenience))) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
@@ -3083,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;
@@ -3097,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;
@@ -3141,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;
@@ -3153,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;
@@ -3180,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)
@@ -3192,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,21 +3304,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));
@@ -3279,7 +3331,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));