diff options
-rw-r--r-- | lib/util/charset/charset.h | 9 | ||||
-rw-r--r-- | lib/util/charset/charset_macosxfs.c | 26 | ||||
-rw-r--r-- | lib/util/charset/charset_proto.h | 36 | ||||
-rw-r--r-- | lib/util/charset/codepoints.c | 14 | ||||
-rw-r--r-- | lib/util/charset/iconv.c | 115 | ||||
-rw-r--r-- | lib/util/charset/tests/convert_string.c | 22 | ||||
-rw-r--r-- | lib/util/charset/tests/iconv.c | 7 | ||||
-rw-r--r-- | lib/util/charset/weird.c | 25 | ||||
-rw-r--r-- | lib/util/charset/wscript_build | 23 | ||||
-rw-r--r-- | source3/Makefile.in | 11 | ||||
-rw-r--r-- | source3/configure.in | 6 | ||||
-rw-r--r-- | source4/param/util.c | 6 | ||||
-rw-r--r-- | source4/selftest/knownfail | 8 | ||||
-rwxr-xr-x | source4/selftest/tests.py | 6 | ||||
-rw-r--r-- | source4/torture/smbiconv.c | 2 |
15 files changed, 121 insertions, 195 deletions
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 2040e2a87c..d731ad1821 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -59,7 +59,7 @@ struct charset_functions { char **outbuf, size_t *outbytesleft); size_t (*push)(void *, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); - struct charset_functions *prev, *next; + bool samba_internal_charset; }; /* this type is used for manipulating unicode codepoints */ @@ -171,7 +171,7 @@ struct smb_iconv_handle *get_iconv_handle(void); struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv); + bool use_builtin_handlers); smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, charset_t from, charset_t to); const char *charset_name(struct smb_iconv_handle *ic, charset_t ch); @@ -200,7 +200,7 @@ int codepoint_cmpi(codepoint_t c1, codepoint_t c2); struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv, + bool use_builtin_handlers, struct smb_iconv_handle *old_ic); bool convert_string_handle(struct smb_iconv_handle *ic, @@ -225,11 +225,10 @@ size_t smb_iconv(smb_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, - const char *fromcode, bool native_iconv); + const char *fromcode, bool use_builtin_handlers); void load_case_tables(void); void load_case_tables_library(void); -bool smb_register_charset(const struct charset_functions *funcs_in); /* The following definitions come from util_unistr_w.c */ diff --git a/lib/util/charset/charset_macosxfs.c b/lib/util/charset/charset_macosxfs.c index 4d2ba5b6ff..dfd142a51e 100644 --- a/lib/util/charset/charset_macosxfs.c +++ b/lib/util/charset/charset_macosxfs.c @@ -30,8 +30,11 @@ */ #include "includes.h" +#include "charset_proto.h" #undef realloc +#ifdef DARWIN + /* * Include OS frameworks. These are only needed in this module. */ @@ -201,7 +204,7 @@ static void hexdump( const char * label, const char * s, size_t len ) * generic, not specifically for the file system. So they may not be * perfect fits. */ -static size_t macosxfs_encoding_pull( +size_t macosxfs_encoding_pull( void *cd, /* Encoder handle */ char **inbuf, size_t *inbytesleft, /* Script string */ char **outbuf, size_t *outbytesleft) /* UTF-16-LE string */ @@ -323,7 +326,7 @@ static size_t macosxfs_encoding_pull( return 0; } -static size_t macosxfs_encoding_push( +size_t macosxfs_encoding_push( void *cd, /* Encoder handle */ char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */ char **outbuf, size_t *outbytesleft) /* Script string */ @@ -587,19 +590,12 @@ static size_t macosxfs_encoding_push( #endif /* USE_INTERNAL_API */ -/* - * For initialization, actually install the encoding as "macosxfs". - */ -static struct charset_functions macosxfs_encoding_functions = { - "MACOSXFS", macosxfs_encoding_pull, macosxfs_encoding_push -}; - -NTSTATUS charset_macosxfs_init(void) +#else /* DARWIN */ + +void charset_macosfs_dummy(void); +void charset_macosfs_dummy(void) { - if (!smb_register_charset(&macosxfs_encoding_functions)) { - return NT_STATUS_INTERNAL_ERROR; - } - return NT_STATUS_OK; + return; } -/* eof */ +#endif /* DARWIN */ diff --git a/lib/util/charset/charset_proto.h b/lib/util/charset/charset_proto.h new file mode 100644 index 0000000000..3b3187a6eb --- /dev/null +++ b/lib/util/charset/charset_proto.h @@ -0,0 +1,36 @@ +/* + Unix SMB/CIFS implementation. + Samba charset modules + Copyright (C) Andrew Tridgell 2001 + Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Benjamin Riefenstahl 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); +size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + +size_t macosxfs_encoding_pull( + void *cd, /* Encoder handle */ + char **inbuf, size_t *inbytesleft, /* Script string */ + char **outbuf, size_t *outbytesleft); /* UTF-16-LE string */ +size_t macosxfs_encoding_push( + void *cd, /* Encoder handle */ + char **inbuf, size_t *inbytesleft, /* UTF-16-LE string */ + char **outbuf, size_t *outbytesleft); /* Script string */ + + diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 0d1020f7a0..0984164d48 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -158,7 +158,7 @@ struct smb_iconv_handle { const char *unix_charset; const char *dos_charset; const char *display_charset; - bool native_iconv; + bool use_builtin_handlers; smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS]; }; @@ -175,10 +175,10 @@ struct smb_iconv_handle *get_iconv_handle(void) struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv) + bool use_builtin_handlers) { return smb_iconv_handle_reinit(mem_ctx, - dos_charset, unix_charset, native_iconv, NULL); + dos_charset, unix_charset, use_builtin_handlers, NULL); } /** @@ -229,7 +229,7 @@ static int close_iconv_handle(struct smb_iconv_handle *data) _PUBLIC_ struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, - bool native_iconv, + bool use_builtin_handlers, struct smb_iconv_handle *old_ic) { struct smb_iconv_handle *ret; @@ -262,7 +262,7 @@ _PUBLIC_ struct smb_iconv_handle *smb_iconv_handle_reinit(TALLOC_CTX *mem_ctx, ret->dos_charset = talloc_strdup(ret->child_ctx, dos_charset); ret->unix_charset = talloc_strdup(ret->child_ctx, unix_charset); - ret->native_iconv = native_iconv; + ret->use_builtin_handlers = use_builtin_handlers; return ret; } @@ -283,7 +283,7 @@ smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, n2 = charset_name(ic, to); ic->conv_handles[from][to] = smb_iconv_open_ex(ic, n2, n1, - ic->native_iconv); + ic->use_builtin_handlers); if (ic->conv_handles[from][to] == (smb_iconv_t)-1) { if ((from == CH_DOS || to == CH_DOS) && @@ -296,7 +296,7 @@ smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic, n2 = charset_name(ic, to); ic->conv_handles[from][to] = - smb_iconv_open_ex(ic, n2, n1, ic->native_iconv); + smb_iconv_open_ex(ic, n2, n1, ic->use_builtin_handlers); } } diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c index fd8b8ae8ee..1c507b4b13 100644 --- a/lib/util/charset/iconv.c +++ b/lib/util/charset/iconv.c @@ -22,15 +22,12 @@ #include "../lib/util/dlinklist.h" #include "system/iconv.h" #include "system/filesys.h" +#include "charset_proto.h" #ifdef strcasecmp #undef strcasecmp #endif -#ifdef static_decl_charset -static_decl_charset; -#endif - /** * @file * @@ -78,65 +75,20 @@ static const struct charset_functions builtin_functions[] = { {"UTF-8", utf8_pull, utf8_push}, /* this handles the munging needed for String2Key */ - {"UTF16_MUNGED", utf16_munged_pull, iconv_copy}, + {"UTF16_MUNGED", utf16_munged_pull, iconv_copy, true}, {"ASCII", ascii_pull, ascii_push}, {"646", ascii_pull, ascii_push}, {"ISO-8859-1", latin1_pull, latin1_push}, - {"UCS2-HEX", ucs2hex_pull, ucs2hex_push} -}; - -static struct charset_functions *charsets = NULL; - -static struct charset_functions *find_charset_functions(const char *name) -{ - struct charset_functions *c; - - /* Check whether we already have this charset... */ - for (c = charsets; c != NULL; c = c->next) { - if(strcasecmp(c->name, name) == 0) { - return c; - } - } - - return NULL; -} - -bool smb_register_charset(const struct charset_functions *funcs_in) -{ - struct charset_functions *funcs; - - DEBUG(5, ("Attempting to register new charset %s\n", funcs_in->name)); - /* Check whether we already have this charset... */ - if (find_charset_functions(funcs_in->name)) { - DEBUG(0, ("Duplicate charset %s, not registering\n", funcs_in->name)); - return false; - } - - funcs = talloc(NULL, struct charset_functions); - if (!funcs) { - DEBUG(0, ("Out of memory duplicating charset %s\n", funcs_in->name)); - return false; - } - *funcs = *funcs_in; - - funcs->next = funcs->prev = NULL; - DEBUG(5, ("Registered charset %s\n", funcs->name)); - DLIST_ADD(charsets, funcs); - return true; -} - -static void lazy_initialize_iconv(void) -{ -#ifdef static_init_charset - static bool initialized = false; - - if (!initialized) { - static_init_charset; - initialized = true; - } +#ifdef DEVELOPER + {"WEIRD", weird_pull, weird_push, true}, #endif -} +#ifdef DARWINOS + {"MACOSXFS", macosxfs_encoding_pull, macosxfs_encoding_push, true}, +#endif + {"UCS2-HEX", ucs2hex_pull, ucs2hex_push, true} + +}; #ifdef HAVE_NATIVE_ICONV /* if there was an error then reset the internal state, @@ -244,14 +196,12 @@ static int smb_iconv_t_destructor(smb_iconv_t hwd) } _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, - const char *fromcode, bool allow_native_iconv) + const char *fromcode, bool use_builtin_handlers) { smb_iconv_t ret; const struct charset_functions *from=NULL, *to=NULL; int i; - lazy_initialize_iconv(); - ret = (smb_iconv_t)talloc_named(mem_ctx, sizeof(*ret), "iconv(%s,%s)", tocode, fromcode); @@ -271,10 +221,14 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, /* check if we have a builtin function for this conversion */ for (i=0;i<ARRAY_SIZE(builtin_functions);i++) { if (strcasecmp(fromcode, builtin_functions[i].name) == 0) { - from = &builtin_functions[i]; + if (use_builtin_handlers || builtin_functions[i].samba_internal_charset) { + from = &builtin_functions[i]; + } } - if (strcasecmp(tocode, builtin_functions[i].name) == 0) { - to = &builtin_functions[i]; + if (strcasecmp(tocode, builtin_functions[i].name) == 0) { + if (use_builtin_handlers || builtin_functions[i].samba_internal_charset) { + to = &builtin_functions[i]; + } } } @@ -284,7 +238,7 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, * initialised only in this block for iconv based * conversions */ - if (allow_native_iconv && from == NULL) { + if (from == NULL) { ret->cd_pull = iconv_open("UTF-16LE", fromcode); if (ret->cd_pull == (iconv_t)-1) ret->cd_pull = iconv_open("UCS-2LE", fromcode); @@ -293,7 +247,7 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, } } - if (allow_native_iconv && to == NULL) { + if (to == NULL) { ret->cd_push = iconv_open(tocode, "UTF-16LE"); if (ret->cd_push == (iconv_t)-1) ret->cd_push = iconv_open(tocode, "UCS-2LE"); @@ -303,35 +257,6 @@ _PUBLIC_ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode, } #endif - /* If iconv was unable to provide the conversion, or if use of - * it was disabled, and it wasn't a builtin charset, try a - * module */ - if (ret->pull == NULL && from == NULL) { - from = find_charset_functions(fromcode); - } - - if (ret->push == NULL && to == NULL) { - to = find_charset_functions(tocode); - } - - /* In the WAF builds, all charset modules are linked in at compile - * time, as we have shared libs. Using run-time loading as well will - * cause dependency loops. For the autoconf build, try loading from a module */ -#ifndef _SAMBA_WAF_BUILD_ - /* check if there is a module available that can do this conversion */ - if (from == NULL && ret->pull == NULL && NT_STATUS_IS_OK(smb_probe_module("charset", fromcode))) { - if (!(from = find_charset_functions(fromcode))) { - DEBUG(0, ("Module %s doesn't provide charset %s!\n", fromcode, fromcode)); - } - } - - if (to == NULL && ret->push == NULL && NT_STATUS_IS_OK(smb_probe_module("charset", tocode))) { - if (!(to = find_charset_functions(tocode))) { - DEBUG(0, ("Module %s doesn't provide charset %s!\n", tocode, tocode)); - } - } -#endif - if (ret->pull == NULL && from == NULL) { goto failed; } diff --git a/lib/util/charset/tests/convert_string.c b/lib/util/charset/tests/convert_string.c index 2c0fe9fc8f..918be496b6 100644 --- a/lib/util/charset/tests/convert_string.c +++ b/lib/util/charset/tests/convert_string.c @@ -107,7 +107,7 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -300,7 +300,7 @@ static bool test_gd_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); gd_utf8_terminated = data_blob_talloc(tctx, NULL, gd_utf8.length + 1); @@ -485,7 +485,7 @@ static bool test_gd_ascii_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -555,7 +555,7 @@ static bool test_plato_english_iso8859_cp850_handle(struct torture_context *tctx talloc_steal(tctx, plato_english_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -674,7 +674,7 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, plato_english_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); plato_english_utf8_terminated = data_blob_talloc(tctx, NULL, plato_english_utf8.length + 1); @@ -816,7 +816,7 @@ static bool test_plato_minus_1_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting iconv handle"); plato_utf8_terminated = data_blob_talloc(tctx, NULL, plato_utf8.length + 1); @@ -931,7 +931,7 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "creating iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -1123,7 +1123,7 @@ static bool test_plato_latin_cp850_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_latin_utf16le.data); iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "creating iconv handle"); torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, @@ -1192,7 +1192,7 @@ static bool test_gd_case_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, gd_utf8.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting utf8 iconv handle"); torture_assert(tctx, @@ -1256,7 +1256,7 @@ static bool test_gd_case_cp850_handle(struct torture_context *tctx) talloc_steal(tctx, gd_cp850.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "CP850", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting cp850 iconv handle"); torture_assert(tctx, @@ -1318,7 +1318,7 @@ static bool test_plato_case_utf8_handle(struct torture_context *tctx) talloc_steal(tctx, plato_utf8.data); iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", - lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); torture_assert(tctx, iconv_handle, "getting utf8 iconv handle"); torture_assert(tctx, diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c index 48702e9c50..6704541016 100644 --- a/lib/util/charset/tests/iconv.c +++ b/lib/util/charset/tests/iconv.c @@ -35,9 +35,6 @@ static bool iconv_untestable(struct torture_context *tctx) { iconv_t cd; - if (!lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)) - torture_skip(tctx, "system iconv disabled - skipping test"); - cd = iconv_open("UTF-16LE", "UCS-4LE"); if (cd == (iconv_t)-1) torture_skip(tctx, "unable to test - system iconv library does not support UTF-16LE -> UCS-4LE"); @@ -158,14 +155,14 @@ static bool test_buffer(struct torture_context *test, "failed to open %s to UTF-16LE", charset)); } - cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", false); + cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", lpcfg_parm_bool(test->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); if (cd2 == (iconv_t)-1) { torture_fail(test, talloc_asprintf(test, "failed to open %s to UTF-16LE via smb_iconv_open_ex", charset)); } - cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, false); + cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, lpcfg_parm_bool(test->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); if (cd3 == (iconv_t)-1) { torture_fail(test, talloc_asprintf(test, diff --git a/lib/util/charset/weird.c b/lib/util/charset/weird.c index 5db8cdcecd..7f766417dc 100644 --- a/lib/util/charset/weird.c +++ b/lib/util/charset/weird.c @@ -19,6 +19,9 @@ */ #include "includes.h" +#include "charset_proto.h" + +#ifdef DEVELOPER static struct { char from; @@ -30,8 +33,8 @@ static struct { {0, NULL} }; -static size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) +size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 1 && *outbytesleft >= 2) { int i; @@ -73,8 +76,8 @@ static size_t weird_pull(void *cd, const char **inbuf, size_t *inbytesleft, return 0; } -static size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) +size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { int ir_count=0; @@ -122,13 +125,11 @@ static size_t weird_push(void *cd, const char **inbuf, size_t *inbytesleft, return ir_count; } -struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; - -NTSTATUS charset_weird_init(void); -NTSTATUS charset_weird_init(void) +#else +void charset_weird_dummy(void); +void charset_weird_dummy(void) { - if (!smb_register_charset(&weird_functions)) { - return NT_STATUS_INTERNAL_ERROR; - } - return NT_STATUS_OK; + return; } + +#endif diff --git a/lib/util/charset/wscript_build b/lib/util/charset/wscript_build index 390a1448fb..621fed6c0e 100644 --- a/lib/util/charset/wscript_build +++ b/lib/util/charset/wscript_build @@ -6,27 +6,6 @@ bld.SAMBA_SUBSYSTEM('ICONV_WRAPPER', bld.SAMBA_SUBSYSTEM('charset', public_headers='charset.h', - source='codepoints.c convert_string.c util_str.c util_unistr_w.c charcnv.c pull_push.c util_unistr.c', + source='codepoints.c convert_string.c util_str.c util_unistr_w.c charcnv.c pull_push.c util_unistr.c weird.c charset_macosxfs.c', deps='DYNCONFIG ICONV_WRAPPER', public_deps='talloc') - -# In the WAF builds, all charset modules are linked in at compile -# time, as we have shared libs. Using run-time loading as well will -# cause dependency loops - -bld.SAMBA_MODULE('charset_weird', - subsystem='charset', - source='weird.c', - init_function='charset_weird_init', - deps='samba-util', - internal_module=True, - enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_weird')) - -bld.SAMBA_MODULE('charset_macosxfs', - subsystem='charset', - source='charset_macosxfs.c', - init_function='charset_macosxfs_init', - internal_module=True, - enabled=bld.SAMBA3_IS_ENABLED_MODULE('charset_macosxfs')) - - diff --git a/source3/Makefile.in b/source3/Makefile.in index 02b7a294f5..d64adb8baa 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -460,7 +460,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) $(LIBTSOCKET_OBJ) \ lib/ms_fnmatch.o ../lib/util/ms_fnmatch.o lib/errmap_unix.o ../libcli/util/errmap_unix.o \ lib/tallocmsg.o lib/dmallocmsg.o \ libsmb/smb_signing.o \ - ../lib/util/charset/iconv.o intl/lang_tdb.o \ + ../lib/util/charset/iconv.o ../lib/util/charset/weird.o \ + ../lib/util/charset/charset_macosxfs.o intl/lang_tdb.o \ lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \ lib/sessionid_tdb.o \ lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \ @@ -2905,14 +2906,6 @@ bin/ldap.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_ldap.o $(IDMAP_RW_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) winbindd/idmap_ldap.o $(IDMAP_RW_OBJ) -bin/weird.@SHLIBEXT@: $(BINARY_PREREQS) $(DEVEL_HELP_WEIRD_OBJ) - @echo "Building plugin $@" - @$(SHLD_MODULE) $(DEVEL_HELP_WEIRD_OBJ) - -bin/macosxfs.@SHLIBEXT@: $(BINARY_PREREQS) $(CHARSET_MACOSXFS_OBJ) - @echo "Building plugin $@" - @$(SHLD_MODULE) $(CHARSET_MACOSXFS_OBJ) -framework CoreFoundation - # NOTE, there is no build rule for a dynamic default VFS module because # this one MUST MUST MUST be built statically. diff --git a/source3/configure.in b/source3/configure.in index 32172faec4..068728578e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -474,7 +474,7 @@ default_shared_modules="$default_shared_modules idmap_autorid" if test "x$developer" = xyes; then default_static_modules="$default_static_modules rpc_rpcecho pdb_ads" default_static_modules="$default_static_modules auth_netlogond" - default_shared_modules="$default_shared_modules charset_weird perfcount_test" + default_shared_modules="$default_shared_modules perfcount_test" fi # @@ -683,7 +683,7 @@ main() { AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters]) # Add a system specific charset module. - default_shared_modules="$default_shared_modules charset_macosxfs" + default_shared_modules="$default_shared_modules" ;; *hurd*) @@ -6877,8 +6877,6 @@ SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o) SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO) SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o) -SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET) -SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET) SMB_SUBSYSTEM(CHARSET,lib/iconv.o) SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH) diff --git a/source4/param/util.c b/source4/param/util.c index 92672ecba2..d5b9583795 100644 --- a/source4/param/util.c +++ b/source4/param/util.c @@ -351,9 +351,9 @@ struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx, struct smb_iconv_handle *old_ic) { return smb_iconv_handle_reinit(mem_ctx, lpcfg_dos_charset(lp_ctx), - lpcfg_unix_charset(lp_ctx), - lpcfg_parm_bool(lp_ctx, NULL, "iconv", "native", true), - old_ic); + lpcfg_unix_charset(lp_ctx), + true, + old_ic); } diff --git a/source4/selftest/knownfail b/source4/selftest/knownfail index 0152676b77..ab1f8170c7 100644 --- a/source4/selftest/knownfail +++ b/source4/selftest/knownfail @@ -5,9 +5,11 @@ # a successful run for any of these tests an error. ^samba4.local.resolve.*.async ^samba4.local.iconv.*.next_codepoint() -^samba4.local.iconv.5M random UTF-16LE sequences # Fails because our CP850 module returns the wrong error codes -^samba4.local.convert_string_handle.iconv.modules.plato_cp850_utf8 -^samba4.local.convert_string.iconv.modules.plato +# these show that we still have some differences between our system +# with our internal iconv because it passes except when we bypass our +# internal iconv modules +^samba4.local.convert_string_handle.system.iconv.gd_ascii +^samba4.local.convert_string_handle.system.iconv.gd_iso8859_cp850 ^samba4..*base.delete.*.deltest17 ^samba4..*base.delete.*.deltest20a ^samba4..*base.delete.*.deltest20b diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 60e16a5d16..5b008a0e9d 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -273,9 +273,9 @@ for t in smb4torture_testsuites("local."): # Confirm these tests with the system iconv too for t in ["local.convert_string_handle", "local.convert_string", "local.ndr"]: - modname = "samba4.%s.iconv.modules" % t - cmdline = "%s %s %s" % (valgrindify(smb4torture), "ncalrpc: --option='iconv:native=false'", t) - plantestsuite_loadlist(modname, env, cmdline) + modname = "samba4.%s.system.iconv" % t + cmdline = "%s %s %s" % (valgrindify(smb4torture), "ncalrpc: --option='iconv:use_builtin_handlers=false'", t) + plantestsuite_loadlist(modname, "none", cmdline) tdbtorture4 = binpath("tdbtorture") if os.path.exists(tdbtorture4): diff --git a/source4/torture/smbiconv.c b/source4/torture/smbiconv.c index f1a7d899a5..45166083b7 100644 --- a/source4/torture/smbiconv.c +++ b/source4/torture/smbiconv.c @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) } } - cd = smb_iconv_open_ex(tctx, to, from, lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true)); + cd = smb_iconv_open_ex(tctx, to, from, lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true)); if((int)cd == -1) { DEBUG(0,("unable to find from or to encoding, exiting...\n")); if (out != stdout) fclose(out); |