[SCM] Samba Shared Repository - branch master updated

Douglas Bagnall dbagnall at samba.org
Wed Nov 13 01:56:02 UTC 2019


The branch, master has been updated
       via  01bb7cff023 ndrdump: check bounds when passed functions/structs by integer
       via  3b9e983b648 ndrdump: Fix new "struct" feature
       via  78521577eb1 pidl: Generate compatability wrappers for ndr_print functions
       via  1bd1ae0593a pidl: Generate the trailing ndr_table even if the UUID is not set
       via  7299b9ba907 librpc: Allow registration of ndr tables with a zero UUID
       via  1b6ae21fff9 build: Prepare for pidl to generate ndr_table entries for more IDL
       via  dd8dfa16dea s3-build: Skip building the ndr_table at the tail of ndr_libnetapi.c
       via  dddef1b8224 pidl: Allow the compilation of the ndr_table to be skiped
       via  5e0442efbe7 build: Allow warning on compile of libnetapi PIDL
       via  e45e342624d librpc: Do not include the ndr_table for libnet_join.idl and libnetapi.idl in the global list
       via  88c8cd7a1e7 librpc: Do not place the ndr_table for windows_event_ids.idl in the global list
       via  88373c472c5 selftest: Add expected-output tests for the ndrdump struct mode
       via  dfbb3049585 ndrdump: add --stop-on-parse-failure
       via  a106ceb7bfe librpc: Match interface name and file name for bkupblobs.idl
       via  666dbc61f1a librpc: Match interface name and file name for winsrepl.idl
       via  8a627b5d65b librpc: Fix typo in "quota" name in IDL
      from  3fea05e01f8 smbd: Remove write cache

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 01bb7cff023719705d7442ae497c52a3f797edf4
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Nov 12 12:11:53 2019 +1300

    ndrdump: check bounds when passed functions/structs by integer
    
    The function or struct number should be >= 0 ans the underlying
    number it is compared to is uint32_t.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    
    Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
    Autobuild-Date(master): Wed Nov 13 01:55:33 UTC 2019 on sn-devel-184

commit 3b9e983b648bd3738d8a5e1d53f29cd21ba63387
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Nov 5 16:15:38 2019 +1300

    ndrdump: Fix new "struct" feature
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 78521577eb11d2d601768f3c521549793341a450
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 12:15:26 2019 +1300

    pidl: Generate compatability wrappers for ndr_print functions
    
    This creates wrappers that are compatible with the functions called by
    ndrdump which have an extra "int flags" parameter for NDR_IN and
    NDR_OUT.  This will make ndrdump of public structures work again.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 1bd1ae0593a233465cbd5c381199bd0fc2cb476f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 12:19:29 2019 +1300

    pidl: Generate the trailing ndr_table even if the UUID is not set
    
    This allows ndrdump to dump many more public structures because most
    of these are not in files with a UUID as they are not RPC protocols.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 7299b9ba907d3c55897453ad2102500b94a21b82
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 7 11:30:52 2019 +1300

    librpc: Allow registration of ndr tables with a zero UUID
    
    This helps ndrdump find public structures to dump
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 1b6ae21fff9a649d451c30df90f167c33452975c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 12:20:19 2019 +1300

    build: Prepare for pidl to generate ndr_table entries for more IDL
    
    These IDL files will soon create ndr_table entries so need to be
    linked into the ndr-table subsystem.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit dd8dfa16dea73da3e07c0e84c308f74246cc5d13
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 12:12:02 2019 +1300

    s3-build: Skip building the ndr_table at the tail of ndr_libnetapi.c
    
    This is not a real protocol and all the functions are set to nopull,nopush
    but do not supply replacement functions.
    
    This is the best was I could find to skip compiling the table as otherwise
    it would point to undefined functions.
    
    This does not happen until we generate the ndr_table for idl files without
    a UUID, but we will shortly do that.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit dddef1b8224a2977c6e8b56af83429b36d6119ad
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 12:17:41 2019 +1300

    pidl: Allow the compilation of the ndr_table to be skiped
    
    libnetapi.idl defines a large number of functions a nopull,nopush and
    no replacement is provided.
    
    This will allow the ndr_table to be generated for all other IDL files
    that may have public structures that could usefully be dumped by
    ndrdump.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 5e0442efbe738c1e1d12a237b4c0abe8a472a176
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Nov 6 15:33:24 2019 +1300

    build: Allow warning on compile of libnetapi PIDL
    
    This not-protocol only uses the print functions, but this means some other functions
    are now unused, and as this is a special case it is better to just allow warnings
    here.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit e45e342624da1b7f5df42c34c6fdccf32fc7b0e2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 11:52:27 2019 +1300

    librpc: Do not include the ndr_table for libnet_join.idl and libnetapi.idl in the global list
    
    These are not wire protocols, there are no structures to parse.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 88c8cd7a1e7bc48a758bd00e91ca58ca91eed9d0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 4 11:51:11 2019 +1300

    librpc: Do not place the ndr_table for windows_event_ids.idl in the global list
    
    This is just a list of event IDs, there are no structures to parse.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-progammed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 88373c472c52ddc1191c1c20e74bff7776d0e805
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 11 16:39:13 2019 +1300

    selftest: Add expected-output tests for the ndrdump struct mode
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit dfbb3049585186230a0d28a581ad22de7276614c
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Wed Oct 30 03:05:22 2019 +0000

    ndrdump: add --stop-on-parse-failure
    
    If a data stream fails to parse as an NDR object, the default ndrdump
    action is to try to print those structures anyway, resulting perhaps in
    a NULL dereference. Sometimes you don't want to see that because it isn't
    very interesting and makes it harder to distinguish a crash in the parse
    routines. So --stop-on-parse-failure will skip the print and validate
    stages altogether if the parse failed.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Pair-programmed-with: Andrew Bartlett <abartlet at samba.org>

