Remove more uses of global_loadparm.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 21 Feb 2008 13:50:57 +0000 (14:50 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 21 Feb 2008 13:50:57 +0000 (14:50 +0100)
12 files changed:
source/kdc/pac-glue.c
source/libcli/auth/smbencrypt.c
source/libcli/dgram/browse.c
source/libcli/dgram/dgramsocket.c
source/libcli/dgram/libdgram.h
source/libcli/dgram/netlogon.c
source/libcli/dgram/ntlogon.c
source/libcli/nbt/nbtname.c
source/libcli/raw/clitransport.c
source/libcli/smb_composite/fetchfile.c
source/libcli/smb_composite/smb_composite.h
source/torture/raw/composite.c

index 5f3a718..637f39a 100644 (file)
@@ -47,6 +47,7 @@ void  samba_kdc_plugin_fini(void *ptr)
 
 static krb5_error_code make_pac(krb5_context context,
                                TALLOC_CTX *mem_ctx, 
+                               struct smb_iconv_convenience *iconv_convenience,
                                struct auth_serversupplied_info *server_info,
                                krb5_pac *pac) 
 {
@@ -73,7 +74,7 @@ static krb5_error_code make_pac(krb5_context context,
 
        logon_info.info->info3 = *info3;
 
-       ndr_err = ndr_push_struct_blob(&pac_out, mem_ctx, lp_iconv_convenience(global_loadparm), &logon_info,
+       ndr_err = ndr_push_struct_blob(&pac_out, mem_ctx, iconv_convenience, &logon_info,
                                       (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO_CTR);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                nt_status = ndr_map_error2ntstatus(ndr_err);
@@ -113,6 +114,7 @@ krb5_error_code samba_kdc_get_pac(void *priv,
        struct hdb_ldb_private *private = talloc_get_type(client->ctx, struct hdb_ldb_private);
        TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context");
        unsigned int userAccountControl;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        if (!mem_ctx) {
                return ENOMEM;
@@ -138,7 +140,7 @@ krb5_error_code samba_kdc_get_pac(void *priv,
                return ENOMEM;
        }
 
-       ret = make_pac(context, mem_ctx, server_info, pac);
+       ret = make_pac(context, mem_ctx, iconv_convenience, server_info, pac);
 
        talloc_free(mem_ctx);
        return ret;
@@ -164,6 +166,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context,
        struct PAC_LOGON_INFO_CTR logon_info;
        union netr_Validation validation;
        struct auth_serversupplied_info *server_info_out;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context");
        
@@ -190,7 +193,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context,
                return ENOMEM;
        }
                
-       ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, lp_iconv_convenience(global_loadparm), &logon_info,
+       ndr_err = ndr_pull_struct_blob(&pac_in, mem_ctx, iconv_convenience, &logon_info,
                                       (ndr_pull_flags_fn_t)ndr_pull_PAC_LOGON_INFO_CTR);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || !logon_info.info) {
                nt_status = ndr_map_error2ntstatus(ndr_err);
@@ -213,7 +216,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context,
        /* We will compleatly regenerate this pac */
        krb5_pac_free(context, *pac);
 
-       ret = make_pac(context, mem_ctx, server_info_out, pac);
+       ret = make_pac(context, mem_ctx, iconv_convenience, server_info_out, pac);
 
        talloc_free(mem_ctx);
        return ret;
index 4ccf568..c5223db 100644 (file)
@@ -125,6 +125,8 @@ bool ntv2_owf_gen(const uint8_t owf[16],
 
        HMACMD5Context ctx;
        TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); 
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
+
        if (!mem_ctx) {
                return false;
        }
@@ -151,14 +153,14 @@ bool ntv2_owf_gen(const uint8_t owf[16],
                }
        }
 
-       user_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &user, user_in);
+       user_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &user, user_in);
        if (user_byte_len == (ssize_t)-1) {
                DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
                talloc_free(mem_ctx);
                return false;
        }
 
-       domain_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &domain, domain_in);
+       domain_byte_len = push_ucs2_talloc(mem_ctx, iconv_convenience, &domain, domain_in);
        if (domain_byte_len == (ssize_t)-1) {
                DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
                talloc_free(mem_ctx);
index eb19555..14d8278 100644 (file)
@@ -38,7 +38,7 @@ NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
        DATA_BLOB blob;
        TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), request,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, request,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -66,7 +66,7 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
        struct nbt_name myname;
        struct socket_address *dest;
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), reply,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -99,7 +99,7 @@ NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot,
        DATA_BLOB data = dgram_mailslot_data(dgram);
        enum ndr_err_code ndr_err;
 
-       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), pkt,
+       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, pkt,
                                      (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
index 032d9de..7d6f562 100644 (file)
@@ -72,7 +72,7 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock)
        }
 
        /* parse the request */
