r26429: Avoid use of global_smb_iconv_convenience.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 13 Dec 2007 21:46:09 +0000 (22:46 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:49:56 +0000 (05:49 +0100)
(This used to be commit d37136b7abfbba75ef2e5ab855eb3382b9648b8c)

39 files changed:
source4/auth/ntlmssp/ntlmssp_parse.c
source4/dsdb/schema/schema_init.c
source4/dsdb/schema/schema_syntax.c
source4/lib/charset/util_unistr.c
source4/lib/policy/lex.c
source4/lib/registry/ldb.c
source4/lib/registry/patchfile_preg.c
source4/lib/registry/util.c
source4/lib/tdr/tdr.c
source4/lib/util/dprintf.c
source4/lib/util/ms_fnmatch.c
source4/libcli/auth/smbencrypt.c
source4/libcli/raw/rawfileinfo.c
source4/libcli/raw/rawrequest.c
source4/libcli/smb2/request.c
source4/librpc/ndr/ndr.c
source4/ntvfs/posix/pvfs_rename.c
source4/ntvfs/posix/pvfs_resolve.c
source4/ntvfs/posix/pvfs_shortname.c
source4/ntvfs/posix/pvfs_util.c
source4/ntvfs/print/vfs_print.c
source4/param/loadparm.c
source4/param/util.c
source4/scripting/ejs/smbcalls_data.c
source4/smb_server/blob.c
source4/smb_server/smb/nttrans.c
source4/smb_server/smb/request.c
source4/smb_server/smb2/fileio.c
source4/smbd/process_standard.c
source4/torture/basic/charset.c
source4/torture/basic/scanner.c
source4/torture/basic/utable.c
source4/torture/masktest.c
source4/torture/rap/rap.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/spoolss_win.c
source4/torture/rpc/wkssvc.c
source4/torture/smbtorture.c

index cc1054ac489ae33dce12ee994c35344dadc4464b..bb2d7a14a8039d5e9211c14dd4878aa5815ba797 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "pstring.h"
+#include "param/param.h"
 
 /*
   this is a tiny msrpc packet generator. I am only using this to
@@ -64,7 +65,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
                case 'U':
                        s = va_arg(ap, char *);
                        head_size += 8;
-                       n = push_ucs2_talloc(pointers, global_smb_iconv_convenience, (void **)&pointers[i].data, s);
+                       n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -75,7 +76,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
                case 'A':
                        s = va_arg(ap, char *);
                        head_size += 8;
-                       n = push_ascii_talloc(pointers, global_smb_iconv_convenience, (char **)&pointers[i].data, s);
+                       n = push_ascii_talloc(pointers, lp_iconv_convenience(global_loadparm), (char **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -87,7 +88,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
                        n = va_arg(ap, int);
                        intargs[i] = n;
                        s = va_arg(ap, char *);
-                       n = push_ucs2_talloc(pointers, global_smb_iconv_convenience, (void **)&pointers[i].data, s);
+                       n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
                        if (n == -1) {
                                return false;
                        }
@@ -243,7 +244,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
                                }
 
                                if (0 < len1) {
-                                       pull_string(global_smb_iconv_convenience, p, blob->data + ptr, p_len, 
+                                       pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len, 
                                                    len1, STR_UNICODE|STR_NOALIGN);
                                        (*ps) = talloc_strdup(mem_ctx, p);
                                        if (!(*ps)) {
@@ -278,7 +279,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
                                }
 
                                if (0 < len1) {
-                                       pull_string(global_smb_iconv_convenience, p, blob->data + ptr, p_len, 
+                                       pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len, 
                                                    len1, STR_ASCII|STR_NOALIGN);
                                        (*ps) = talloc_strdup(mem_ctx, p);
                                        if (!(*ps)) {
@@ -343,7 +344,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
                                goto cleanup;
                        }
 
-                       head_ofs += pull_string(global_smb_iconv_convenience, p,
+                       head_ofs += pull_string(lp_iconv_convenience(global_loadparm), p,
                                        blob->data+head_ofs, p_len,
                                        blob->length - head_ofs,
                                        STR_ASCII|STR_TERMINATE);
index c301766c9deead79ee350e9a40bb5a8a64cfcc3d..24ef91777b964c0099987a7e1a312ec49b940e79 100644 (file)
@@ -27,6 +27,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "librpc/gen_ndr/ndr_drsuapi.h"
 #include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "param/param.h"
 
 WERROR dsdb_load_oid_mappings_drsuapi(struct dsdb_schema *schema, const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)
 {
@@ -620,7 +621,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
        } \
        if (_a && _a->value_ctr.num_values >= 1) { \
                ssize_t _ret; \
-               _ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, \
+               _ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, \
                                             _a->value_ctr.values[0].blob->data, \
                                             _a->value_ctr.values[0].blob->length, \
                                             (void **)discard_const(&(p)->elem)); \
index 749064d5cfd40633d6b26a56158966796fd1999b..a8fe4a3b9db881dffafdf07bbf385fa25512f366 100644 (file)
@@ -25,6 +25,7 @@
 #include "system/time.h"
 #include "lib/charset/charset.h"
 #include "librpc/ndr/libndr.h"
+#include "param/param.h"
 
 static WERROR dsdb_syntax_FOOBAR_drsuapi_to_ldb(const struct dsdb_schema *schema,
                                                const struct dsdb_attribute *attr,
@@ -766,7 +767,7 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(const struct dsdb_schema *schem
                        return WERR_FOOBAR;
                }
 
-               ret = convert_string_talloc(out->values, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+               ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
                                            in->value_ctr.values[i].blob->data,
                                            in->value_ctr.values[i].blob->length,
                                            (void **)&str);
@@ -808,7 +809,7 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(const struct dsdb_schema *schem
 
                out->value_ctr.values[i].blob   = &blobs[i];
 
-               ret = convert_string_talloc(blobs, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+               ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
                                            in->values[i].data,
                                            in->values[i].length,
                                            (void **)&blobs[i].data);
@@ -1043,7 +1044,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(const struct dsdb_
                        return WERR_FOOBAR;
                }
 
-               ret = convert_string_talloc(out->values, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+               ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
                                            in->value_ctr.values[i].blob->data+4,
                                            in->value_ctr.values[i].blob->length-4,
                                            (void **)&str);
@@ -1086,7 +1087,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(const struct dsdb_
 
                out->value_ctr.values[i].blob   = &blobs[i];
 
-               ret = convert_string_talloc(blobs, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+               ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
                                            in->values[i].data,
                                            in->values[i].length,
                                            (void **)&data);
index 67a790c250e59abc9c80f571db2aac0974b21ba7..e0e1aed222d3c8787d151f64c7ea4ba317ba061e 100644 (file)
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "system/locale.h"
 #include "dynconfig.h"
+#include "param/param.h"
 
 /**
  * @file
@@ -129,8 +130,8 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
        if (s2 == NULL) return 1;
 
        while (*s1 && *s2) {
-               c1 = next_codepoint(global_smb_iconv_convenience, s1, &size1);
-               c2 = next_codepoint(global_smb_iconv_convenience, s2, &size2);
+               c1 = next_codepoint(lp_iconv_convenience(global_loadparm), s1, &size1);
+               c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -215,8 +216,8 @@ _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
        while (*s1 && *s2 && n) {
                n--;
 
-               c1 = next_codepoint(global_smb_iconv_convenience, s1, &size1);
-               c2 = next_codepoint(global_smb_iconv_convenience, s2, &size2);
+               c1 = next_codepoint(lp_iconv_convenience(global_loadparm), s1, &size1);
+               c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s2, &size2);
 
                s1 += size1;
                s2 += size2;
@@ -275,7 +276,7 @@ _PUBLIC_ void string_replace_w(char *s, char oldc, char newc)
 {
        while (s && *s) {
                size_t size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
                if (c == oldc) {
                        *s = newc;
                }
@@ -353,7 +354,7 @@ _PUBLIC_ size_t strlen_m(const char *s)
 
        while (*s) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
                if (c < 0x10000) {
                        count += 1;
                } else {
@@ -391,7 +392,7 @@ _PUBLIC_ char *strchr_m(const char *s, char c)
 
        while (*s) {
                size_t size;
-               codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size);
+               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
                if (c2 == c) {
                        return discard_const_p(char, s);
                }
@@ -416,7 +417,7 @@ _PUBLIC_ char *strrchr_m(const char *s, char c)
 
        while (*s) {
                size_t size;
-               codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size);
+               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
                if (c2 == c) {
                        ret = discard_const_p(char, s);
                }
@@ -436,7 +437,7 @@ _PUBLIC_ bool strhaslower(const char *string)
                codepoint_t s;
                codepoint_t t;
 
-               s = next_codepoint(global_smb_iconv_convenience, string, &c_size);
+               s = next_codepoint(lp_iconv_convenience(global_loadparm), string, &c_size);
                string += c_size;
 
                t = toupper_w(s);
@@ -459,7 +460,7 @@ _PUBLIC_ bool strhasupper(const char *string)
                codepoint_t s;
                codepoint_t t;
 
-               s = next_codepoint(global_smb_iconv_convenience, string, &c_size);
+               s = next_codepoint(lp_iconv_convenience(global_loadparm), string, &c_size);
                string += c_size;
 
                t = tolower_w(s);
@@ -489,12 +490,12 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
 
        while (*src) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, src, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), src, &c_size);
                src += c_size;
 
                c = tolower_w(c);
 
-               c_size = push_codepoint(global_smb_iconv_convenience, dest+size, c);
+               c_size = push_codepoint(lp_iconv_convenience(global_loadparm), dest+size, c);
                if (c_size == -1) {
                        talloc_free(dest);
                        return NULL;
@@ -533,12 +534,12 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src)
 
        while (*src) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, src, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), src, &c_size);
                src += c_size;
 
                c = toupper_w(c);
 
-               c_size = push_codepoint(global_smb_iconv_convenience, dest+size, c);
+               c_size = push_codepoint(lp_iconv_convenience(global_loadparm), dest+size, c);
                if (c_size == -1) {
                        talloc_free(dest);
                        return NULL;
@@ -579,8 +580,8 @@ _PUBLIC_ void strlower_m(char *s)
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size);
-               c_size2 = push_codepoint(global_smb_iconv_convenience, d, tolower_w(c));
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
+               c_size2 = push_codepoint(lp_iconv_convenience(global_loadparm), d, tolower_w(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
                                 c, tolower_w(c), (int)c_size, (int)c_size2));
@@ -615,8 +616,8 @@ _PUBLIC_ void strupper_m(char *s)
 
        while (*s) {
                size_t c_size, c_size2;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, s, &c_size);
-               c_size2 = push_codepoint(global_smb_iconv_convenience, d, toupper_w(c));
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), s, &c_size);
+               c_size2 = push_codepoint(lp_iconv_convenience(global_loadparm), d, toupper_w(c));
                if (c_size2 > c_size) {
                        DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
                                 c, toupper_w(c), (int)c_size, (int)c_size2));
@@ -638,7 +639,7 @@ _PUBLIC_ size_t count_chars_w(const char *s, char c)
 
        while (*s) {
                size_t size;
-               codepoint_t c2 = next_codepoint(global_smb_iconv_convenience, s, &size);
+               codepoint_t c2 = next_codepoint(lp_iconv_convenience(global_loadparm), s, &size);
                if (c2 == c) count++;
                s += size;
        }
index 5364706fc4b579279902bae707295343d58b61c4..c2899aa80834c7333a3117696a20cf1fc6c57373 100644 (file)
@@ -587,6 +587,7 @@ char *yytext;
 #line 23 "lex.l"
 #include "includes.h"
 #include "lib/policy/parse_adm.h"
+#include "param/param.h"
 void error_message (const char *format, ...);
 int yyparse (void);
 
@@ -600,7 +601,7 @@ static bool utf16 = false;
                if (fread(&v, 2, 1, yyin) < 1) \
                        result = YY_NULL; \
                else \
-                       result = push_codepoint(global_smb_iconv_convenience, buf, v); \
+                       result = push_codepoint(lp_iconv_convenience(global_loadparm), buf, v); \
        } else { \
                int c = getc(yyin); \
                result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
index 0e556da9e26af03f857bf223612f4203dacf63e1..11fa066a3502ebe1b8dc8257fbe456d12a25a6fc 100644 (file)
@@ -54,7 +54,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
        {
        case REG_SZ:
        case REG_EXPAND_SZ:
-               data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF8, CH_UTF16,
+               data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF8, CH_UTF16,
                                                     val->data, val->length,
                                                     (void **)&data->data);
                break;
@@ -85,7 +85,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
        switch (type) {
        case REG_SZ:
        case REG_EXPAND_SZ:
-               val.length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+               val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
                                                   (void *)data.data,
                                                   data.length,
                                                   (void **)&val.data);
index 47bd160c5400bd340debd1b40b3ec1f860ee813b..9cc9a5dec2e69bc2fdabc41c9302ff5fed2e1437 100644 (file)
@@ -23,6 +23,7 @@
 #include "lib/registry/registry.h"
 #include "lib/registry/patchfile.h"
 #include "system/filesys.h"
+#include "param/param.h"
 
 struct preg_data {
        int fd;
@@ -35,7 +36,7 @@ static WERROR preg_read_utf16(int fd, char *c)
        if (read(fd, &v, 2) < 2) {
                return WERR_GENERAL_FAILURE;
        }
-       push_codepoint(global_smb_iconv_convenience, c, v);
+       push_codepoint(lp_iconv_convenience(global_loadparm), c, v);
        return WERR_OK;
 }
 
index f75fc835b54fab01888bb43bf8d59020b95e08c8..a251ae49a59177f98e08aada8c69de464d1e85fb 100644 (file)
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
 
 /**
  * @file
@@ -61,7 +62,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
        switch (type) {
                case REG_EXPAND_SZ:
                case REG_SZ:
-                       convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+                       convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
                                              data.data, data.length,
                                              (void **)&ret);
                        return ret;
@@ -117,7 +118,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
        {
                case REG_SZ:
                case REG_EXPAND_SZ:
-               data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+               data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
                                                     data_str, strlen(data_str),
                                                     (void **)&data->data);
                        break;
index 0757a02e47b2401493bb1f78ca2b8930cb069553..80e1d9ae243a6249564ce076a47a6dcabb907de3 100644 (file)
@@ -24,6 +24,7 @@
 #include "system/filesys.h"
 #include "system/network.h"
 #include "tdr/tdr.h"
+#include "param/param.h"
 
 #define TDR_BASE_MARSHALL_SIZE 1024
 
@@ -153,7 +154,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v,
 
        TDR_PULL_NEED_BYTES(tdr, el_size*length);
        
-       ret = convert_string_talloc(ctx, global_smb_iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v));
+       ret = convert_string_talloc(ctx, lp_iconv_convenience(global_loadparm), chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v));
 
        if (ret == -1) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -175,7 +176,7 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length,
        required = el_size * length;
        TDR_PUSH_NEED_BYTES(tdr, required);
 
-       ret = convert_string(global_smb_iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
+       ret = convert_string(lp_iconv_convenience(global_loadparm), CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
 
        if (ret == -1) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -404,9 +405,7 @@ void tdr_print_debug_helper(struct tdr_print *tdr, const char *format, ...) _PRI
        vasprintf(&s, format, ap);
        va_end(ap);
 
-       for (i=0;i<tdr->level;i++) {
-               DEBUG(0,("    "));
-       }
+       for (i=0;i<tdr->level;i++) { DEBUG(0,("    ")); }
 
        DEBUG(0,("%s\n", s));
        free(s);
index 5b3fe4b1ea1712bae28282502a186b5ed7948998..ae2b7bb4d5f40540376f5ecb9db61fd490776ecf 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "includes.h"
 #include "system/locale.h"
+#include "param/param.h"
 
 _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
 {
@@ -55,7 +56,7 @@ again:
                SAFE_FREE(p);
                return -1;
        }
-       clen = convert_string(global_smb_iconv_convenience, CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen);
+       clen = convert_string(lp_iconv_convenience(global_loadparm), CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen);
         if (clen == -1) {
                /* the string can't be converted - do the best we can,
                   filling in non-printing chars with '?' */
index e1bf6f94c5ed321d85ab8d9f3ecc928fb507fb30..1fb57b07a49be9ab5fcbb6c504c6cd0ae4acdc37 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "includes.h"
+#include "param/param.h"
 
 static int null_match(const char *p)
 {
@@ -64,7 +65,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
        int i;
        size_t size, size_n;
 
-       while ((c = next_codepoint(global_smb_iconv_convenience, p, &size))) {
+       while ((c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &size))) {
                p += size;
 
                switch (c) {
@@ -74,7 +75,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return null_match(p);
                        }
                        for (i=0; n[i]; i += size_n) {
-                               next_codepoint(global_smb_iconv_convenience, n+i, &size_n);
+                               next_codepoint(lp_iconv_convenience(global_loadparm), n+i, &size_n);
                                if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
                                        return 0;
                                }
@@ -93,7 +94,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return -1;
                        }
                        for (i=0; n[i]; i += size_n) {
-                               next_codepoint(global_smb_iconv_convenience, n+i, &size_n);
+                               next_codepoint(lp_iconv_convenience(global_loadparm), n+i, &size_n);
                                if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
                                if (n+i == ldot) {
                                        if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
@@ -109,7 +110,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                        if (! *n) {
                                return -1;
                        }
-                       next_codepoint(global_smb_iconv_convenience, n, &size_n);
+                       next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n);
                        n += size_n;
                        break;
 
@@ -123,7 +124,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                break;
                        }
                        if (! *n) return null_match(p);
-                       next_codepoint(global_smb_iconv_convenience, n, &size_n);
+                       next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n);
                        n += size_n;
                        break;
 
@@ -133,12 +134,12 @@ static int ms_fnmatch_core(const char *p, const char *n,
                                return 0;
                        }
                        if (*n != '.') return -1;
-                       next_codepoint(global_smb_iconv_convenience, n, &size_n);
+                       next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n);
                        n += size_n;
                        break;
 
                default:
