diff options
Diffstat (limited to 'source4')
39 files changed, 176 insertions, 138 deletions
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c index cc1054ac48..bb2d7a14a8 100644 --- a/source4/auth/ntlmssp/ntlmssp_parse.c +++ b/source4/auth/ntlmssp/ntlmssp_parse.c @@ -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); diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index c301766c9d..24ef91777b 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -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)); \ diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index 749064d5cf..a8fe4a3b9d 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -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); diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c index 67a790c250..e0e1aed222 100644 --- a/source4/lib/charset/util_unistr.c +++ b/source4/lib/charset/util_unistr.c @@ -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; } diff --git a/source4/lib/policy/lex.c b/source4/lib/policy/lex.c index 5364706fc4..c2899aa808 100644 --- a/source4/lib/policy/lex.c +++ b/source4/lib/policy/lex.c @@ -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); \ diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 0e556da9e2..11fa066a35 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -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); diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 47bd160c54..9cc9a5dec2 100644 --- a/source4/lib/registry/patchfile_preg.c +++ b/source4/lib/registry/patchfile_preg.c @@ -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; } diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index f75fc835b5..a251ae49a5 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -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; diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c index 0757a02e47..80e1d9ae24 100644 --- a/source4/lib/tdr/tdr.c +++ b/source4/lib/tdr/tdr.c @@ -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); diff --git a/source4/lib/util/dprintf.c b/source4/lib/util/dprintf.c index 5b3fe4b1ea..ae2b7bb4d5 100644 --- a/source4/lib/util/dprintf.c +++ b/source4/lib/util/dprintf.c @@ -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 '?' */ diff --git a/source4/lib/util/ms_fnmatch.c b/source4/lib/util/ms_fnmatch.c index e1bf6f94c5..1fb57b07a4 100644 --- a/source4/lib/util/ms_fnmatch.c +++ b/source4/lib/util/ms_fnmatch.c @@ -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; } diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index ccad1058bf..26b78d25ef 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -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 diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index 972ae7f5e1..9827217a04 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -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) { diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index 43c984721b..e7dffaf054 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -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; diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index 5a7534f906..73c74dcfeb 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -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; diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index a1535d3043..070ad99a82 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -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; } diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index 5c351b2df2..3b9842db7f 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -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; diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index f1d701b343..d9a60e3857 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -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; diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c index 68e415000e..083a281819 100644 --- a/source4/ntvfs/posix/pvfs_shortname.c +++ b/source4/ntvfs/posix/pvfs_shortname.c @@ -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; } diff --git a/source4/ntvfs/posix/pvfs_util.c b/source4/ntvfs/posix/pvfs_util.c index b7cba00d9b..b52c3e387b 100644 --- a/source4/ntvfs/posix/pvfs_util.c +++ b/source4/ntvfs/posix/pvfs_util.c @@ -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; diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c index 5fdb7aada6..267f325dd4 100644 --- a/source4/ntvfs/print/vfs_print.c +++ b/source4/ntvfs/print/vfs_print.c @@ -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; } diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index ef53a29b2b..af3986c885 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -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); +} diff --git a/source4/param/util.c b/source4/param/util.c index 281d32f35f..48ddbfdca0 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -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); -} + diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c index d0dd96c087..3ea41d46fb 100644 --- a/source4/scripting/ejs/smbcalls_data.c +++ b/source4/scripting/ejs/smbcalls_data.c @@ -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"); diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c index 237ebd4d7e..21cddc4d7d 100644 --- a/source4/smb_server/blob.c +++ b/source4/smb_server/blob.c @@ -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 diff --git a/source4/smb_server/smb/nttrans.c b/source4/smb_server/smb/nttrans.c index 25cddd6654..34f9df8706 100644 --- a/source4/smb_server/smb/nttrans.c +++ b/source4/smb_server/smb/nttrans.c @@ -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); diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index cdeba02dd7..8f6d664500 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -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; diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c index a5fc3d8268..e853743b2f 100644 --- a/source4/smb_server/smb2/fileio.c +++ b/source4/smb_server/smb2/fileio.c @@ -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); diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index fdeaefc443..09d32d05aa 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -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(); diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index 6b993aad8c..7dfbdebe7f 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -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); diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c index 884be8490d..caccadb7eb 100644 --- a/source4/torture/basic/scanner.c +++ b/source4/torture/basic/scanner.c @@ -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, ¶m[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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, ¶m[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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, ¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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, ¶m[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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, ¶m[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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, ¶m[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), ¶m[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); diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 244378dbc9..51b7b39309 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -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; diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index 4603fd05e4..3eb815fe28 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -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': diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index 7ef2555800..d39a83034d 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -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; } diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 496453e181..a63772e964 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -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; } diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index b60cef7d53..7fd5199908 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -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) { diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c index 8e22750d0c..9192d98c73 100644 --- a/source4/torture/rpc/spoolss_win.c +++ b/source4/torture/rpc/spoolss_win.c @@ -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); diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index ddec59a15d..98e811468d 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -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); diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index b35e623610..6d97e9ad9d 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -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); |