-       ndr_err = ndr_pull_struct_blob(&blob, packet, lp_iconv_convenience(global_loadparm), packet,
+       ndr_err = ndr_pull_struct_blob(&blob, packet, dgmsock->iconv_convenience, packet,
                                      (ndr_pull_flags_fn_t)ndr_pull_nbt_dgram_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
@@ -187,6 +187,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
        dgmsock->send_queue = NULL;
        dgmsock->incoming.handler = NULL;
        dgmsock->mailslot_handlers = NULL;
+       dgmsock->iconv_convenience = lp_iconv_convenience(global_loadparm);
        
        return dgmsock;
 
@@ -229,7 +230,7 @@ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock,
        req->dest = dest;
        if (talloc_reference(req, dest) == NULL) goto failed;
 
-       ndr_err = ndr_push_struct_blob(&req->encoded, req, lp_iconv_convenience(global_loadparm), packet,
+       ndr_err = ndr_push_struct_blob(&req->encoded, req, dgmsock->iconv_convenience, packet,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_dgram_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                status = ndr_map_error2ntstatus(ndr_err);
index 6d4cdb2..4645840 100644 (file)
@@ -40,6 +40,7 @@ struct nbt_dgram_request {
 struct nbt_dgram_socket {
        struct socket_context *sock;
        struct event_context *event_ctx;
+       struct smb_iconv_convenience *iconv_convenience;
 
        /* the fd event */
        struct fd_event *fde;
index 670af4e..5c7dedc 100644 (file)
@@ -41,7 +41,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
        TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
 
        ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, 
-                                      lp_iconv_convenience(global_loadparm),
+                                      dgmsock->iconv_convenience,
                                       request,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -76,7 +76,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
        struct socket_address *dest;
 
        ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, 
-                                      lp_iconv_convenience(global_loadparm),
+                                      dgmsock->iconv_convenience,
                                       reply,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -114,7 +114,7 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
        DATA_BLOB data = dgram_mailslot_data(dgram);
        enum ndr_err_code ndr_err;
 
-       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), netlogon,
+       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, netlogon,
                                      (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
index 98aad1a..7b26ed7 100644 (file)
@@ -41,7 +41,7 @@ NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock,
        DATA_BLOB blob;
        TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm)
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience
                                       request,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -75,7 +75,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
        struct nbt_name myname;
        struct socket_address *dest;
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), reply,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply,
                                      (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -113,7 +113,7 @@ NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
        DATA_BLOB data = dgram_mailslot_data(dgram);
        enum ndr_err_code ndr_err;
 
-       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), ntlogon,
+       ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, ntlogon,
                                      (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
index 142dad0..ae9f3f6 100644 (file)
@@ -381,11 +381,11 @@ _PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struc
 /**
   push a nbt name into a blob
 */
-_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name)
+_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name)
 {
        enum ndr_err_code ndr_err;
 
-       ndr_err = ndr_push_struct_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm), name, (ndr_push_flags_fn_t)ndr_push_nbt_name);
+       ndr_err = ndr_push_struct_blob(blob, mem_ctx, iconv_convenience, name, (ndr_push_flags_fn_t)ndr_push_nbt_name);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return ndr_map_error2ntstatus(ndr_err);
        }
index 288f061..5c14e9f 100644 (file)
@@ -164,14 +164,15 @@ struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *tr
        DATA_BLOB calling_blob, called_blob;
        TALLOC_CTX *tmp_ctx = talloc_new(transport);
        NTSTATUS status;
+       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        status = nbt_name_dup(transport, called, &transport->called);
        if (!NT_STATUS_IS_OK(status)) goto failed;
        
-       status = nbt_name_to_blob(tmp_ctx, &calling_blob, calling);
+       status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &calling_blob, calling);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
-       status = nbt_name_to_blob(tmp_ctx, &called_blob, called);
+       status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &called_blob, called);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
        /* allocate output buffer */
index c7d02e3..e431279 100644 (file)
@@ -147,8 +147,8 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
        state->connect->in.fallback_to_anonymous = false;
        state->connect->in.workgroup    = io->in.workgroup;
 
-       lp_smbcli_options(global_loadparm, &state->connect->in.options);
-       
+       state->connect->in.options      = io->in.options;
+
        state->creq = smb_composite_connect_send(state->connect, state, 
                                                 lp_resolve_context(global_loadparm), event_ctx);
        if (state->creq == NULL) goto failed;
index a732617..964ffb0 100644 (file)
@@ -55,6 +55,7 @@ struct smb_composite_fetchfile {
                struct cli_credentials *credentials;
                const char *workgroup;
                const char *filename;
+               struct smbcli_options options;
        } in;
        struct {
                uint8_t *data;
index 0367110..7238a2f 100644 (file)
@@ -161,6 +161,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct
        io2.in.credentials = cmdline_credentials;
        io2.in.workgroup  = lp_workgroup(tctx->lp_ctx);
        io2.in.filename = fname;
+       lp_smbcli_options(tctx->lp_ctx, &io2.in.options);
 
        printf("testing parallel fetchfile with %d ops\n", torture_numops);