-                       c2 = next_codepoint(global_smb_iconv_convenience, n, &size_n);
+                       c2 = next_codepoint(lp_iconv_convenience(global_loadparm), n, &size_n);
                        if (c != c2 && codepoint_cmpi(c, c2) != 0) {
                                return -1;
                        }
index ccad1058bf8f1757cd7d84d0ae345fa1102993f8..26b78d25efcfce7b5cf99cfed77f8969a98a6517 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/crypto/crypto.h"
 #include "libcli/auth/libcli_auth.h"
 #include "pstring.h"
+#include "param/param.h"
 
 /*
    This implements the X/Open SMB password encryption
@@ -67,7 +68,7 @@ _PUBLIC_ bool E_md4hash(const char *passwd, uint8_t p16[16])
        int len;
        void *wpwd;
 
-       len = push_ucs2_talloc(NULL, global_smb_iconv_convenience, &wpwd, passwd);
+       len = push_ucs2_talloc(NULL, lp_iconv_convenience(global_loadparm), &wpwd, passwd);
        if (len < 2) {
                /* We don't want to return fixed data, as most callers
                 * don't check */
@@ -97,7 +98,7 @@ _PUBLIC_ bool E_deshash(const char *passwd, uint8_t p16[16])
        ZERO_STRUCT(dospwd);
 
        /* Password must be converted to DOS charset - null terminated, uppercase. */