commit a106ceb7bfe588b1888001fbba5f500c2d33e5f8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Nov 5 09:46:13 2019 +1300

    librpc: Match interface name and file name for bkupblobs.idl
    
    This helps generate fuzzers for this IDL.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 666dbc61f1a32f78a4096373e7b94733e06bd86d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Nov 5 10:12:01 2019 +1300

    librpc: Match interface name and file name for winsrepl.idl
    
    This helps generate fuzzers for this IDL.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 8a627b5d65b65e926f739272bb8f8191cd1a25b3
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Nov 1 17:18:37 2019 +1300

    librpc: Fix typo in "quota" name in IDL
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 librpc/ABI/{ndr-0.2.0.sigs => ndr-0.2.1.sigs}      |   1 +
 librpc/idl/bkupblobs.idl                           |   2 +-
 librpc/idl/quota.idl                               |   2 +-
 librpc/idl/wscript_build                           |   9 +++-
 librpc/ndr/ndr_table.c                             |  26 ++++++++---
 librpc/tools/ndrdump.c                             |  50 ++++++++++++++++++---
 librpc/wscript_build                               |   2 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm           |  46 +++++++++++++++----
 python/samba/tests/blackbox/ndrdump.py             |  28 +++++++++++-
 source3/librpc/idl/wscript_build                   |  11 ++++-
 source3/librpc/wscript_build                       |   4 +-
 source4/librpc/idl/winsrepl.idl                    |   2 +-
 .../tests/dns-decode_dns_name_packet-hex.txt       |  35 +++++++++++++++
 source4/librpc/tests/krb5pac-PAC_DATA.dat          | Bin 0 -> 768 bytes
 source4/librpc/wscript_build                       |  12 +++++
 15 files changed, 203 insertions(+), 27 deletions(-)
 copy librpc/ABI/{ndr-0.2.0.sigs => ndr-0.2.1.sigs} (98%)
 create mode 100644 source4/librpc/tests/dns-decode_dns_name_packet-hex.txt
 create mode 100644 source4/librpc/tests/krb5pac-PAC_DATA.dat


Changeset truncated at 500 lines:

