From 787065289880a727ab7c8a6bbc1293c5b945dab8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 18:00:15 +0000 Subject: r21564: Move ndrdump to librpc/tools. (This used to be commit e3cc94e7d175824abce16c377e5180b4756543cf) --- source4/librpc/tools/ndrdump.c | 414 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 414 insertions(+) create mode 100644 source4/librpc/tools/ndrdump.c (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c new file mode 100644 index 0000000000..205d094fe7 --- /dev/null +++ b/source4/librpc/tools/ndrdump.c @@ -0,0 +1,414 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Jelmer Vernooij 2006 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/cmdline/popt_common.h" +#include "system/filesys.h" +#include "system/locale.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/rpc/dcerpc_table.h" + +static const struct dcerpc_interface_call *find_function( + const struct dcerpc_interface_table *p, + const char *function) +{ + int i; + if (isdigit(function[0])) { + i = strtol(function, NULL, 0); + return &p->calls[i]; + } + for (i=0;inum_calls;i++) { + if (strcmp(p->calls[i].name, function) == 0) { + break; + } + } + if (i == p->num_calls) { + printf("Function '%s' not found\n", function); + exit(1); + } + return &p->calls[i]; +} + + +static void show_pipes(void) +{ + const struct dcerpc_interface_list *l; + printf("\nYou must specify a pipe\n"); + printf("known pipes are:\n"); + for (l=librpc_dcerpc_pipes();l;l=l->next) { + if(l->table->helpstring) { + printf("\t%s - %s\n", l->table->name, l->table->helpstring); + } else { + printf("\t%s\n", l->table->name); + } + } + exit(1); +} + +static void show_functions(const struct dcerpc_interface_table *p) +{ + int i; + printf("\nYou must specify a function\n"); + printf("known functions on '%s' are:\n", p->name); + for (i=0;inum_calls;i++) { + printf("\t0x%02x (%2d) %s\n", i, i, p->calls[i].name); + } + exit(1); +} + +static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size) +{ + int num_read, total_len = 0; + char buf[255]; + char *result = NULL; + + while((num_read = read(STDIN_FILENO, buf, 255)) > 0) { + + if (result) { + result = (char *) talloc_realloc( + mem_ctx, result, char *, total_len + num_read); + } else { + result = talloc_size(mem_ctx, num_read); + } + + memcpy(result + total_len, buf, num_read); + + total_len += num_read; + } + + if (size) + *size = total_len; + + return result; +} + +const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name) +{ + const struct dcerpc_interface_table *p; + void *handle; + char *symbol; + + handle = dlopen(plugin, RTLD_NOW); + if (handle == NULL) { + printf("%s: Unable to open: %s\n", plugin, dlerror()); + return NULL; + } + + symbol = talloc_asprintf(NULL, "dcerpc_table_%s", pipe_name); + p = dlsym(handle, symbol); + + if (!p) { + printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror()); + talloc_free(symbol); + return NULL; + } + + talloc_free(symbol); + + return p; +} + + int main(int argc, const char *argv[]) +{ + const struct dcerpc_interface_table *p = NULL; + const struct dcerpc_interface_call *f; + const char *pipe_name, *function, *inout, *filename; + uint8_t *data; + size_t size; + DATA_BLOB blob; + struct ndr_pull *ndr_pull; + struct ndr_print *ndr_print; + TALLOC_CTX *mem_ctx; + int flags; + poptContext pc; + NTSTATUS status; + void *st; + void *v_st; + const char *ctx_filename = NULL; + const char *plugin = NULL; + bool validate = false; + bool dumpdata = false; + int opt; + enum {OPT_CONTEXT_FILE=1000, OPT_VALIDATE, OPT_DUMP_DATA, OPT_LOAD_DSO}; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"context-file", 'c', POPT_ARG_STRING, NULL, OPT_CONTEXT_FILE, "In-filename to parse first", "CTX-FILE" }, + {"validate", 0, POPT_ARG_NONE, NULL, OPT_VALIDATE, "try to validate the data", NULL }, + {"dump-data", 0, POPT_ARG_NONE, NULL, OPT_DUMP_DATA, "dump the hex data", NULL }, + {"load-dso", 'l', POPT_ARG_STRING, NULL, OPT_LOAD_DSO, "load from shared object file", NULL }, + POPT_COMMON_SAMBA + POPT_COMMON_VERSION + { NULL } + }; + + dcerpc_table_init(); + + pc = poptGetContext("ndrdump", argc, argv, long_options, 0); + + poptSetOtherOptionHelp( + pc, " []"); + + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case OPT_CONTEXT_FILE: + ctx_filename = poptGetOptArg(pc); + break; + case OPT_VALIDATE: + validate = true; + break; + case OPT_DUMP_DATA: + dumpdata = true; + break; + case OPT_LOAD_DSO: + plugin = poptGetOptArg(pc); + break; + } + } + + pipe_name = poptGetArg(pc); + + if (!pipe_name) { + poptPrintUsage(pc, stderr, 0); + show_pipes(); + exit(1); + } + + if (plugin != NULL) { + p = load_iface_from_plugin(plugin, pipe_name); + } + + if (!p) { + p = idl_iface_by_name(pipe_name); + } + + if (!p) { + struct GUID uuid; + + status = GUID_from_string(pipe_name, &uuid); + + if (NT_STATUS_IS_OK(status)) { + p = idl_iface_by_uuid(&uuid); + } + } + + if (!p) { + printf("Unknown pipe or UUID '%s'\n", pipe_name); + exit(1); + } + + function = poptGetArg(pc); + inout = poptGetArg(pc); + filename = poptGetArg(pc); + + if (!function || !inout) { + poptPrintUsage(pc, stderr, 0); + show_functions(p); + exit(1); + } + + if (strcmp(inout, "in") == 0 || + strcmp(inout, "request") == 0) { + flags = NDR_IN; + } else if (strcmp(inout, "out") == 0 || + strcmp(inout, "response") == 0) { + flags = NDR_OUT; + } else { + printf("Bad inout value '%s'\n", inout); + exit(1); + } + + f = find_function(p, function); + + mem_ctx = talloc_init("ndrdump"); + + st = talloc_zero_size(mem_ctx, f->struct_size); + if (!st) { + printf("Unable to allocate %d bytes\n", (int)f->struct_size); + exit(1); + } + + v_st = talloc_zero_size(mem_ctx, f->struct_size); + if (!v_st) { + printf("Unable to allocate %d bytes\n", (int)f->struct_size); + exit(1); + } + + if (ctx_filename) { + if (flags == NDR_IN) { + printf("Context file can only be used for \"out\" packages\n"); + exit(1); + } + + data = (uint8_t *)file_load(ctx_filename, &size, mem_ctx); + if (!data) { + perror(ctx_filename); + exit(1); + } + + blob.data = data; + blob.length = size; + + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; + + status = f->ndr_pull(ndr_pull, NDR_IN, st); + + if (ndr_pull->offset != ndr_pull->data_size) { + printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - ndr_pull->offset); + } + + if (!NT_STATUS_IS_OK(status)) { + printf("pull for context file returned %s\n", nt_errstr(status)); + exit(1); + } + memcpy(v_st, st, f->struct_size); + } + + if (filename) + data = (uint8_t *)file_load(filename, &size, mem_ctx); + else + data = (uint8_t *)stdin_load(mem_ctx, &size); + + if (!data) { + if (filename) + perror(filename); + else + perror("stdin"); + exit(1); + } + + blob.data = data; + blob.length = size; + + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; + + status = f->ndr_pull(ndr_pull, flags, st); + + printf("pull returned %s\n", nt_errstr(status)); + + if (ndr_pull->offset != ndr_pull->data_size) { + printf("WARNING! %d unread bytes\n", ndr_pull->data_size - ndr_pull->offset); + dump_data(0, ndr_pull->data+ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); + } + + if (dumpdata) { + printf("%d bytes consumed\n", ndr_pull->offset); + dump_data(0, blob.data, blob.length); + } + + ndr_print = talloc_zero(mem_ctx, struct ndr_print); + ndr_print->print = ndr_print_debug_helper; + ndr_print->depth = 1; + f->ndr_print(ndr_print, function, flags, st); + + if (!NT_STATUS_IS_OK(status)) { + printf("dump FAILED\n"); + exit(1); + } + + if (validate) { + DATA_BLOB v_blob; + struct ndr_push *ndr_v_push; + struct ndr_pull *ndr_v_pull; + struct ndr_print *ndr_v_print; + uint32_t i; + uint8_t byte_a, byte_b; + bool differ; + + ndr_v_push = ndr_push_init_ctx(mem_ctx); + + status = f->ndr_push(ndr_v_push, flags, st); + if (!NT_STATUS_IS_OK(status)) { + printf("validate push FAILED\n"); + exit(1); + } + + v_blob = ndr_push_blob(ndr_v_push); + + if (dumpdata) { + printf("%ld bytes generated (validate)\n", (long)v_blob.length); + dump_data(0, v_blob.data, v_blob.length); + } + + ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); + ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; + + status = f->ndr_pull(ndr_v_pull, flags, v_st); + if (!NT_STATUS_IS_OK(status)) { + printf("validate pull FAILED\n"); + exit(1); + } + + printf("pull returned %s\n", nt_errstr(status)); + + if (ndr_v_pull->offset != ndr_v_pull->data_size) { + printf("WARNING! %d unread bytes in validation\n", ndr_v_pull->data_size - ndr_v_pull->offset); + dump_data(0, ndr_v_pull->data+ndr_v_pull->offset, ndr_v_pull->data_size - ndr_v_pull->offset); + } + + ndr_v_print = talloc_zero(mem_ctx, struct ndr_print); + ndr_v_print->print = ndr_print_debug_helper; + ndr_v_print->depth = 1; + f->ndr_print(ndr_v_print, function, flags, v_st); + + if (blob.length != v_blob.length) { + printf("WARNING! orig bytes:%u validated pushed bytes:%u\n", blob.length, v_blob.length); + } + + if (ndr_pull->offset != ndr_v_pull->offset) { + printf("WARNING! orig pulled bytes:%u validated pulled bytes:%u\n", ndr_pull->offset, ndr_v_pull->offset); + } + + differ = false; + byte_a = 0x00; + byte_b = 0x00; + for (i=0; i < blob.length; i++) { + byte_a = blob.data[i]; + + if (i == v_blob.length) { + byte_b = 0x00; + differ = true; + break; + } + + byte_b = v_blob.data[i]; + + if (byte_a != byte_b) { + differ = true; + break; + } + } + if (differ) { + printf("WARNING! orig and validated differ at byte 0x%02X (%u)\n", i, i); + printf("WARNING! orig byte[0x%02X] = 0x%02X validated byte[0x%02X] = 0x%02X\n", + i, byte_a, i, byte_b); + } + } + + printf("dump OK\n"); + + talloc_free(mem_ctx); + + poptFreeContext(pc); + + return 0; +} -- cgit From 678c401d3ed6f480e237e519aa9aeeaa12b0ab52 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 12:47:51 +0000 Subject: r21650: Update ndrdump to work in samba3 (This used to be commit 10295d9bdd035c008fa7dafef0426c1e86250ac9) --- source4/librpc/tools/ndrdump.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 205d094fe7..7fc3e57ff3 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -20,11 +20,13 @@ */ #include "includes.h" +#if (_SAMBA_BUILD_ >= 4) #include "lib/cmdline/popt_common.h" #include "system/filesys.h" #include "system/locale.h" #include "librpc/rpc/dcerpc.h" #include "librpc/rpc/dcerpc_table.h" +#endif static const struct dcerpc_interface_call *find_function( const struct dcerpc_interface_table *p, @@ -47,6 +49,7 @@ static const struct dcerpc_interface_call *find_function( return &p->calls[i]; } +#if (_SAMBA_BUILD_ >= 4) static void show_pipes(void) { @@ -63,6 +66,8 @@ static void show_pipes(void) exit(1); } +#endif + static void show_functions(const struct dcerpc_interface_table *p) { int i; @@ -159,7 +164,9 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, { NULL } }; +#if (_SAMBA_BUILD_ >= 4) dcerpc_table_init(); +#endif pc = poptGetContext("ndrdump", argc, argv, long_options, 0); @@ -187,14 +194,21 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, if (!pipe_name) { poptPrintUsage(pc, stderr, 0); +#if (_SAMBA_BUILD_ >= 4) show_pipes(); +#endif exit(1); } if (plugin != NULL) { p = load_iface_from_plugin(plugin, pipe_name); + } +#if (_SAMBA_BUILD_ <= 3) + else { + fprintf(stderr, "Only loading from DSO's supported in Samba 3\n"); + exit(1); } - +#else if (!p) { p = idl_iface_by_name(pipe_name); } @@ -208,6 +222,7 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, p = idl_iface_by_uuid(&uuid); } } +#endif if (!p) { printf("Unknown pipe or UUID '%s'\n", pipe_name); @@ -257,7 +272,11 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, exit(1); } +#if (_SAMBA_BUILD_ >= 4) data = (uint8_t *)file_load(ctx_filename, &size, mem_ctx); +#else + data = (uint8_t *)file_load(ctx_filename, &size, 0); +#endif if (!data) { perror(ctx_filename); exit(1); @@ -283,7 +302,11 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, } if (filename) +#if (_SAMBA_BUILD_ >= 4) data = (uint8_t *)file_load(filename, &size, mem_ctx); +#else + data = (uint8_t *)file_load(filename, &size, 0); +#endif else data = (uint8_t *)stdin_load(mem_ctx, &size); -- cgit From 04fed31e1a61366debd217510cb1a9d767fbaaec Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 13:44:56 +0000 Subject: r21653: Add two more tdr tests. (This used to be commit cc40e3acd95aecea481a65e936d311b815c6e9ae) --- source4/librpc/tools/ndrdump.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 7fc3e57ff3..23cfebcb9c 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -166,6 +166,15 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, #if (_SAMBA_BUILD_ >= 4) dcerpc_table_init(); +#else + /* Initialise samba stuff */ + load_case_tables(); + + setlinebuf(stdout); + + dbf = x_stderr; + + setup_logging(argv[0],True); #endif pc = poptGetContext("ndrdump", argc, argv, long_options, 0); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/librpc/tools/ndrdump.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 23cfebcb9c..6616ba0778 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,8 +15,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 698e7c5f2ae23656c50b95b5ca7151396d215ffb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 18 Aug 2007 10:30:40 +0000 Subject: r24535: rename struct dcerpc_interface_call -> struct ndr_interface_call and move it to librpc/ndr/libndr.h metze (This used to be commit abd5551aabae1820baaa52a963e8c7aa9605914e) --- source4/librpc/tools/ndrdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 6616ba0778..b7db31733c 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -27,7 +27,7 @@ #include "librpc/rpc/dcerpc_table.h" #endif -static const struct dcerpc_interface_call *find_function( +static const struct ndr_interface_call *find_function( const struct dcerpc_interface_table *p, const char *function) { @@ -133,7 +133,7 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, int main(int argc, const char *argv[]) { const struct dcerpc_interface_table *p = NULL; - const struct dcerpc_interface_call *f; + const struct ndr_interface_call *f; const char *pipe_name, *function, *inout, *filename; uint8_t *data; size_t size; -- cgit From b8cdadced4d2a26a63b8bbe397c12df949783ed4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 20:46:45 +0000 Subject: r24551: rename dcerpc_interface_table -> ndr_interface_table rename dcerpc_interface_list -> ndr_interface_list and move them to libndr.h metze (This used to be commit 4adbebef5df2f833d2d4bfcdda72a34179d52f5c) --- source4/librpc/tools/ndrdump.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index b7db31733c..966ca9b98d 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -28,7 +28,7 @@ #endif static const struct ndr_interface_call *find_function( - const struct dcerpc_interface_table *p, + const struct ndr_interface_table *p, const char *function) { int i; @@ -52,7 +52,7 @@ static const struct ndr_interface_call *find_function( static void show_pipes(void) { - const struct dcerpc_interface_list *l; + const struct ndr_interface_list *l; printf("\nYou must specify a pipe\n"); printf("known pipes are:\n"); for (l=librpc_dcerpc_pipes();l;l=l->next) { @@ -67,7 +67,7 @@ static void show_pipes(void) #endif -static void show_functions(const struct dcerpc_interface_table *p) +static void show_functions(const struct ndr_interface_table *p) { int i; printf("\nYou must specify a function\n"); @@ -104,9 +104,9 @@ static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size) return result; } -const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name) +const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name) { - const struct dcerpc_interface_table *p; + const struct ndr_interface_table *p; void *handle; char *symbol; @@ -132,7 +132,7 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, int main(int argc, const char *argv[]) { - const struct dcerpc_interface_table *p = NULL; + const struct ndr_interface_table *p = NULL; const struct ndr_interface_call *f; const char *pipe_name, *function, *inout, *filename; uint8_t *data; -- cgit From f14bd1a90ab47a418c0ec2492990a417a0bb3bf6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 21:23:03 +0000 Subject: r24557: rename 'dcerpc_table_' -> 'ndr_table_' metze (This used to be commit 84651aee81aaabbebf52ffc3fbcbabb2eec6eed5) --- source4/librpc/tools/ndrdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 966ca9b98d..2e57e882d6 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -116,7 +116,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con return NULL; } - symbol = talloc_asprintf(NULL, "dcerpc_table_%s", pipe_name); + symbol = talloc_asprintf(NULL, "ndr_table_%s", pipe_name); p = dlsym(handle, symbol); if (!p) { @@ -164,7 +164,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con }; #if (_SAMBA_BUILD_ >= 4) - dcerpc_table_init(); + ndr_table_init(); #else /* Initialise samba stuff */ load_case_tables(); -- cgit From bd93ed4680b3a86348b0d84a93d20f3daafbe8ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Aug 2007 19:35:43 +0000 Subject: r24606: move librpc/rpc/table.c -> librpc/ndr/ndr_table.c and rename the containing functions to have a ndr_ prefix metze (This used to be commit cb234d43ae693af5d8a921a15c9bcac3c6f0359a) --- source4/librpc/tools/ndrdump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 2e57e882d6..4b840fed5a 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -23,8 +23,8 @@ #include "lib/cmdline/popt_common.h" #include "system/filesys.h" #include "system/locale.h" -#include "librpc/rpc/dcerpc.h" -#include "librpc/rpc/dcerpc_table.h" +#include "librpc/ndr/libndr.h" +#include "librpc/ndr/ndr_table.h" #endif static const struct ndr_interface_call *find_function( @@ -55,7 +55,7 @@ static void show_pipes(void) const struct ndr_interface_list *l; printf("\nYou must specify a pipe\n"); printf("known pipes are:\n"); - for (l=librpc_dcerpc_pipes();l;l=l->next) { + for (l=ndr_table_list();l;l=l->next) { if(l->table->helpstring) { printf("\t%s - %s\n", l->table->name, l->table->helpstring); } else { @@ -218,7 +218,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con } #else if (!p) { - p = idl_iface_by_name(pipe_name); + p = ndr_table_by_name(pipe_name); } if (!p) { @@ -227,7 +227,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con status = GUID_from_string(pipe_name, &uuid); if (NT_STATUS_IS_OK(status)) { - p = idl_iface_by_uuid(&uuid); + p = ndr_table_by_uuid(&uuid); } } #endif -- cgit From dfa4e5f78440e375a9c47eab913c5980c1aa640b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Aug 2007 02:10:17 +0000 Subject: r24631: Fix up format warnings, found on my Fedora 7 x86_64 workstation. Andrew Bartlett (This used to be commit 3d74d178bfd89127ff387939e848b240e638cc35) --- source4/librpc/tools/ndrdump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 4b840fed5a..8a5e55f91e 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -402,11 +402,13 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con f->ndr_print(ndr_v_print, function, flags, v_st); if (blob.length != v_blob.length) { - printf("WARNING! orig bytes:%u validated pushed bytes:%u\n", blob.length, v_blob.length); + printf("WARNING! orig bytes:%llu validated pushed bytes:%llu\n", + (unsigned long long)blob.length, (unsigned long long)v_blob.length); } if (ndr_pull->offset != ndr_v_pull->offset) { - printf("WARNING! orig pulled bytes:%u validated pulled bytes:%u\n", ndr_pull->offset, ndr_v_pull->offset); + printf("WARNING! orig pulled bytes:%llu validated pulled bytes:%llu\n", + (unsigned long long)ndr_pull->offset, (unsigned long long)ndr_v_pull->offset); } differ = false; -- cgit From 6cf69fee189857ae6f85cd3f81a6a58364839942 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 13:31:15 +0000 Subject: r24994: Fix some C++ warnings. (This used to be commit 925abf74fa1ed5ae726bae8781ec549302786b39) --- source4/librpc/tools/ndrdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 8a5e55f91e..bd9d860c84 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -50,7 +50,7 @@ static const struct ndr_interface_call *find_function( #if (_SAMBA_BUILD_ >= 4) -static void show_pipes(void) +_NORETURN_ static void show_pipes(void) { const struct ndr_interface_list *l; printf("\nYou must specify a pipe\n"); @@ -67,7 +67,7 @@ static void show_pipes(void) #endif -static void show_functions(const struct ndr_interface_table *p) +_NORETURN_ static void show_functions(const struct ndr_interface_table *p) { int i; printf("\nYou must specify a function\n"); -- cgit From 7a287e07043cf937e22f8051c1a324d8a30c53e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 13:34:42 +0000 Subject: r25028: Fix more warnings. (This used to be commit 3aa7ee4a0d8837471deeaa1c5a1f4a0d2a14aa6e) --- source4/librpc/tools/ndrdump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index bd9d860c84..5a3e63ed93 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -87,10 +87,10 @@ static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size) while((num_read = read(STDIN_FILENO, buf, 255)) > 0) { if (result) { - result = (char *) talloc_realloc( - mem_ctx, result, char *, total_len + num_read); + result = talloc_realloc( + mem_ctx, result, char, total_len + num_read); } else { - result = talloc_size(mem_ctx, num_read); + result = talloc_array(mem_ctx, char, num_read); } memcpy(result + total_len, buf, num_read); @@ -104,7 +104,7 @@ static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size) return result; } -const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name) +static const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name) { const struct ndr_interface_table *p; void *handle; @@ -117,7 +117,7 @@ const struct ndr_interface_table *load_iface_from_plugin(const char *plugin, con } symbol = talloc_asprintf(NULL, "ndr_table_%s", pipe_name); - p = dlsym(handle, symbol); + p = (const struct ndr_interface_table *)dlsym(handle, symbol); if (!p) { printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror()); -- cgit From f05a356cbbdd4b0f3b7775338f288b2756f5fc24 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 2 Nov 2007 11:36:06 +0100 Subject: r25800: Use dump_data_skip_zeros() in ndrdump. Still obey the --dump-data parameter which enforces the full dump display (thanks metze). Guenther (This used to be commit c44a1d839375196fb832c64d43b7e47ea67c66b2) --- source4/librpc/tools/ndrdump.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 5a3e63ed93..0faabdd225 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -130,6 +130,15 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug return p; } +static void ndrdump_data(uint8_t *d, uint32_t l, bool force) +{ + if (force) { + dump_data(0, d, l); + } else { + dump_data_skip_zeros(0, d, l); + } +} + int main(int argc, const char *argv[]) { const struct ndr_interface_table *p = NULL; @@ -338,12 +347,14 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug if (ndr_pull->offset != ndr_pull->data_size) { printf("WARNING! %d unread bytes\n", ndr_pull->data_size - ndr_pull->offset); - dump_data(0, ndr_pull->data+ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); + ndrdump_data(ndr_pull->data+ndr_pull->offset, + ndr_pull->data_size - ndr_pull->offset, + dumpdata); } if (dumpdata) { printf("%d bytes consumed\n", ndr_pull->offset); - dump_data(0, blob.data, blob.length); + ndrdump_data(blob.data, blob.length, dumpdata); } ndr_print = talloc_zero(mem_ctx, struct ndr_print); @@ -377,7 +388,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug if (dumpdata) { printf("%ld bytes generated (validate)\n", (long)v_blob.length); - dump_data(0, v_blob.data, v_blob.length); + ndrdump_data(v_blob.data, v_blob.length, dumpdata); } ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); @@ -393,7 +404,9 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug if (ndr_v_pull->offset != ndr_v_pull->data_size) { printf("WARNING! %d unread bytes in validation\n", ndr_v_pull->data_size - ndr_v_pull->offset); - dump_data(0, ndr_v_pull->data+ndr_v_pull->offset, ndr_v_pull->data_size - ndr_v_pull->offset); + ndrdump_data(ndr_v_pull->data+ndr_v_pull->offset, + ndr_v_pull->data_size - ndr_v_pull->offset, + dumpdata); } ndr_v_print = talloc_zero(mem_ctx, struct ndr_print); -- cgit From b2ddeeb79d2622b3fd216465716dfa6b8c3e0b86 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:24:25 +0100 Subject: r25919: ndr: change NTSTAUS into enum ndr_err_code (ndrdump) librpc/tools/ndrdump.c metze (This used to be commit c788fe3eecae49187a84561783ddbe8f0199ac70) --- source4/librpc/tools/ndrdump.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 0faabdd225..a86b349aa9 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -153,6 +153,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) int flags; poptContext pc; NTSTATUS status; + enum ndr_err_code ndr_err; void *st; void *v_st; const char *ctx_filename = NULL; @@ -305,13 +306,14 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; - status = f->ndr_pull(ndr_pull, NDR_IN, st); + ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); if (ndr_pull->offset != ndr_pull->data_size) { printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - ndr_pull->offset); } - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); printf("pull for context file returned %s\n", nt_errstr(status)); exit(1); } @@ -341,7 +343,8 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; - status = f->ndr_pull(ndr_pull, flags, st); + ndr_err = f->ndr_pull(ndr_pull, flags, st); + status = ndr_map_error2ntstatus(ndr_err); printf("pull returned %s\n", nt_errstr(status)); @@ -378,8 +381,10 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndr_v_push = ndr_push_init_ctx(mem_ctx); - status = f->ndr_push(ndr_v_push, flags, st); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = f->ndr_push(ndr_v_push, flags, st); + status = ndr_map_error2ntstatus(ndr_err); + printf("push returned %s\n", nt_errstr(status)); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { printf("validate push FAILED\n"); exit(1); } @@ -394,13 +399,14 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; - status = f->ndr_pull(ndr_v_pull, flags, v_st); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = f->ndr_pull(ndr_v_pull, flags, v_st); + status = ndr_map_error2ntstatus(ndr_err); + printf("pull returned %s\n", nt_errstr(status)); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { printf("validate pull FAILED\n"); exit(1); } - printf("pull returned %s\n", nt_errstr(status)); if (ndr_v_pull->offset != ndr_v_pull->data_size) { printf("WARNING! %d unread bytes in validation\n", ndr_v_pull->data_size - ndr_v_pull->offset); -- cgit From 61873ce94c172c801a4831de5550a8e0fe54c5f5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:23 +0100 Subject: r26431: Require ndr_push creators to specify a iconv_convenience context. (This used to be commit 7352206f4450fdf881b95bda064cedd9d2477e4c) --- source4/librpc/tools/ndrdump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index a86b349aa9..7ee702fefb 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -25,6 +25,7 @@ #include "system/locale.h" #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" +#include "param/param.h" #endif static const struct ndr_interface_call *find_function( @@ -379,7 +380,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) uint8_t byte_a, byte_b; bool differ; - ndr_v_push = ndr_push_init_ctx(mem_ctx); + ndr_v_push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_err = f->ndr_push(ndr_v_push, flags, st); status = ndr_map_error2ntstatus(ndr_err); -- cgit From d1e716cf4331bf09cfe15a6634bc5887aff81d20 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:27 +0100 Subject: r26432: Require ndr_pull users to specify iconv_convenience. (This used to be commit 28b1d36551b75241c1cf9fca5d74f45a6dc884ab) --- source4/librpc/tools/ndrdump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/librpc/tools/ndrdump.c') diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index 7ee702fefb..bc1436916f 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -304,7 +304,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); @@ -341,7 +341,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, flags, st); @@ -397,7 +397,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndrdump_data(v_blob.data, v_blob.length, dumpdata); } - ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); + ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_v_pull, flags, v_st); -- cgit