-       push_string(global_smb_iconv_convenience, dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
+       push_string(lp_iconv_convenience(global_loadparm), dospwd, passwd, sizeof(dospwd), STR_ASCII|STR_UPPER|STR_TERMINATE);
 
        /* Only the fisrt 14 chars are considered, password need not be null terminated. */
        E_P16((const uint8_t *)dospwd, p16);
@@ -150,14 +151,14 @@ bool ntv2_owf_gen(const uint8_t owf[16],
                }
        }
 
-       user_byte_len = push_ucs2_talloc(mem_ctx, global_smb_iconv_convenience, &user, user_in);
+       user_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &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, global_smb_iconv_convenience, &domain, domain_in);
+       domain_byte_len = push_ucs2_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), &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);
@@ -468,7 +469,7 @@ bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag
        /* the incoming buffer can be any alignment. */
        string_flags |= STR_NOALIGN;
 
-       new_pw_len = push_string(global_smb_iconv_convenience, new_pw,
+       new_pw_len = push_string(lp_iconv_convenience(global_loadparm), new_pw,
                                 password, 
                                 sizeof(new_pw), string_flags);
        
@@ -521,7 +522,7 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd,
        }
 
        /* decode into the return buffer.  Buffer length supplied */
-       *new_pw_len = pull_string(global_smb_iconv_convenience, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, 
+       *new_pw_len = pull_string(lp_iconv_convenience(global_loadparm), new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, 
                                  byte_len, string_flags);
 
 #ifdef DEBUG_PASSWORD
index 972ae7f5e14b6a7abc20e09fcb986d9faea366d2..9827217a0435879d9efe8b57e7dcfaf095c79ce6 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
 #include "librpc/gen_ndr/ndr_security.h"
+#include "param/param.h"
 
 /* local macros to make the code more readable */
 #define FINFO_CHECK_MIN_SIZE(size) if (blob->length < (size)) { \
@@ -62,7 +63,7 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
                        return NT_STATUS_INFO_LENGTH_MISMATCH;
                }
                size = convert_string_talloc(io->streams, 
-                                            global_smb_iconv_convenience,
+                                            lp_iconv_convenience(global_loadparm),
                                             CH_UTF16, CH_UNIX,
                                             blob.data+ofs+24, nlen, &vstr);
                if (size == -1) {
index 43c984721b2cb229b792cae80cc8237d9441f6b8..e7dffaf05400d793c227f5b1988b3b71aa5e31c4 100644 (file)
@@ -26,6 +26,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "lib/util/dlinklist.h"
 #include "lib/events/events.h"
+#include "param/param.h"
 
 /* we over allocate the data buffer to prevent too many realloc calls */
 #define REQ_OVER_ALLOCATION 0
@@ -418,7 +419,7 @@ size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, uin
 
        smbcli_req_grow_allocation(req, len + req->out.data_size);
 
-       len = push_string(global_smb_iconv_convenience, req->out.data + req->out.data_size, str, len, flags);
+       len = push_string(lp_iconv_convenience(global_loadparm), req->out.data + req->out.data_size, str, len, flags);
 
        smbcli_req_grow_data(req, len + req->out.data_size);
 
@@ -574,7 +575,7 @@ static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_c
                return 0;
        }
 