diff --git a/librpc/ABI/ndr-0.2.0.sigs b/librpc/ABI/ndr-0.2.1.sigs
similarity index 98%
copy from librpc/ABI/ndr-0.2.0.sigs
copy to librpc/ABI/ndr-0.2.1.sigs
index 6346f2fb491..b73a463bc8e 100644
--- a/librpc/ABI/ndr-0.2.0.sigs
+++ b/librpc/ABI/ndr-0.2.1.sigs
@@ -255,6 +255,7 @@ ndr_syntax_id_equal: bool (const struct ndr_syntax_id *, const struct ndr_syntax
 ndr_syntax_id_from_string: bool (const char *, struct ndr_syntax_id *)
 ndr_syntax_id_null: uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\000", node = "\000\000\000\000\000"}, if_version = 0
 ndr_syntax_id_to_string: char *(TALLOC_CTX *, const struct ndr_syntax_id *)
+ndr_table_misc: name = 0xXXXX "misc", syntax_id = {uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\000", node = "\000\000\000\000\000"}, if_version = 0}, helpstring = 0xXXXX, num_calls = 0, calls = 0xXXXX <misc_calls>, num_public_structs = 10, public_structs = 0xXXXX <misc_public_structs>, endpoints = 0xXXXX <misc_endpoints>, authservices = 0xXXXX <misc_authservices>
 ndr_token_peek: uint32_t (struct ndr_token_list *, const void *)
 ndr_token_retrieve: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *)
 ndr_token_retrieve_cmp_fn: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *, comparison_fn_t, bool)
diff --git a/librpc/idl/bkupblobs.idl b/librpc/idl/bkupblobs.idl
index d1ec4a5126f..6e4dd98b103 100644
--- a/librpc/idl/bkupblobs.idl
+++ b/librpc/idl/bkupblobs.idl
@@ -12,7 +12,7 @@ import "fscc.idl";
 ]
 
 
