The Samba-Bugzilla – Attachment 8650 Details for
Bug 9723
Add a tool to migrate latin1 printing tdb's to registry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
v3-6-test patch
v3-6-test-ntprinting.patch (text/plain), 33.14 KB, created by
Andreas Schneider
on 2013-03-15 13:39:54 UTC
(
hide
)
Description:
v3-6-test patch
Filename:
MIME Type:
Creator:
Andreas Schneider
Created:
2013-03-15 13:39:54 UTC
Size:
33.14 KB
patch
obsolete
>From bd173f7a1ee1e35fd7f1ba350c4fbc52646d8a9c Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 12 Mar 2013 11:36:38 +0100 >Subject: [PATCH 1/7] pidl: Add skip option to elements. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This option allows to skip struct elements in pull and push function. >This can be used to pass flags to the structure e.g. for string values. > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > pidl/lib/Parse/Pidl/NDR.pm | 1 + > pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > >diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm >index 71e7228..c4cef64 100644 >--- a/pidl/lib/Parse/Pidl/NDR.pm >+++ b/pidl/lib/Parse/Pidl/NDR.pm >@@ -1070,6 +1070,7 @@ my %property_list = ( > "noprint" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT", "PIPE"], > "nopython" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"], > "todo" => ["FUNCTION"], >+ "skip" => ["ELEMENT"], > > # union > "switch_is" => ["ELEMENT"], >diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm >index 3676d6d..10a886a 100644 >--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm >+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm >@@ -924,7 +924,11 @@ sub ParseDataPull($$$$$$$) > > $var_name = get_pointer_to($var_name); > >- $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); >+ if (has_property($e, "skip")) { >+ $self->pidl("/* [skip] '$var_name' */"); >+ } else { >+ $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); >+ } > > my $pl = GetPrevLevel($e, $l); > >@@ -962,7 +966,11 @@ sub ParseDataPush($$$$$$$) > $var_name = get_pointer_to($var_name); > } > >- $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); >+ if (has_property($e, "skip")) { >+ $self->pidl("/* [skip] '$var_name' */"); >+ } else { >+ $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); >+ } > } else { > $self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred); > } >-- >1.8.1.5 > > >From 6889306316d44b8964979e0e9ef328e011370f07 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Mon, 11 Mar 2013 15:45:15 +0100 >Subject: [PATCH 2/7] ndr: Add ndr_ntprinting_string_flags() function. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >It defaults to utf8string. > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > librpc/ndr/ndr_ntprinting.c | 13 +++++++++++++ > librpc/ndr/ndr_ntprinting.h | 2 ++ > 2 files changed, 15 insertions(+) > >diff --git a/librpc/ndr/ndr_ntprinting.c b/librpc/ndr/ndr_ntprinting.c >index 76b296d..8d392b0 100644 >--- a/librpc/ndr/ndr_ntprinting.c >+++ b/librpc/ndr/ndr_ntprinting.c >@@ -22,6 +22,19 @@ > #include "includes.h" > #include "../librpc/gen_ndr/ndr_ntprinting.h" > >+_PUBLIC_ uint32_t ndr_ntprinting_string_flags(uint32_t string_flags) >+{ >+ uint32_t flags = LIBNDR_FLAG_STR_NULLTERM; >+ >+ if (string_flags & LIBNDR_FLAG_STR_ASCII) { >+ flags |= LIBNDR_FLAG_STR_ASCII; >+ } else { >+ flags |= LIBNDR_FLAG_STR_UTF8; >+ } >+ >+ return flags; >+} >+ > _PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, int ndr_flags, struct ntprinting_printer *r) > { > uint32_t _ptr_devmode; >diff --git a/librpc/ndr/ndr_ntprinting.h b/librpc/ndr/ndr_ntprinting.h >index 8bda430..3b6ee01 100644 >--- a/librpc/ndr/ndr_ntprinting.h >+++ b/librpc/ndr/ndr_ntprinting.h >@@ -22,4 +22,6 @@ > #include "includes.h" > #include "../librpc/gen_ndr/ndr_ntprinting.h" > >+_PUBLIC_ uint32_t ndr_ntprinting_string_flags(uint32_t string_flags); >+ > _PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, int ndr_flags, struct ntprinting_printer *r); >-- >1.8.1.5 > > >From e99349ccb6502d2a14a0a41a9401e479aaa7f55b Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Mon, 11 Mar 2013 15:47:00 +0100 >Subject: [PATCH 3/7] idl: Add flags for strings in ntprinting idl. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > librpc/idl/ntprinting.idl | 69 ++++++++++++++++++++++++++++------------------- > 1 file changed, 42 insertions(+), 27 deletions(-) > >diff --git a/librpc/idl/ntprinting.idl b/librpc/idl/ntprinting.idl >index 7013566..8152144 100644 >--- a/librpc/idl/ntprinting.idl >+++ b/librpc/idl/ntprinting.idl >@@ -30,20 +30,24 @@ interface ntprinting > [in] ntprinting_form form > ); > >- /* Samba 3 tdb storage format: drivers >+ /* >+ * First the string flags and then the Samba 3 tdb storage >+ * format: drivers > * "dffffffff" followed by a remaining buffer of "f" array */ > > typedef [flag(NDR_NOALIGN),public] struct { >+ [skip] uint32 string_flags; >+ > uint32 version; >- utf8string name; >- utf8string environment; >- utf8string driverpath; >- utf8string datafile; >- utf8string configfile; >- utf8string helpfile; >- utf8string monitorname; >- utf8string defaultdatatype; >- [flag(STR_UTF8|STR_NOTERM|NDR_REMAINING)] string_array dependent_files; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string name; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string environment; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string driverpath; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string datafile; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string configfile; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string helpfile; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string monitorname; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string defaultdatatype; >+ [flag((ndr_ntprinting_string_flags(r->string_flags)&~STR_NULLTERM)|STR_NOTERM|NDR_REMAINING)] string_array dependent_files; > } ntprinting_driver; > > [public] void decode_ntprinting_driver( >@@ -57,9 +61,11 @@ interface ntprinting > * "B" private data blob */ > > typedef [flag(NDR_NOALIGN),public] struct { >+ [skip] uint32 string_flags; >+ > /* uint32 devicemode_ptr; */ >- utf8string devicename; >- utf8string formname; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string devicename; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string formname; > uint16 specversion; > uint16 driverversion; > uint16 size; >@@ -95,21 +101,30 @@ interface ntprinting > DATA_BLOB *nt_dev_private; > } ntprinting_devicemode; > >- /* Samba 3 tdb storage format: printer_data >+ /* >+ * First the string flags and then the Samba 3 tdb storage >+ * format: printer_data > * "p" ptr to printer_data > * "fdB" */ > > typedef [flag(NDR_NOALIGN),public] struct { >+ [skip] uint32 string_flags; >+ > uint32 ptr; >- utf8string name; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string name; > uint32 type; > DATA_BLOB data; > } ntprinting_printer_data; > >- /* Samba 3 tdb storage format: printer_info >- * "dddddddddddfffffPfffff" */ >+ /* >+ * First the string flags and then the Samba 3 tdb storage >+ * format: printer_info >+ * "dddddddddddfffffPfffff" >+ */ > > typedef [flag(NDR_NOALIGN),public] struct { >+ [skip] uint32 string_flags; >+ > uint32 attributes; > uint32 priority; > uint32 default_priority; >@@ -121,17 +136,17 @@ interface ntprinting > uint32 changeid; > uint32 c_setprinter; > uint32 setuptime; >- utf8string servername; >- utf8string printername; >- utf8string sharename; >- utf8string portname; >- utf8string drivername; >- utf8string comment; >- utf8string location; >- utf8string sepfile; >- utf8string printprocessor; >- utf8string datatype; >- utf8string parameters; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string servername; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string printername; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string sharename; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string portname; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string drivername; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string comment; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string location; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string sepfile; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string printprocessor; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string datatype; >+ [flag(ndr_ntprinting_string_flags(r->string_flags))] string parameters; > } ntprinting_printer_info; > > /* Abstract Samba 3 printer >-- >1.8.1.5 > > >From e82194c261a1c5df36e0d63ebaf4df7a86048e67 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 12 Mar 2013 15:17:54 +0100 >Subject: [PATCH 4/7] ndr: Pass down string_flags in > ndr_pull_ntprinting_printer(). >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > librpc/ndr/ndr_ntprinting.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/librpc/ndr/ndr_ntprinting.c b/librpc/ndr/ndr_ntprinting.c >index 8d392b0..cb5293b 100644 >--- a/librpc/ndr/ndr_ntprinting.c >+++ b/librpc/ndr/ndr_ntprinting.c >@@ -56,6 +56,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, int > if (r->devmode) { > _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr); > NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0); >+ r->devmode->string_flags = r->info.string_flags; > NDR_CHECK(ndr_pull_ntprinting_devicemode(ndr, NDR_SCALARS|NDR_BUFFERS, r->devmode)); > NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0); > } >@@ -72,6 +73,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, int > } > r->printer_data = talloc_realloc(ndr, r->printer_data, struct ntprinting_printer_data, r->count + 1); > NDR_ERR_HAVE_NO_MEMORY(r->printer_data); >+ r->printer_data[r->count].string_flags = r->info.string_flags; > NDR_CHECK(ndr_pull_ntprinting_printer_data(ndr, NDR_SCALARS, &r->printer_data[r->count])); > r->count++; > } >-- >1.8.1.5 > > >From 17383f572ea6b1dad8b3726b803e1e7517aa8dd7 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 12 Mar 2013 11:39:08 +0100 >Subject: [PATCH 5/7] s3-net: Add encoding=<CP> to 'net printing migrate'. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This allows you to convert printing tdb's which are in e.g. in latin1 to >convert to UTF-8 and import them into the registry. > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > source3/printing/nt_printing_migrate.c | 14 ++++- > source3/printing/nt_printing_migrate.h | 6 +- > source3/printing/nt_printing_migrate_internal.c | 6 +- > source3/utils/net_printing.c | 75 +++++++++++++++++++++++-- > 4 files changed, 90 insertions(+), 11 deletions(-) > >diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c >index 6eb2f44..7776619 100644 >--- a/source3/printing/nt_printing_migrate.c >+++ b/source3/printing/nt_printing_migrate.c >@@ -103,7 +103,8 @@ NTSTATUS printing_tdb_migrate_driver(TALLOC_CTX *mem_ctx, > struct rpc_pipe_client *winreg_pipe, > const char *key_name, > unsigned char *data, >- size_t length) >+ size_t length, >+ bool do_string_conversion) > { > struct dcerpc_binding_handle *b = winreg_pipe->binding_handle; > enum ndr_err_code ndr_err; >@@ -121,6 +122,10 @@ NTSTATUS printing_tdb_migrate_driver(TALLOC_CTX *mem_ctx, > > ZERO_STRUCT(r); > >+ if (do_string_conversion) { >+ r.string_flags = LIBNDR_FLAG_STR_ASCII; >+ } >+ > ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, > (ndr_pull_flags_fn_t)ndr_pull_ntprinting_driver); > if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { >@@ -177,7 +182,8 @@ NTSTATUS printing_tdb_migrate_printer(TALLOC_CTX *mem_ctx, > struct rpc_pipe_client *winreg_pipe, > const char *key_name, > unsigned char *data, >- size_t length) >+ size_t length, >+ bool do_string_conversion) > { > struct dcerpc_binding_handle *b = winreg_pipe->binding_handle; > enum ndr_err_code ndr_err; >@@ -200,6 +206,10 @@ NTSTATUS printing_tdb_migrate_printer(TALLOC_CTX *mem_ctx, > > ZERO_STRUCT(r); > >+ if (do_string_conversion) { >+ r.info.string_flags = LIBNDR_FLAG_STR_ASCII; >+ } >+ > ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, > (ndr_pull_flags_fn_t) ndr_pull_ntprinting_printer); > if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { >diff --git a/source3/printing/nt_printing_migrate.h b/source3/printing/nt_printing_migrate.h >index 3da8db4..0c9800d 100644 >--- a/source3/printing/nt_printing_migrate.h >+++ b/source3/printing/nt_printing_migrate.h >@@ -30,12 +30,14 @@ NTSTATUS printing_tdb_migrate_driver(TALLOC_CTX *mem_ctx, > struct rpc_pipe_client *winreg_pipe, > const char *key_name, > unsigned char *data, >- size_t length); >+ size_t length, >+ bool do_string_conversion); > NTSTATUS printing_tdb_migrate_printer(TALLOC_CTX *mem_ctx, > struct rpc_pipe_client *winreg_pipe, > const char *key_name, > unsigned char *data, >- size_t length); >+ size_t length, >+ bool do_string_conversion); > NTSTATUS printing_tdb_migrate_secdesc(TALLOC_CTX *mem_ctx, > struct rpc_pipe_client *winreg_pipe, > const char *key_name, >diff --git a/source3/printing/nt_printing_migrate_internal.c b/source3/printing/nt_printing_migrate_internal.c >index 5d8edc7..4b3758f 100644 >--- a/source3/printing/nt_printing_migrate_internal.c >+++ b/source3/printing/nt_printing_migrate_internal.c >@@ -114,7 +114,8 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx, > winreg_pipe, > (const char *) kbuf.dptr + strlen(DRIVERS_PREFIX), > dbuf.dptr, >- dbuf.dsize); >+ dbuf.dsize, >+ false); > SAFE_FREE(dbuf.dptr); > if (!NT_STATUS_IS_OK(status)) { > tdb_close(tdb); >@@ -130,7 +131,8 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx, > winreg_pipe, > printer_name, > dbuf.dptr, >- dbuf.dsize); >+ dbuf.dsize, >+ false); > SAFE_FREE(dbuf.dptr); > if (!NT_STATUS_IS_OK(status)) { > tdb_close(tdb); >diff --git a/source3/utils/net_printing.c b/source3/utils/net_printing.c >index a52d31f..f0c11a2 100644 >--- a/source3/utils/net_printing.c >+++ b/source3/utils/net_printing.c >@@ -37,6 +37,48 @@ > #define PRINTERS_PREFIX "PRINTERS/" > #define SECDESC_PREFIX "SECDESC/" > >+#define ARG_ENCODING "encoding=" >+ >+struct printing_opts { >+ const char *encoding; >+ const char *tdb; >+}; >+ >+static NTSTATUS printing_parse_args(TALLOC_CTX *mem_ctx, >+ struct printing_opts **popts, >+ int argc, const char **argv) >+{ >+ size_t c; >+ struct printing_opts *o; >+ >+ if (argc == 0) { >+ return NT_STATUS_INVALID_PARAMETER; >+ } >+ >+ o = talloc_zero(mem_ctx, struct printing_opts); >+ if (o == NULL) { >+ return NT_STATUS_INVALID_PARAMETER; >+ } >+ >+ for (c = 0; c < argc; c++) { >+ if (strnequal(argv[c], ARG_ENCODING, sizeof(ARG_ENCODING) - 1)) { >+ o->encoding = talloc_strdup(o, >+ argv[c] + sizeof(ARG_ENCODING) - 1); >+ if (o->encoding == NULL) { >+ return NT_STATUS_NO_MEMORY; >+ } >+ } else { >+ o->tdb = talloc_strdup(o, argv[c]); >+ if (o->tdb == NULL) { >+ return NT_STATUS_NO_MEMORY; >+ } >+ } >+ } >+ >+ *popts = o; >+ return NT_STATUS_OK; >+} >+ > static void dump_form(TALLOC_CTX *mem_ctx, > const char *key_name, > unsigned char *data, >@@ -229,23 +271,39 @@ static NTSTATUS printing_migrate_internal(struct net_context *c, > int argc, > const char **argv) > { >+ struct printing_opts *o; > TALLOC_CTX *tmp_ctx; > TDB_CONTEXT *tdb; > TDB_DATA kbuf, newkey, dbuf; > NTSTATUS status; >+ const char *save_dos_charset = lp_dos_charset(); >+ bool do_string_conversion = false; > > tmp_ctx = talloc_new(mem_ctx); > if (tmp_ctx == NULL) { > return NT_STATUS_NO_MEMORY; > } > >- tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0600); >+ status = printing_parse_args(tmp_ctx, &o, argc, argv); >+ if (!NT_STATUS_IS_OK(status)) { >+ d_fprintf(stderr, _("failed to parse arguments\n")); >+ goto done; >+ } >+ >+ tdb = tdb_open_log(o->tdb, 0, TDB_DEFAULT, O_RDONLY, 0600); > if (tdb == NULL) { >- d_fprintf(stderr, _("failed to open tdb file: %s\n"), argv[0]); >+ d_fprintf(stderr, _("failed to open tdb file: %s\n"), o->tdb); > status = NT_STATUS_NO_SUCH_FILE; > goto done; > } > >+ if (o->encoding != NULL) { >+ lp_set_cmdline("dos charset", o->encoding); >+ d_fprintf(stderr, _("do string conversion from %s to %s\n"), >+ lp_dos_charset(), lp_unix_charset()); >+ do_string_conversion = true; >+ } >+ > for (kbuf = tdb_firstkey(tdb); > kbuf.dptr; > newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf = newkey) >@@ -270,7 +328,8 @@ static NTSTATUS printing_migrate_internal(struct net_context *c, > winreg_pipe, > (const char *) kbuf.dptr + strlen(DRIVERS_PREFIX), > dbuf.dptr, >- dbuf.dsize); >+ dbuf.dsize, >+ do_string_conversion); > SAFE_FREE(dbuf.dptr); > continue; > } >@@ -280,7 +339,8 @@ static NTSTATUS printing_migrate_internal(struct net_context *c, > winreg_pipe, > (const char *) kbuf.dptr + strlen(PRINTERS_PREFIX), > dbuf.dptr, >- dbuf.dsize); >+ dbuf.dsize, >+ do_string_conversion); > SAFE_FREE(dbuf.dptr); > continue; > } >@@ -312,6 +372,7 @@ static NTSTATUS printing_migrate_internal(struct net_context *c, > status = NT_STATUS_OK; > > done: >+ lp_set_cmdline("dos charset", save_dos_charset); > talloc_free(tmp_ctx); > return status; > } >@@ -322,10 +383,14 @@ static int net_printing_migrate(struct net_context *c, > { > if (argc < 1 || c->display_usage) { > d_printf( "%s\n" >- "net printing migrate <file.tdb>\n" >+ "net printing migrate [options] <file.tdb>\n" > " %s\n", > _("Usage:"), > _("Migrate tdb printing files to new storage")); >+ d_printf(_("Valid options:\n")); >+ d_printf(_(" encoding=<CP> Set the Code Page of the tdb file.\n" >+ " See iconv -l for the list of CP values\n" >+ " (CP1252 is Western latin1, CP1251 is Cyrillic).\n")); > return 0; > } > >-- >1.8.1.5 > > >From 23462710c4bf25330f88c3bf1b2e6b0f75f2e689 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 12 Mar 2013 18:42:02 +0100 >Subject: [PATCH 6/7] s3-net: Add encoding=<CP> to 'net printing dump'. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > source3/utils/net_printing.c | 59 ++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 51 insertions(+), 8 deletions(-) > >diff --git a/source3/utils/net_printing.c b/source3/utils/net_printing.c >index f0c11a2..ccb073c 100644 >--- a/source3/utils/net_printing.c >+++ b/source3/utils/net_printing.c >@@ -112,7 +112,8 @@ static void dump_form(TALLOC_CTX *mem_ctx, > static void dump_driver(TALLOC_CTX *mem_ctx, > const char *key_name, > unsigned char *data, >- size_t length) >+ size_t length, >+ bool do_string_conversion) > { > enum ndr_err_code ndr_err; > DATA_BLOB blob; >@@ -125,6 +126,10 @@ static void dump_driver(TALLOC_CTX *mem_ctx, > > ZERO_STRUCT(r); > >+ if (do_string_conversion) { >+ r.string_flags = LIBNDR_FLAG_STR_ASCII; >+ } >+ > ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, > (ndr_pull_flags_fn_t)ndr_pull_ntprinting_driver); > if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { >@@ -142,7 +147,8 @@ static void dump_driver(TALLOC_CTX *mem_ctx, > static void dump_printer(TALLOC_CTX *mem_ctx, > const char *key_name, > unsigned char *data, >- size_t length) >+ size_t length, >+ bool do_string_conversion) > { > enum ndr_err_code ndr_err; > DATA_BLOB blob; >@@ -155,6 +161,10 @@ static void dump_printer(TALLOC_CTX *mem_ctx, > > ZERO_STRUCT(r); > >+ if (do_string_conversion) { >+ r.info.string_flags = LIBNDR_FLAG_STR_ASCII; >+ } >+ > ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, > (ndr_pull_flags_fn_t)ndr_pull_ntprinting_printer); > if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { >@@ -207,19 +217,43 @@ static int net_printing_dump(struct net_context *c, int argc, > TALLOC_CTX *ctx = talloc_stackframe(); > TDB_CONTEXT *tdb; > TDB_DATA kbuf, newkey, dbuf; >+ struct printing_opts *o; >+ const char *save_dos_charset = lp_dos_charset(); >+ bool do_string_conversion = false; >+ NTSTATUS status; > > if (argc < 1 || c->display_usage) { >- d_fprintf(stderr, "%s\nnet printing dump <file.tdb>\n", >- _("Usage:")); >+ d_printf( "%s\n" >+ "net printing dump [options] <file.tdb>\n" >+ " %s\n", >+ _("Usage:"), >+ _("Dump formated printer information of the tdb.")); >+ d_printf(_("Valid options:\n")); >+ d_printf(_(" encoding=<CP> Set the Code Page of the tdb file.\n" >+ " See iconv -l for the list of CP values\n" >+ " (CP1252 is Western latin1, CP1251 is Cyrillic).\n")); > goto done; > } > >- tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0600); >+ status = printing_parse_args(ctx, &o, argc, argv); >+ if (!NT_STATUS_IS_OK(status)) { >+ d_fprintf(stderr, _("failed to parse arguments\n")); >+ goto done; >+ } >+ >+ tdb = tdb_open_log(o->tdb, 0, TDB_DEFAULT, O_RDONLY, 0600); > if (!tdb) { >- d_fprintf(stderr, _("failed to open tdb file: %s\n"), argv[0]); >+ d_fprintf(stderr, _("failed to open tdb file: %s\n"), o->tdb); > goto done; > } > >+ if (o->encoding != NULL) { >+ lp_set_cmdline("dos charset", o->encoding); >+ d_fprintf(stderr, _("do string conversion from %s to %s\n"), >+ lp_dos_charset(), lp_unix_charset()); >+ do_string_conversion = true; >+ } >+ > for (kbuf = tdb_firstkey(tdb); > kbuf.dptr; > newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf=newkey) >@@ -236,13 +270,21 @@ static int net_printing_dump(struct net_context *c, int argc, > } > > if (strncmp((const char *)kbuf.dptr, DRIVERS_PREFIX, strlen(DRIVERS_PREFIX)) == 0) { >- dump_driver(ctx, (const char *)kbuf.dptr+strlen(DRIVERS_PREFIX), dbuf.dptr, dbuf.dsize); >+ dump_driver(ctx, >+ (const char *)kbuf.dptr+strlen(DRIVERS_PREFIX), >+ dbuf.dptr, >+ dbuf.dsize, >+ do_string_conversion); > SAFE_FREE(dbuf.dptr); > continue; > } > > if (strncmp((const char *)kbuf.dptr, PRINTERS_PREFIX, strlen(PRINTERS_PREFIX)) == 0) { >- dump_printer(ctx, (const char *)kbuf.dptr+strlen(PRINTERS_PREFIX), dbuf.dptr, dbuf.dsize); >+ dump_printer(ctx, >+ (const char *)kbuf.dptr+strlen(PRINTERS_PREFIX), >+ dbuf.dptr, >+ dbuf.dsize, >+ do_string_conversion); > SAFE_FREE(dbuf.dptr); > continue; > } >@@ -258,6 +300,7 @@ static int net_printing_dump(struct net_context *c, int argc, > ret = 0; > > done: >+ lp_set_cmdline("dos charset", save_dos_charset); > talloc_free(ctx); > return ret; > } >-- >1.8.1.5 > > >From f8923316d9e2e270a95cef5e4eeb0b35d5c27516 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Thu, 14 Mar 2013 07:29:20 +0100 >Subject: [PATCH 7/7] torture: Add ntprinting latin1 test. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Reviewed-by: Günther Deschner <gd@samba.org> >--- > source4/torture/ndr/ntprinting.c | 217 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 217 insertions(+) > >diff --git a/source4/torture/ndr/ntprinting.c b/source4/torture/ndr/ntprinting.c >index 44ad86b..3ff9cb1 100644 >--- a/source4/torture/ndr/ntprinting.c >+++ b/source4/torture/ndr/ntprinting.c >@@ -22,6 +22,7 @@ > #include "torture/ndr/ndr.h" > #include "librpc/gen_ndr/ndr_ntprinting.h" > #include "torture/ndr/proto.h" >+#include "param/param.h" > > static const uint8_t ntprinting_printer_data[] = { > 0x48, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, >@@ -296,6 +297,170 @@ static const uint8_t ntprinting_printer_data[] = { > 0x00, 0x00, 0x00, 0x00, 0x00 > }; > >+static const uint8_t ntprinting_printer_data_latin1[] = { >+ 0x48, 0x1a, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, >+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x94, 0x46, 0x50, 0x0e, 0x00, 0x00, 0x00, 0x00, >+ 0x94, 0xee, 0xb9, 0x50, 0x00, 0x53, 0x30, 0x42, >+ 0x43, 0x00, 0x53, 0x30, 0x42, 0x43, 0x00, 0x53, >+ 0x61, 0x6d, 0x62, 0x61, 0x20, 0x50, 0x72, 0x69, >+ 0x6e, 0x74, 0x65, 0x72, 0x20, 0x50, 0x6f, 0x72, >+ 0x74, 0x00, 0x48, 0x50, 0x20, 0x44, 0x65, 0x73, >+ 0x69, 0x67, 0x6e, 0x6a, 0x65, 0x74, 0x20, 0x38, >+ 0x30, 0x30, 0x50, 0x53, 0x20, 0x34, 0x32, 0x20, >+ 0x62, 0x79, 0x20, 0x48, 0x50, 0x00, 0x22, 0x20, >+ 0x53, 0x41, 0x4c, 0x41, 0x20, 0x44, 0x41, 0x20, >+ 0x52, 0x45, 0x43, 0x45, 0x50, 0xc7, 0xc3, 0x4f, >+ 0x20, 0x44, 0x41, 0x20, 0x43, 0x4f, 0x4e, 0x53, >+ 0x54, 0x52, 0x55, 0xc7, 0xc3, 0x4f, 0x20, 0x2d, >+ 0x20, 0x52, 0x41, 0x4e, 0x44, 0x30, 0x20, 0x4c, >+ 0x4f, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x00, 0x55, >+ 0x54, 0x47, 0x43, 0x41, 0x20, 0x00, 0x00, 0x77, >+ 0x69, 0x6e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x00, >+ 0x52, 0x41, 0x57, 0x00, 0x00, 0x01, 0x00, 0x00, >+ 0x00, 0x5c, 0x5c, 0x4c, 0x4f, 0x43, 0x41, 0x4c, >+ 0x48, 0x4f, 0x53, 0x54, 0x5c, 0x53, 0x30, 0x42, >+ 0x43, 0x00, 0x4c, 0x65, 0x74, 0x74, 0x65, 0x72, >+ 0x00, 0x01, 0x04, 0x00, 0x04, 0xdc, 0x00, 0x00, >+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x64, 0x00, 0x01, 0x00, 0x0f, 0x00, 0xfc, >+ 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x47, 0x01, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x72, 0x69, >+ 0x6e, 0x74, 0x65, 0x72, 0x44, 0x72, 0x69, 0x76, >+ 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, >+ 0x00, 0x00, 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, >+ 0x65, 0x72, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, >+ 0x44, 0x61, 0x74, 0x61, 0x5c, 0x44, 0x72, 0x76, >+ 0x50, 0x61, 0x70, 0x65, 0x72, 0x53, 0x74, 0x61, >+ 0x6e, 0x64, 0x61, 0x72, 0x64, 0x73, 0x00, 0x04, >+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x61, >+ 0xc2, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x50, >+ 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x44, 0x72, >+ 0x69, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, >+ 0x5c, 0x44, 0x72, 0x76, 0x44, 0x65, 0x76, 0x4d, >+ 0x6f, 0x64, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, >+ 0x42, 0x02, 0x00, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x36, 0x00, >+ 0x36, 0x00, 0x3b, 0x00, 0x2d, 0x00, 0x33, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x31, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x30, 0x00, 0x37, 0x00, 0x33, 0x00, >+ 0x37, 0x00, 0x34, 0x00, 0x31, 0x00, 0x39, 0x00, >+ 0x30, 0x00, 0x35, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x35, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x35, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x36, 0x00, >+ 0x32, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x36, 0x00, >+ 0x37, 0x00, 0x37, 0x00, 0x37, 0x00, 0x32, 0x00, >+ 0x31, 0x00, 0x36, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x36, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x36, 0x00, 0x35, 0x00, >+ 0x35, 0x00, 0x33, 0x00, 0x35, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x36, 0x00, 0x33, 0x00, 0x31, 0x00, >+ 0x37, 0x00, 0x32, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, >+ 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x37, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, >+ 0x30, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x3b, 0x00, >+ 0x31, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00, >+ 0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00, >+ 0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00, >+ 0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00, >+ 0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00, >+ 0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00, >+ 0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00, >+ 0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00, >+ 0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00, >+ 0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00, >+ 0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00, >+ 0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00, >+ 0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00, >+ 0x34, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, >+ 0x3b, 0x00, 0x3b, 0x00, 0x3b, 0x00, 0x3b, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, >+ 0x3b, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x01, 0x00, >+ 0x00, 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x65, >+ 0x72, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x44, >+ 0x61, 0x74, 0x61, 0x5c, 0x44, 0x72, 0x76, 0x45, >+ 0x57, 0x53, 0x49, 0x50, 0x00, 0x01, 0x00, 0x00, >+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, >+ 0x00, 0x00, 0x00, 0x44, 0x73, 0x53, 0x70, 0x6f, >+ 0x6f, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, >+ 0x00, 0x44, 0x73, 0x53, 0x70, 0x6f, 0x6f, 0x6c, >+ 0x65, 0x72, 0x5c, 0x70, 0x72, 0x69, 0x6e, 0x74, >+ 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x00, 0x01, >+ 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x53, >+ 0x00, 0x30, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00, >+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x73, 0x53, >+ 0x70, 0x6f, 0x6f, 0x6c, 0x65, 0x72, 0x5c, 0x73, >+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, >+ 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, >+ 0x00, 0x00, 0x53, 0x00, 0x36, 0x00, 0x30, 0x00, >+ 0x32, 0x00, 0x30, 0x00, 0x50, 0x00, 0x53, 0x00, >+ 0x36, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, >+ 0x00, 0x00, 0x44, 0x73, 0x53, 0x70, 0x6f, 0x6f, >+ 0x6c, 0x65, 0x72, 0x5c, 0x73, 0x68, 0x6f, 0x72, >+ 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, >+ 0x61, 0x6d, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, >+ 0x14, 0x00, 0x00, 0x00, 0x53, 0x00, 0x36, 0x00, >+ 0x30, 0x00, 0x32, 0x00, 0x30, 0x00, 0x50, 0x00, >+ 0x53, 0x00, 0x36, 0x00, 0x36, 0x00, 0x00, 0x00, >+ 0x01, 0x00, 0x00, 0x00, 0x44, 0x73, 0x53, 0x70, >+ 0x6f, 0x6f, 0x6c, 0x65, 0x72, 0x5c, 0x75, 0x4e, >+ 0x43, 0x4e, 0x61, 0x6d, 0x65, 0x00, 0x01, 0x00, >+ 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x5c, 0x00, >+ 0x5c, 0x00, 0x53, 0x00, 0x36, 0x00, 0x30, 0x00, >+ 0x32, 0x00, 0x30, 0x00, 0x50, 0x00, 0x53, 0x00, >+ 0x36, 0x00, 0x36, 0x00, 0x5c, 0x00, 0x53, 0x00, >+ 0x30, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00 >+}; >+ > static bool ntprinting_printer_check(struct torture_context *tctx, > struct ntprinting_printer *r) > { >@@ -421,10 +586,62 @@ static bool ntprinting_printer_check(struct torture_context *tctx, > return true; > } > >+static bool ntprinting_printer_latin1_check(struct torture_context *tctx) >+{ >+ enum ndr_err_code ndr_err; >+ struct ntprinting_printer r; >+ DATA_BLOB blob; >+ bool ok; >+ >+ ok = lpcfg_do_global_parameter(tctx->lp_ctx, "dos charset", "CP1252"); >+ if (!ok) { >+ torture_comment(tctx, "Could not set 'dos charset' option.\n"); >+ return false; >+ } >+ reload_charcnv(tctx->lp_ctx); >+ >+ ZERO_STRUCT(r); >+ r.info.string_flags = LIBNDR_FLAG_STR_ASCII; >+ >+ blob = data_blob_const(ntprinting_printer_data_latin1, >+ sizeof(ntprinting_printer_data_latin1)); >+ >+ ndr_err = ndr_pull_struct_blob(&blob, tctx, &r, >+ (ndr_pull_flags_fn_t)ndr_pull_ntprinting_printer); >+ >+ torture_assert_ndr_success(tctx, >+ ndr_err, >+ "ndr_pull_ntprinting_printer"); >+#if 0 >+ ndr_print_debug((ndr_print_fn_t) ndr_print_ntprinting_printer, >+ "ntprinter", >+ &r); >+#endif >+ torture_assert_str_equal(tctx, >+ r.info.printername, >+ "S0BC", >+ "printername"); >+ /* latin1 encoding check */ >+ torture_assert_str_equal(tctx, >+ r.info.comment, >+ "\" SALA DA RECEPÃÃO DA CONSTRUÃÃO - RAND0 LOCATIO", >+ "comment"); >+ torture_assert_str_equal(tctx, >+ r.info.location, >+ "UTGCA ", >+ "location"); >+ >+ return true; >+} >+ > struct torture_suite *ndr_ntprinting_suite(TALLOC_CTX *ctx) > { > struct torture_suite *suite = torture_suite_create(ctx, "ntprinting"); > >+ torture_suite_add_simple_test(suite, >+ "ntprinting latin1 check", >+ ntprinting_printer_latin1_check); >+ > torture_suite_add_ndr_pull_test(suite, > ntprinting_printer, > ntprinting_printer_data, >-- >1.8.1.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
gd
:
review+
asn
:
review?
(
ddiss
)
Actions:
View
Attachments on
bug 9723
:
8649
| 8650