-       ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest);
+       ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)dest);
        if (ret == -1) {
                *dest = NULL;
                return 0;
@@ -616,7 +617,7 @@ size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
                src_len2++;
        }
 
-       ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)dest);
+       ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)dest);
 
        if (ret == -1) {
                *dest = NULL;
@@ -769,7 +770,7 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
 
        src_len2 = utf16_len_n(src, src_len);
 
-       ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
+       ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
        if (ret == -1) {
                *dest = NULL;
                return 0;
@@ -815,7 +816,7 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx,
                src_len2++;
        }
 
-       ret = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
+       ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
 
        if (ret == -1) {
                *dest = NULL;
@@ -965,7 +966,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
                return 0;
        }
 
-       len = push_string(global_smb_iconv_convenience, blob->data + blob->length, str, max_len, flags);
+       len = push_string(lp_iconv_convenience(global_loadparm), blob->data + blob->length, str, max_len, flags);
 
        blob->length += len;
 
index 5a7534f906df6ea36affa2534bc377389c384f48..73c74dcfeb6ff234af3764cbef211069435de28e 100644 (file)
@@ -26,6 +26,7 @@
 #include "lib/util/dlinklist.h"
 #include "lib/events/events.h"
 #include "libcli/smb2/smb2_calls.h"
+#include "param/param.h"
 
 /*
   initialise a smb2 request
@@ -579,7 +580,7 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
                return NT_STATUS_OK;
        }
 
-       size = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, 
+       size = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, 
                                     blob.data, blob.length, &vstr);
        data_blob_free(&blob);
        (*str) = (char *)vstr;
@@ -604,7 +605,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
                return smb2_push_o16s16_blob(buf, ofs, data_blob(NULL, 0));
        }
 
-       size = convert_string_talloc(buf->buffer, global_smb_iconv_convenience, CH_UNIX, CH_UTF16, 
+       size = convert_string_talloc(buf->buffer, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16, 
                                     str, strlen(str), (void **)&blob.data);
        if (size == -1) {
                return NT_STATUS_ILLEGAL_CHARACTER;
index a1535d3043119ac287ad931b00b57343f93d5ba7..070ad99a827c71d5ea7eee0dbf1588eb86d249cf 100644 (file)
@@ -30,6 +30,7 @@
 #include "librpc/ndr/libndr.h"
 #include "lib/util/dlinklist.h"
 #include "librpc/gen_ndr/dcerpc.h"
+#include "param/param.h"
 
 #define NDR_BASE_MARSHALL_SIZE 1024
 
@@ -66,7 +67,7 @@ _PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *
 
        ndr->data = blob->data;
        ndr->data_size = blob->length;
-       ndr->iconv_convenience = talloc_reference(ndr, global_smb_iconv_convenience);
+       ndr->iconv_convenience = talloc_reference(ndr, lp_iconv_convenience(global_loadparm));
 
        return ndr;
 }
@@ -115,7 +116,7 @@ _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
        if (!ndr->data) {
                return NULL;
        }
-       ndr->iconv_convenience = talloc_reference(ndr, global_smb_iconv_convenience);
+       ndr->iconv_convenience = talloc_reference(ndr, lp_iconv_convenience(global_loadparm));
 
        return ndr;
 }
index 5c351b2df21b4aa2faf52db0e0bd31399c685377..3b9842db7f22a54d67779447eaae27700237b021 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "vfs_posix.h"
 #include "librpc/gen_ndr/security.h"
+#include "param/param.h"
 
 
 /*
@@ -107,16 +108,16 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
        while (*p2) {
                codepoint_t c1, c2;
                size_t c_size1, c_size2;
-               c1 = next_codepoint(global_smb_iconv_convenience, p1, &c_size1);
-               c2 = next_codepoint(global_smb_iconv_convenience, p2, &c_size2);
+               c1 = next_codepoint(lp_iconv_convenience(global_loadparm), p1, &c_size1);
+               c2 = next_codepoint(lp_iconv_convenience(global_loadparm), p2, &c_size2);
                if (c2 == '?') {
-                       d += push_codepoint(global_smb_iconv_convenience, d, c1);
+                       d += push_codepoint(lp_iconv_convenience(global_loadparm), d, c1);
                } else if (c2 == '*') {
                        memcpy(d, p1, strlen(p1));
                        d += strlen(p1);
                        break;
                } else {
-                       d += push_codepoint(global_smb_iconv_convenience, d, c2);
+                       d += push_codepoint(lp_iconv_convenience(global_loadparm), d, c2);
                }
 
                p1 += c_size1;
index f1d701b343e2312f9a39aa085d883d9624434dad..d9a60e385728df7f180bc1b206c6d8fff81a21cc 100644 (file)
@@ -29,8 +29,9 @@
 #include "includes.h"
 #include "vfs_posix.h"
 #include "system/dir.h"
+#include "param/param.h"
 
-/*
+/**
   compare two filename components. This is where the name mangling hook will go
 */
 static int component_compare(struct pvfs_state *pvfs, const char *comp, const char *name)
@@ -256,7 +257,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
 
        while (*p) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, p, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &c_size);
                switch (c) {
                case '\\':
                        if (name->has_wildcard) {
@@ -340,7 +341,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t
        if (s == NULL) return NT_STATUS_NO_MEMORY;
 
        for (num_components=1, p=s; *p; p += c_size) {
-               c = next_codepoint(global_smb_iconv_convenience, p, &c_size);
+               c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &c_size);
                if (c == '\\') num_components++;
        }
 
@@ -352,7 +353,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t
 
        components[0] = s;
        for (i=0, p=s; *p; p += c_size) {
-               c = next_codepoint(global_smb_iconv_convenience, p, &c_size);
+               c = next_codepoint(lp_iconv_convenience(global_loadparm), p, &c_size);
                if (c == '\\') {
                        *p = 0;
                        components[++i] = p+1;
index 68e415000ef9d1f1a2ff64f5734fab3d4a11caf9..083a2818193bae0b2301b240d6ef1eb48c1ea396 100644 (file)
@@ -388,7 +388,7 @@ static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
 {
        while (*name) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, name, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), name, &c_size);
                if (c == INVALID_CODEPOINT) {
                        return false;
                }
index b7cba00d9bc87fbe14f691f40c3ff0a7782d61d3..b52c3e387bd45516a44d478e1a0c0b2fd6734dd9 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "vfs_posix.h"
+#include "param/param.h"
 
 /*
   return true if a string contains one of the CIFS wildcard characters
@@ -181,7 +182,7 @@ uint32_t pvfs_name_hash(const char *key, size_t length)
 
        while (*key && length--) {
                size_t c_size;
-               codepoint_t c = next_codepoint(global_smb_iconv_convenience, key, &c_size);
+               codepoint_t c = next_codepoint(lp_iconv_convenience(global_loadparm), key, &c_size);
                c = toupper_w(c);
                 value *= fnv1_prime;
                 value ^= (uint32_t)c;
index 5fdb7aada615e07f6ef919317cf6aa1ce2d2f813..267f325dd4a595fe612eef7206104e179ed4dcb3 100644 (file)
@@ -83,8 +83,8 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
 
                p = (char *)io->ioctl.out.blob.data;
                SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
-               push_string(global_smb_iconv_convenience, p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
-               push_string(global_smb_iconv_convenience, p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
+               push_string(lp_iconv_convenience(global_loadparm), p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
+               push_string(lp_iconv_convenience(global_loadparm), p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
                return NT_STATUS_OK;
        }
 
index ef53a29b2be95dd0d677bfa91d7a2d13caa5f262..af3986c885ae05f75fd709115f5c7e8cb8d28656 100644 (file)
@@ -531,6 +531,7 @@ struct loadparm_context {
                time_t modtime;
        } *file_lists;
        unsigned int flags[NUMPARAMETERS];
+       struct smb_iconv_convenience *iconv_convenience;
 };
 
 
@@ -858,9 +859,11 @@ static bool lp_bool(const char *s)
 }
 
 
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-/* Returned value is allocated in 'lp_talloc' context */
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ * Returned value is allocated in 'lp_talloc' context 
+ */
 
 const char *lp_parm_string(struct loadparm_context *lp_ctx, 
                           struct loadparm_service *service, const char *type, 
@@ -874,9 +877,11 @@ const char *lp_parm_string(struct loadparm_context *lp_ctx,
        return NULL;
 }
 
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-/* Returned value is allocated in 'lp_talloc' context */
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ * Returned value is allocated in 'lp_talloc' context
+ */
 
 const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
                                 struct loadparm_context *lp_ctx, 
@@ -892,8 +897,10 @@ const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
        return NULL;
 }
 
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
 
 int lp_parm_int(struct loadparm_context *lp_ctx, 
                struct loadparm_service *service, const char *type, 
@@ -907,7 +914,8 @@ int lp_parm_int(struct loadparm_context *lp_ctx,
        return default_v;
 }
 
-/* Return parametric option from a given service. Type is a part of
+/**
+ * Return parametric option from a given service. Type is a part of
  * option before ':'.
  * Parametric option has following syntax: 'Type: option = value'.
  */
@@ -929,9 +937,11 @@ int lp_parm_bytes(struct loadparm_context *lp_ctx,
        return default_v;
 }
 
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
-
+/**
+ * Return parametric option from a given service. 
+ * Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
 unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx, 
                            struct loadparm_service *service, const char *type, 
                            const char *option, unsigned long default_v)
@@ -957,8 +967,10 @@ double lp_parm_double(struct loadparm_context *lp_ctx,
        return default_v;
 }
 
-/* Return parametric option from a given service. Type is a part of option before ':' */
-/* Parametric option has following syntax: 'Type: option = value' */
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
 
 bool lp_parm_bool(struct loadparm_context *lp_ctx, 
                  struct loadparm_service *service, const char *type, 
@@ -986,9 +998,9 @@ static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx)
 }
 
 /**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
Set a string value, deallocating any existing space, and allocing the space
for the string
+ */
 static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
 {
        talloc_free(*dest);
@@ -2447,7 +2459,7 @@ bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
 
        panic_action = lp_ctx->globals->panic_action;
 
-       reload_charcnv();
+       reload_charcnv(lp_ctx);
 
        return bRetval;
 }
@@ -2561,3 +2573,18 @@ int lp_maxprintjobs(struct loadparm_service *service)
 
        return maxjobs;
 }
+
+struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx)
+{
+       if (lp_ctx == NULL) {
+               return smb_iconv_convenience_init(talloc_autofree_context(), 
+                                                 "CP850", "UTF8", "UTF8", true);
+       }
+       return lp_ctx->iconv_convenience;
+}
+
+_PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
+{
+       talloc_free(lp_ctx->iconv_convenience);
+       lp_ctx->iconv_convenience = smb_iconv_convenience_init_lp(lp_ctx, lp_ctx);
+}
index 281d32f35f8ed9dd6c3d0de911ee77f3860e96c8..48ddbfdca0b3ddf53385120864d189d5ea0c217e 100644 (file)
@@ -283,13 +283,6 @@ _PUBLIC_ const char *lp_messaging_path(TALLOC_CTX *mem_ctx,
        return smbd_tmp_path(mem_ctx, lp_ctx, "messaging");
 }
 
