[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Oct 29 07:32:01 MDT 2014


The branch, master has been updated
       via  ea962a6 torture/spoolss: cleanup print_job_enum test jobs
       via  6adcc7b s3-nmbd: Fix netbios name truncation.
      from  bf07a6b autobuild: check whether ctdbd has been installed in the samba-ctdb target

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


- Log -----------------------------------------------------------------
commit ea962a656ca43954a1ffb3af19dd406b69dee0e7
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Oct 29 11:54:19 2014 +0100

    torture/spoolss: cleanup print_job_enum test jobs
    
    Purge print queue on startup to ensure that the test is not affected by
    jobs queued for prior tests. Also, empty the queue at the end of the
    test to play nice with others.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Oct 29 14:31:52 CET 2014 on sn-devel-104

commit 6adcc7bffd5e1474ecba04d2328955c0b208cabc
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Oct 28 11:55:30 2014 -0700

    s3-nmbd: Fix netbios name truncation.
    
    Try and cope with truncation more intelligently.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10896
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source3/nmbd/nmbd_nameregister.c |   76 ++++++++++++++++++++++++++++++++++----
 source4/torture/rpc/spoolss.c    |   10 +++++
 2 files changed, 78 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index 71c4751..8b078e6 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -482,17 +482,77 @@ void register_name(struct subnet_record *subrec,
 {
 	struct nmb_name nmbname;
 	nstring nname;
+	size_t converted_size;
 
 	errno = 0;
-	push_ascii_nstring(nname, name);
-        if (errno == E2BIG) {
-		unstring tname;
-		pull_ascii_nstring(tname, sizeof(tname), nname);
-		DEBUG(0,("register_name: NetBIOS name %s is too long. Truncating to %s\n",
-			name, tname));
-		make_nmb_name(&nmbname, tname, type);
-	} else {
+	converted_size = push_ascii_nstring(nname, name);
+	if (converted_size != (size_t)-1) {
+		/* Success. */
 		make_nmb_name(&nmbname, name, type);
+	} else if (errno == E2BIG) {
+		/*
+		 * Name converted to CH_DOS is too large.
+		 * try to truncate.
+		 */
+		char *converted_str_dos = NULL;
+		char *converted_str_unix = NULL;
+		bool ok;
+
+		converted_size = 0;
+
+		ok = convert_string_talloc(talloc_tos(),
+				CH_UNIX,
+				CH_DOS,
+				name,
+				strlen(name)+1,
+				&converted_str_dos,
+				&converted_size);
+		if (!ok) {
+			DEBUG(0,("register_name: NetBIOS name %s cannot be "
+				"converted. Failing to register name.\n",
+				name));
+			return;
+		}
+
+		/*
+		 * As it's now CH_DOS codepage
+		 * we truncate by writing '\0' at
+		 * MAX_NETBIOSNAME_LEN-1 and then
+		 * convert back to CH_UNIX which we
+		 * need for the make_nmb_name() call.
+		 */
+		if (converted_size >= MAX_NETBIOSNAME_LEN) {
+			converted_str_dos[MAX_NETBIOSNAME_LEN-1] = '\0';
+		}
+
+		ok = convert_string_talloc(talloc_tos(),
+				CH_DOS,
+				CH_UNIX,
+				converted_str_dos,
+				strlen(converted_str_dos)+1,
+				&converted_str_unix,
+				&converted_size);
+		if (!ok) {
+			DEBUG(0,("register_name: NetBIOS name %s cannot be "
+				"converted back to CH_UNIX. "
+				"Failing to register name.\n",
+				converted_str_dos));
+			TALLOC_FREE(converted_str_dos);
+			return;
+		}
+
+		make_nmb_name(&nmbname, converted_str_unix, type);
+
+		TALLOC_FREE(converted_str_dos);
+		TALLOC_FREE(converted_str_unix);
+	} else {
+		/*
+		 * Generic conversion error. Fail to register.
+		 */
+		DEBUG(0,("register_name: NetBIOS name %s cannot be "
+			"converted (%s). Failing to register name.\n",
+			name, strerror(errno)));
+		return;
 	}
 
 	/* Always set the NB_ACTIVE flag on the name we are
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index dea5549..20e86fc 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -8867,6 +8867,11 @@ static bool test_print_job_enum(struct torture_context *tctx,
 		test_PausePrinter(tctx, b, &t->handle),
 		"failed to pause printer");
 
+	/* purge in case of any jobs from previous tests */
+	torture_assert(tctx,
+		test_printer_purge(tctx, b, &t->handle),
+		"failed to purge printer");
+
 	/* enum before jobs, valid level */
 	torture_assert(tctx,
 		       test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
@@ -8912,6 +8917,11 @@ static bool test_print_job_enum(struct torture_context *tctx,
 					  &count, &info),
 		       "EnumJobs with invalid level");
 
+	for (i = 0; i < num_jobs; i++) {
+		test_SetJob(tctx, b, &t->handle, job_ids[i], NULL,
+			    SPOOLSS_JOB_CONTROL_DELETE);
+	}
+
 	torture_assert(tctx,
 		test_ResumePrinter(tctx, b, &t->handle),
 		"failed to resume printer");


-- 
Samba Shared Repository


More information about the samba-cvs mailing list