-interface bkup
+interface bkupblobs
 {
 	typedef [v1_enum] enum {
 		STREAM_ID_DATA	= 1,
diff --git a/librpc/idl/quota.idl b/librpc/idl/quota.idl
index 7c4d00acfcb..8d713c8475a 100644
--- a/librpc/idl/quota.idl
+++ b/librpc/idl/quota.idl
@@ -27,7 +27,7 @@ interface file_quota {
 	} file_quota_information;
 }
 
-interface smb2_query_quoata
+interface smb2_query_quota
 {
 	/* MS-SMB2 2.2.37.1 */
 	typedef [public] struct {
diff --git a/librpc/idl/wscript_build b/librpc/idl/wscript_build
index e17a37255fa..c9b19c4aac4 100644
--- a/librpc/idl/wscript_build
+++ b/librpc/idl/wscript_build
@@ -114,12 +114,19 @@ bld.SAMBA_PIDL_LIST('PIDL',
                     security.idl
                     server_id.idl
                     smb_acl.idl
-                    windows_event_ids.idl
                     xattr.idl
                     ''',
                     options='--header --ndr-parser --python',
                     output_dir='../gen_ndr')
 
+bld.SAMBA_PIDL_LIST('PIDL',
+		    '''
+                    windows_event_ids.idl
+                    ''',
+                    options='--header --ndr-parser --python',
+                    output_dir='../gen_ndr',
+                    generate_tables=False)
+
 bld.SAMBA_PIDL_LIST('PIDL',
                     'winbind.idl',
                     options='--header --ndr-parser --samba3-ndr-server --client --python',
diff --git a/librpc/ndr/ndr_table.c b/librpc/ndr/ndr_table.c
index f64e5ac4d20..c386b8c0030 100644
--- a/librpc/ndr/ndr_table.c
+++ b/librpc/ndr/ndr_table.c
@@ -36,12 +36,28 @@ NTSTATUS ndr_table_register(const struct ndr_interface_table *table)
 	struct ndr_interface_list *l;
 
 	for (l = ndr_interfaces; l; l = l->next) {
-		if (GUID_equal(&table->syntax_id.uuid, &l->table->syntax_id.uuid)) {
-			DEBUG(0, ("Attempt to register interface %s which has the "
-				  "same UUID as already registered interface %s\n", 
-				  table->name, l->table->name));
-			return NT_STATUS_OBJECT_NAME_COLLISION;
+		/*
+		 * If no GUID is supplied, use the name to determine
+		 * uniquness.
+		 */
+		if (GUID_all_zero(&table->syntax_id.uuid)) {
+			if (strcmp(table->name,
+				   l->table->name) != 0) {
+				continue;
+			}
+			DBG_ERR("Attempt to register interface %s which has the "
+				"same name as already registered interface\n",
+				table->name);
+		} else {
+			if (!GUID_equal(&table->syntax_id.uuid,
+					&l->table->syntax_id.uuid)) {
+				continue;
+			}
+			DBG_ERR("Attempt to register interface %s which has the "
+				"same UUID as already registered interface %s\n",
+				table->name, l->table->name);
 		}
+		return NT_STATUS_OBJECT_NAME_COLLISION;
 	}
 
 	/*
diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c
index bd4f277607b..4173f03098d 100644
--- a/librpc/tools/ndrdump.c
+++ b/librpc/tools/ndrdump.c
@@ -31,9 +31,17 @@ static const struct ndr_interface_call *find_function(
 	const struct ndr_interface_table *p,
 	const char *function)
 {
-	int i;
+	unsigned int i;
 	if (isdigit(function[0])) {
-		i = strtol(function, NULL, 0);
+		char *eptr = NULL;
+		i = strtoul(function, &eptr, 0);
+		if (i >= p->num_calls
+		    || eptr == NULL
+		    || eptr[0] != '\0') {
+			printf("Function number '%s' not found\n",
+			       function);
+			exit(1);
+		}
 		return &p->calls[i];
 	}
 	for (i=0;i<p->num_calls;i++) {
@@ -57,7 +65,19 @@ static const struct ndr_interface_call *find_struct(
 	const char *struct_name,
 	struct ndr_interface_call *out_buffer)
 {
-	int i;
+	unsigned int i;
+	if (isdigit(struct_name[0])) {
+		char *eptr = NULL;
+		i = strtoul(struct_name, &eptr, 0);
+		if (i >= p->num_public_structs
+		    || eptr == NULL
+		    || eptr[0] != '\0') {
+			printf("Public structure number '%s' not found\n",
+			       struct_name);
+			exit(1);
+		}
+		return &p->calls[i];
+	}
 	for (i=0;i<p->num_public_structs;i++) {
 		if (strcmp(p->public_structs[i].name, struct_name) == 0) {
 			break;
@@ -261,8 +281,18 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
 	bool assume_ndr64 = false;
 	bool quiet = false;
 	bool hex_input = false;
+	bool stop_on_parse_failure = false;
 	int opt;
-	enum {OPT_CONTEXT_FILE=1000, OPT_VALIDATE, OPT_DUMP_DATA, OPT_LOAD_DSO, OPT_NDR64, OPT_QUIET, OPT_HEX_INPUT};
+	enum {
+		OPT_CONTEXT_FILE=1000,
+		OPT_VALIDATE,
+		OPT_DUMP_DATA,
+		OPT_LOAD_DSO,
+		OPT_NDR64,
+		OPT_QUIET,
+		OPT_HEX_INPUT,
+		OPT_STOP_ON_PARSE_FAILURE,
+	};
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
 		{"context-file", 'c', POPT_ARG_STRING, NULL, OPT_CONTEXT_FILE, "In-filename to parse first", "CTX-FILE" },
@@ -272,6 +302,8 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
 		{"ndr64", 0, POPT_ARG_NONE, NULL, OPT_NDR64, "Assume NDR64 data", NULL },
 		{"quiet", 0, POPT_ARG_NONE, NULL, OPT_QUIET, "Don't actually dump anything", NULL },
 		{"hex-input", 0, POPT_ARG_NONE, NULL, OPT_HEX_INPUT, "Read the input file in as a hex dump", NULL },
+		{"stop-on-parse-failure", 0, POPT_ARG_NONE, NULL, OPT_STOP_ON_PARSE_FAILURE,
+		 "Do not try to print structures that fail to parse.", NULL },
 		POPT_COMMON_SAMBA
 		POPT_COMMON_VERSION
 		{ NULL }
@@ -316,6 +348,9 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
 		case OPT_HEX_INPUT:
 			hex_input = true;
 			break;
+		case OPT_STOP_ON_PARSE_FAILURE:
+			stop_on_parse_failure = true;
+			break;
 		}
 	}
 
@@ -360,7 +395,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
 	}
 
 	if (strcmp(type, "struct") == 0) {
-		flags = 0; /* neither NDR_IN nor NDR_OUT */
+		flags = NDR_SCALARS|NDR_BUFFERS; /* neither NDR_IN nor NDR_OUT */
 		f = find_struct(p, format, &f_buffer);
 	} else {
 		f = find_function(p, format);
@@ -509,6 +544,11 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
 
 	printf("pull returned %s\n", nt_errstr(status));
 
+	if (stop_on_parse_failure  && !NT_STATUS_IS_OK(status)) {
+		printf("not printing because --stop-on-parse-failure\n");
+		exit(1);
+	}
+
 	if (ndr_pull->offset > ndr_pull->relative_highest_offset) {
 		highest_ofs = ndr_pull->offset;
 	} else {
diff --git a/librpc/wscript_build b/librpc/wscript_build
index 5c4bedc5d7b..f5f8a344f64 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -620,7 +620,7 @@ bld.SAMBA_LIBRARY('ndr',
     public_deps='samba-errors talloc samba-util util_str_hex',
     public_headers='gen_ndr/misc.h gen_ndr/ndr_misc.h ndr/libndr.h:ndr.h',
     header_path= [('*gen_ndr*', 'gen_ndr')],
-    vnum='0.2.0',
+    vnum='0.2.1',
     abi_directory='ABI',
     abi_match='ndr_* GUID_*',
     )
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 2fc4327faf4..222a8b8c7b4 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -2768,7 +2768,7 @@ sub StructEntry($$)
 	$self->pidl("\t\t.struct_size = sizeof($type_decl),");
 	$self->pidl("\t\t.ndr_push = (ndr_push_flags_fn_t) ndr_push_$d->{NAME},");
 	$self->pidl("\t\t.ndr_pull = (ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},");
-	$self->pidl("\t\t.ndr_print = (ndr_print_function_t) ndr_print_$d->{NAME},");
+	$self->pidl("\t\t.ndr_print = (ndr_print_function_t) ndr_print_flags_$d->{NAME},");
 	$self->pidl("\t},");
 	return 1;
 }
@@ -2788,7 +2788,6 @@ sub FunctionTable($$)
 	}
 	return if ($#{$interface->{FUNCTIONS}}+1 == 0 and
 		   $count_public_structs == 0);
-	return unless defined ($interface->{PROPERTIES}->{uuid});
 
 	foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) {
 		$self->FunctionCallPipes($d);
@@ -2832,16 +2831,18 @@ sub FunctionTable($$)
 		$interface->{PROPERTIES}->{authservice} = "\"host\"";
 	}
 
-	$self->AuthServiceStruct($interface->{NAME}, 
+	$self->AuthServiceStruct($interface->{NAME},
 		                     $interface->{PROPERTIES}->{authservice});
 
 	$self->pidl("\nconst struct ndr_interface_table ndr_table_$interface->{NAME} = {");
 	$self->pidl("\t.name\t\t= \"$interface->{NAME}\",");
-	$self->pidl("\t.syntax_id\t= {");
-	$self->pidl("\t\t" . print_uuid($interface->{UUID}) .",");
-	$self->pidl("\t\tNDR_$uname\_VERSION");
-	$self->pidl("\t},");
-	$self->pidl("\t.helpstring\t= NDR_$uname\_HELPSTRING,");
+	if (defined $interface->{PROPERTIES}->{uuid}) {
+		$self->pidl("\t.syntax_id\t= {");
+		$self->pidl("\t\t" . print_uuid($interface->{UUID}) .",");
+		$self->pidl("\t\tNDR_$uname\_VERSION");
+		$self->pidl("\t},");
+		$self->pidl("\t.helpstring\t= NDR_$uname\_HELPSTRING,");
+	}
 	$self->pidl("\t.num_calls\t= $count,");
 	$self->pidl("\t.calls\t\t= $interface->{NAME}\_calls,");
 	$self->pidl("\t.num_public_structs\t= $count_public_structs,");
@@ -2910,7 +2911,15 @@ sub HeaderInterface($$$)
 
 		if(!defined $interface->{PROPERTIES}->{helpstring}) { $interface->{PROPERTIES}->{helpstring} = "NULL"; }
 		$self->pidl_hdr("#define NDR_$name\_HELPSTRING $interface->{PROPERTIES}->{helpstring}");
+	}
 
+	my $count_public_structs = 0;
+	foreach my $d (@{$interface->{TYPES}}) {
+	        next unless (has_property($d, "public"));
+		$count_public_structs += 1;
+	}
+	if ($#{$interface->{FUNCTIONS}}+1 > 0 or
+		   $count_public_structs > 0) {
 		$self->pidl_hdr("extern const struct ndr_interface_table ndr_table_$interface->{NAME};");
 	}
 
@@ -3014,6 +3023,18 @@ sub ParseTypePrintFunction($$$)
 
 	$self->pidl_hdr("void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args);");
 
+	if (has_property($e, "public")) {
+                $self->pidl("static void ".TypeFunctionName("ndr_print_flags", $e).
+                             "(struct ndr_print *$ndr, const char *name, int unused, $args)"
+                             );
+		$self->pidl("{");
+		$self->indent;
+		$self->pidl(TypeFunctionName("ndr_print", $e)."($ndr, name, $varname);");
+		$self->deindent;
+		$self->pidl("}");
+		$self->pidl("");
+	}
+
 	return if (has_property($e, "noprint"));
 
 	$self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *$ndr, const char *name, $args)");
@@ -3093,7 +3114,16 @@ sub ParseInterface($$$)
 		($needed->{"ndr_print_$d->{NAME}"}) && $self->ParseFunctionPrint($d);
 	}
 
+        # Allow compilation of generated files where replacement functions
+        # for structures declared nopull/nopush have not been provided.
+        #
+        # This makes sense when only the print functions are used
+        #
+        # Otherwise the ndr_table XXX will reference these
+
+        $self->pidl("#ifndef SKIP_NDR_TABLE_$interface->{NAME}");
 	$self->FunctionTable($interface);
+        $self->pidl("#endif /* SKIP_NDR_TABLE_$interface->{NAME} */");
 
 	$self->pidl_hdr("#endif /* _HEADER_NDR_$interface->{NAME} */");
 }
diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py
index fd1bc832d9b..b8f467f8e82 100644
--- a/python/samba/tests/blackbox/ndrdump.py
+++ b/python/samba/tests/blackbox/ndrdump.py
@@ -62,9 +62,35 @@ class NdrDumpTests(BlackboxTestCase):
                 self.data_path("dns-decode_dns_name_packet-hex.dat")))
 
     def test_ndrdump_with_hex_struct_name(self):
+        expected = open(self.data_path("dns-decode_dns_name_packet-hex.txt")).read()
         try:
-            self.check_run(
+            actual = self.check_output(
                 "ndrdump dns dns_name_packet struct --hex-input %s" %
                 self.data_path("dns-decode_dns_name_packet-hex.dat"))
         except BlackboxProcessError as e:
             self.fail(e)
+
+        # check_output will return bytes
+        # convert expected to bytes for python 3
+        self.assertEqual(actual, expected.encode('utf-8'))
+
+    def test_ndrdump_with_binary_struct_name(self):
+        # Prefix of the expected unparsed PAC data (without times, as
+        # these vary by host)
+        expected = '''pull returned NT_STATUS_OK
+    PAC_DATA: struct PAC_DATA
+        num_buffers              : 0x00000005 (5)
+        version                  : 0x00000000 (0)
+        buffers: ARRAY(5)'''
+        try:
+            actual = self.check_output(
+                "ndrdump krb5pac PAC_DATA struct %s" %
+                self.data_path("krb5pac-PAC_DATA.dat"))
+        except BlackboxProcessError as e:
+            self.fail(e)
+
+        # check_output will return bytes
+        # convert expected to bytes for python 3
+        self.assertEqual(actual[:len(expected)],
+                         expected.encode('utf-8'))
+        self.assertTrue(actual.endswith(b"dump OK\n"))
diff --git a/source3/librpc/idl/wscript_build b/source3/librpc/idl/wscript_build
index 183226e5f9b..2c6ec49faec 100644
--- a/source3/librpc/idl/wscript_build
+++ b/source3/librpc/idl/wscript_build
@@ -5,10 +5,17 @@ import os
 topinclude=os.path.join(bld.srcnode.abspath(), 'librpc/idl')
 
 bld.SAMBA_PIDL_LIST('PIDL',
-                    '''libnetapi.idl open_files.idl
-                       perfcount.idl secrets.idl libnet_join.idl
+                    '''open_files.idl
+                       perfcount.idl secrets.idl
                        smbXsrv.idl
                        leases_db.idl
                     ''',
                     options='--includedir=%s --header --ndr-parser' % topinclude,
                     output_dir='../gen_ndr')
+
+bld.SAMBA_PIDL_LIST('PIDL',
+                    '''libnetapi.idl libnet_join.idl
+                    ''',
+                    options='--includedir=%s --header --ndr-parser' % topinclude,
+                    output_dir='../gen_ndr',
+                    generate_tables=False)
diff --git a/source3/librpc/wscript_build b/source3/librpc/wscript_build
index 92603509311..34cd96bebda 100644
--- a/source3/librpc/wscript_build
+++ b/source3/librpc/wscript_build
@@ -1,8 +1,10 @@
 #!/usr/bin/env python
 
 bld.SAMBA3_SUBSYSTEM('NDR_LIBNETAPI',
+        cflags="-D SKIP_NDR_TABLE_libnetapi",
 	source='gen_ndr/ndr_libnetapi.c',
-	public_deps='ndr'
+	public_deps='ndr',
+	allow_warnings=True
 	)
 
 bld.SAMBA3_SUBSYSTEM('NDR_LIBNET_JOIN',
diff --git a/source4/librpc/idl/winsrepl.idl b/source4/librpc/idl/winsrepl.idl
index 23b14990e7d..4ef2e8ef7a7 100644
--- a/source4/librpc/idl/winsrepl.idl
+++ b/source4/librpc/idl/winsrepl.idl
@@ -15,7 +15,7 @@ import "nbt.idl";
 	uuid("915f5653-bac1-431c-97ee-9ffb34526921"),
 	helpstring("WINS Replication PDUs"),
 	helper("../libcli/nbt/libnbt.h")
-] interface wrepl
+] interface winsrepl
 {
 	const int WINS_REPLICATION_PORT = 42;
 
diff --git a/source4/librpc/tests/dns-decode_dns_name_packet-hex.txt b/source4/librpc/tests/dns-decode_dns_name_packet-hex.txt
new file mode 100644
index 00000000000..a973c28d5b9
--- /dev/null
+++ b/source4/librpc/tests/dns-decode_dns_name_packet-hex.txt
@@ -0,0 +1,35 @@
+pull returned NT_STATUS_OK
+    dns_name_packet: struct dns_name_packet
+        id                       : 0xecef (60655)
+        operation                : 0x2800 (10240)
+            0x00: DNS_RCODE                 (0)
+               0: DNS_FLAG_RECURSION_AVAIL 
+               0: DNS_FLAG_RECURSION_DESIRED
+               0: DNS_FLAG_TRUNCATION      
+               0: DNS_FLAG_AUTHORITATIVE   
+            0x05: DNS_OPCODE                (5)
+               0: DNS_FLAG_REPLY           
+        qdcount                  : 0x0001 (1)
+        ancount                  : 0x0000 (0)
+        nscount                  : 0x0001 (1)
+        arcount                  : 0x0000 (0)
+        questions: ARRAY(1)
+            questions: struct dns_name_question
+                name                     : 'samba2003.example.com'
+                question_type            : DNS_QTYPE_SOA (0x6)
+                question_class           : DNS_QCLASS_IN (0x1)
+        answers: ARRAY(0)
+        nsrecs: ARRAY(1)
+            nsrecs: struct dns_res_rec
+                name                     : 'cnamedotprefix0.samba2003.example.com'
+                rr_type                  : DNS_QTYPE_CNAME (0x5)
+                rr_class                 : DNS_QCLASS_IN (0x1)
+                ttl                      : 0x00000384 (900)
+                length                   : 0x0013 (19)
+                rdata                    : union dns_rdata(case 0x5)
+                cname_record             : ''
+                unexpected               : DATA_BLOB length=18
+[0000] 0F 62 6E 61 6D 65 64 6F   74 70 72 65 66 69 78 32   .bnamedo tprefix2
+[0010] C0 0C                                              .. 
+        additional: ARRAY(0)
+dump OK
diff --git a/source4/librpc/tests/krb5pac-PAC_DATA.dat b/source4/librpc/tests/krb5pac-PAC_DATA.dat
new file mode 100644
index 00000000000..71b48d9d719
Binary files /dev/null and b/source4/librpc/tests/krb5pac-PAC_DATA.dat differ
diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index 23b02604c83..7dab8bcf72d 100644
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -125,6 +125,18 @@ bld.SAMBA_SUBSYSTEM('ndr-table',
                     NDR_CLUSAPI
                     NDR_WINSPOOL
                     NDR_CAB
+                    NDR_FSRVP_STATE
+                    NDR_IOCTL
+                    NDR_COMPRESSION
+                    NDR_PRINTCAP
+                    NDR_QUOTA
+                    NDR_RAP
+                    NDR_DCERPC
+                    NDR_MESSAGING
+                    NDR_SMB_ACL
+                    NDR_PERFCOUNT
+                    NDR_SECRETS
+                    NDR_LEASES_DB
                     ''',
         depends_on='GEN_NDR_TABLES'
         )


-- 
Samba Shared Repository



More information about the samba-cvs mailing list