-struct smb_iconv_convenience *global_smb_iconv_convenience = NULL;
-
-struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx)
-{
-       return global_smb_iconv_convenience;
-}
-
 struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx,
                                                         struct loadparm_context *lp_ctx)
 {
@@ -299,8 +292,4 @@ struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx,
                lp_parm_bool(lp_ctx, NULL, "iconv", "native", true));
 }
 
-_PUBLIC_ void reload_charcnv(void)
-{
-       talloc_free(global_smb_iconv_convenience);
-       global_smb_iconv_convenience = smb_iconv_convenience_init_lp(talloc_autofree_context(), global_loadparm);
-}
+
index d0dd96c087a6c812543b008b353c81c3a184bd1a..3ea41d46fb4d3038d100815f68d991ce039afe51 100644 (file)
@@ -177,7 +177,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv)
        case REG_EXPAND_SZ: {
                char *s;
                ssize_t len;
-               len = convert_string_talloc(mprMemCtx(), global_smb_iconv_convenience, CH_UTF16, CH_UNIX, 
+               len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, 
                                            blob->data, blob->length, (void **)&s);
                if (len == -1) {
                        ejsSetErrorMsg(eid, "regToVar invalid REG_SZ string");
@@ -225,7 +225,7 @@ static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv)
                        if (slen == 2 && b.length == 2 && SVAL(b.data, 0) == 0) {
                                break;
                        }
-                       len = convert_string_talloc(mprMemCtx(), global_smb_iconv_convenience, CH_UTF16, CH_UNIX, 
+                       len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, 
                                                    b.data, slen, (void **)&s);
                        if (len == -1) {
                                ejsSetErrorMsg(eid, "regToVar invalid REG_MULTI_SZ string");
index 237ebd4d7e5b96c42d435475604504bec38c45c9..21cddc4d7dada0c5bbb8c8b3e0cdb4bacc0a954c 100644 (file)
@@ -24,6 +24,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "ntvfs/ntvfs.h"
 #include "libcli/raw/libcliraw.h"
+#include "param/param.h"
 
 #define BLOB_CHECK(cmd) do { \
        NTSTATUS _status; \
@@ -138,10 +139,10 @@ size_t smbsrv_blob_push_string(TALLOC_CTX *mem_ctx,
                alignment = 1;
                if (dest_len > 0) {
                        SCVAL(blob->data + offset, 0, 0);
-                       ret = push_string(global_smb_iconv_convenience, blob->data + offset + 1, str, dest_len-1, flags);
+                       ret = push_string(lp_iconv_convenience(global_loadparm), blob->data + offset + 1, str, dest_len-1, flags);
                }
        } else {
-               ret = push_string(global_smb_iconv_convenience, blob->data + offset, str, dest_len, flags);
+               ret = push_string(lp_iconv_convenience(global_loadparm), blob->data + offset, str, dest_len, flags);
        }
 
        /* sometimes the string needs to be terminated, but the length
index 25cddd6654fabf4dcd16e9737c8710dd5f26e098..34f9df87066abdb92fdb73f5aa81c1745ccea6e3 100644 (file)
@@ -26,6 +26,7 @@
 #include "ntvfs/ntvfs.h"
 #include "libcli/raw/libcliraw.h"
 #include "librpc/gen_ndr/ndr_security.h"
+#include "param/param.h"
 
 /*
   hold the state of a nttrans op while in progress. Needed to allow for async backend
@@ -372,7 +373,7 @@ static NTSTATUS nttrans_notify_change_send(struct nttrans_op *op)
                ssize_t len;
 
                SIVAL(p, 4, info->nttrans.out.changes[i].action);
-               len = push_string(global_smb_iconv_convenience, p + 12, info->nttrans.out.changes[i].name.s, 
+               len = push_string(lp_iconv_convenience(global_loadparm), p + 12, info->nttrans.out.changes[i].name.s, 
                                  op->trans->out.params.length - 
                                  (p+12 - op->trans->out.params.data), STR_UNICODE);
                SIVAL(p, 8, len);
index cdeba02dd780c56e21743df281848e933c4f54e1..8f6d66450026178264a03cfb58eef143d81e4373 100644 (file)
@@ -27,6 +27,7 @@
 #include "smbd/service_stream.h"
 #include "lib/stream/packet.h"
 #include "ntvfs/ntvfs.h"
+#include "param/param.h"
 
 
 /* we over allocate the data buffer to prevent too many realloc calls */
@@ -408,7 +409,7 @@ size_t req_push_str(struct smbsrv_request *req, uint8_t *dest, const char *str,
                dest = req->out.buffer + PTR_DIFF(dest, buf0);
        }
 
-       len = push_string(global_smb_iconv_convenience, dest, str, len, flags);
+       len = push_string(lp_iconv_convenience(global_loadparm), dest, str, len, flags);
 
        grow_size = len + PTR_DIFF(dest, req->out.data);
 
@@ -494,7 +495,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
                return src_len2 + alignment;
        }
 
-       ret = convert_string_talloc(req, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
+       ret = convert_string_talloc(req, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
 
        if (ret == -1) {
                *dest = NULL;
@@ -543,7 +544,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
                src_len2++;
        }
 
-       ret = convert_string_talloc(req, global_smb_iconv_convenience, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
+       ret = convert_string_talloc(req, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
 
        if (ret == -1) {
                *dest = NULL;
index a5fc3d826876ac4cd3f75949317bac392c49a629..e853743b2f6612f349ae916b63b6fa90a3092b45 100644 (file)
@@ -24,6 +24,7 @@
 #include "smb_server/service_smb_proto.h"
 #include "smb_server/smb2/smb2_server.h"
 #include "ntvfs/ntvfs.h"
+#include "param/param.h"
 
 static void smb2srv_create_send(struct ntvfs_request *ntvfs)
 {
@@ -352,7 +353,7 @@ static void smb2srv_notify_send(struct ntvfs_request *ntvfs)
                ssize_t len;
 
                SIVAL(p, 4, io->smb2.out.changes[i].action);
-               len = push_string(global_smb_iconv_convenience, p + 12, io->smb2.out.changes[i].name.s, 
+               len = push_string(lp_iconv_convenience(global_loadparm), p + 12, io->smb2.out.changes[i].name.s, 
                                  blob.length - (p+12 - blob.data), STR_UNICODE);
                SIVAL(p, 8, len);
 
index fdeaefc443cb72e00c020989345f309ed60bcaf3..09d32d05aa39d7716d3ee0ef2ebb7338e0cc0e87 100644 (file)
@@ -198,7 +198,7 @@ _NORETURN_ static void standard_terminate(struct event_context *ev, const char *
 
        /* this reload_charcnv() has the effect of freeing the iconv context memory,
           which makes leak checking easier */
-       reload_charcnv();
+       reload_charcnv(global_loadparm);
 
        /* the secrets db should really hang off the connection structure */
        secrets_shutdown();
index 6b993aad8cda241f1ac0cd577c017ea8818e22bf..7dfbdebe7f08a75c909715739410e70fe8992213 100644 (file)
@@ -24,6 +24,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "libcli/libcli.h"
 #include "torture/util.h"
+#include "param/param.h"
 
 #define BASEDIR "\\chartest\\"
 
@@ -55,7 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
        }
        SSVAL(ucs_name, i*2, 0);
 
-       i = convert_string_talloc(ucs_name, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
+       i = convert_string_talloc(ucs_name, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
        if (i == -1) {
                torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
                talloc_free(ucs_name);
index 884be8490d400d2fab3cd64a131761405c152789..caccadb7eb2f6fe980c53ea1deb643aed1711e5c 100644 (file)
@@ -24,6 +24,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "system/filesys.h"
 #include "pstring.h"
+#include "param/param.h"
 
 #define VERBOSE 0
 #define OP_MIN 0
@@ -207,7 +208,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(global_smb_iconv_convenience, &param[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE);
 
        status = try_trans2_len(cli, "fname", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
@@ -218,7 +219,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(global_smb_iconv_convenience, &param[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE);
 
        status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
@@ -230,7 +231,7 @@ static bool scan_trans2(struct smbcli_state *cli, int op, int level,
        smbcli_mkdir(cli->tree, "\\testdir");
        param_len = 2;
        SSVAL(param, 0, level);
-       param_len += push_string(global_smb_iconv_convenience, &param[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE);
 
        status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
@@ -439,7 +440,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(global_smb_iconv_convenience, &param[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE);
 
        status = try_nttrans_len(cli, "fname", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
@@ -450,7 +451,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level,
        SSVAL(param, 0, level);
        SSVAL(param, 2, 0);
        SSVAL(param, 4, 0);
-       param_len += push_string(global_smb_iconv_convenience, &param[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE);
 
        status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
@@ -462,7 +463,7 @@ static bool scan_nttrans(struct smbcli_state *cli, int op, int level,
        smbcli_mkdir(cli->tree, "\\testdir");
        param_len = 2;
        SSVAL(param, 0, level);
-       param_len += push_string(global_smb_iconv_convenience, &param[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE);
+       param_len += push_string(lp_iconv_convenience(global_loadparm), &param[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE);
 
        status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len, 
                                &rparam_len, &rdata_len);
index 244378dbc9df997fc1a3153ee12d14dca86e4571..51b7b39309b1c30ea872e50ac9d1d6f0d4f3ab56 100644 (file)
@@ -24,6 +24,7 @@
 #include "libcli/libcli.h"
 #include "torture/util.h"
 #include "pstring.h"
+#include "param/param.h"
 
 bool torture_utable(struct torture_context *tctx, 
                                        struct smbcli_state *cli)
@@ -49,7 +50,7 @@ bool torture_utable(struct torture_context *tctx,
                SSVAL(c2, 0, c);
                fstrcpy(fname, "\\utable\\x");
                p = fname+strlen(fname);
-               len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, 
+               len = convert_string(lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, 
                                     c2, 2, 
                                     p, sizeof(fname)-strlen(fname));
                p[len] = 0;
@@ -108,7 +109,7 @@ static char *form_name(int c)
        p = fname+strlen(fname);
        SSVAL(c2, 0, c);
 
-       len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, 
+       len = convert_string(lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, 
                             c2, 2, 
                             p, sizeof(fname)-strlen(fname));
        p[len] = 0;
index 4603fd05e4bc774c118e188bc4fede69fa18db50..3eb815fe28550e6dda421bcc9a9d227367c2f881 100644 (file)
@@ -310,8 +310,6 @@ static void usage(void)
 
        seed = time(NULL);
 
-       reload_charcnv();
-
        while ((opt = getopt(argc, argv, "n:d:U:s:hm:f:aoW:M:vEl:")) != EOF) {
                switch (opt) {
                case 'n':
index 7ef25558000909f73b31e462a97237bf5231b068..d39a83034d98e4e248d3d11498268cb694e44e6b 100644 (file)
@@ -26,6 +26,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "libcli/libcli.h"
 #include "librpc/ndr/libndr.h"
+#include "param/param.h"
 
 #define RAP_GOTO(call) do { \
        NTSTATUS _status; \
@@ -182,7 +183,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
                return NT_STATUS_INVALID_PARAMETER;
 
        *dest = talloc_zero_array(mem_ctx, char, len+1);
-       pull_string(global_smb_iconv_convenience, *dest, p, len+1, len, STR_ASCII);
+       pull_string(lp_iconv_convenience(global_loadparm), *dest, p, len+1, len, STR_ASCII);
 
        return NT_STATUS_OK;
 }
index 496453e1812c13c30ee2c2903425d0b957f99ad1..a63772e96410ac47b388a32e74ccbcf29a5dcf6d 100644 (file)
@@ -2314,7 +2314,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, lp_iconv_convenience(global_loadparm)
                              name, servername) < 0) {
                return NT_STATUS_NO_MEMORY;
        }
index b60cef7d53082bf3fbe9adcbeda35e9da15e6818..7fd5199908fc0fc46bd1cb291ee26e4498780bc6 100644 (file)
@@ -1158,7 +1158,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
        ZERO_STRUCT(user_session_key);
        
        if ((push_ucs2_talloc(samlogon_state->mem_ctx, 
-                             global_smb_iconv_convenience
+                             lp_iconv_convenience(global_loadparm)
                              &unicodepw, samlogon_state->password)) == -1) {
                DEBUG(0, ("push_ucs2_allocate failed!\n"));
                exit(1);
@@ -1169,7 +1169,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
        password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password);
 
        if ((convert_string_talloc(samlogon_state->mem_ctx, 
-                                  global_smb_iconv_convenience,
+                                  lp_iconv_convenience(global_loadparm),
                                   CH_UNIX, CH_DOS, 
                                   password, strlen(password)+1, 
                                   (void**)&dospw)) == -1) {
index 8e22750d0c324fdbe748cb718a5cc41a9eb2115e..9192d98c734a3f223a8644ad58629983bf2c2683 100644 (file)
@@ -355,7 +355,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
 
        torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
 
-       convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UTF16,
+       convert_string_talloc(ctx, lp_iconv_convenience(global_loadparm), CH_UTF16,
                        CH_UNIX, epk.out.key_buffer, epk.out.needed,
                        (void**)&ctx->printer_keys);
 
index ddec59a15d3eff4bac96dc1f01e1f340aefc9921..98e811468d0cf1d9dbaeaa19ddab1150a6c0972d 100644 (file)
@@ -966,7 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx,
        size_t size;
        uint8_t *msg;
 
-       size = push_ucs2_talloc(tctx, global_smb_iconv_convenience
+       size = push_ucs2_talloc(tctx, lp_iconv_convenience(global_loadparm)
                                (void **)&msg, message);
 
        r.in.server_name = dcerpc_server_name(p);
index b35e62361036d0fcbbc0f0e972245c863280c89e..6d97e9ad9d67d31011bf9950cf79a8448977f251 100644 (file)
@@ -50,7 +50,7 @@ static bool run_matching(struct torture_context *torture,
                for (o = torture_root->children; o; o = o->next) {
                        if (gen_fnmatch(expr, o->name) == 0) {
                                *matched = true;
-                               reload_charcnv();
+                               reload_charcnv(torture->lp_ctx);
                                ret &= torture_run_suite(torture, o);
                                continue;
                        }
@@ -67,7 +67,7 @@ static bool run_matching(struct torture_context *torture,
 
                        if (gen_fnmatch(expr, name) == 0) {
                                *matched = true;
-                               reload_charcnv();
+                               reload_charcnv(torture->lp_ctx);
                                torture->active_testname = talloc_strdup(torture, prefix);
                                ret &= torture_run_suite(torture, c);
                                free(name);
@@ -83,7 +83,7 @@ static bool run_matching(struct torture_context *torture,
                        asprintf(&name, "%s-%s", prefix, t->name);
                        if (gen_fnmatch(expr, name) == 0) {
                                *matched = true;
-                               reload_charcnv();
+                               reload_charcnv(torture->lp_ctx);
                                torture->active_testname = talloc_strdup(torture, prefix);
                                ret &= torture_run_tcase(torture, t);
                                talloc_free(torture->active_testname);