[SCM] Samba Shared Repository - branch v4-2-test updated

Karolin Seeger kseeger at samba.org
Wed Oct 29 16:49:03 MDT 2014


The branch, v4-2-test has been updated
       via  703957e s3: libsmbclient - smb2. MacOSX 10 SMB2 server doesn't set STATUS_NO_MORE_FILES when handed a non-wildcard path.
       via  bab7e51 spoolss: fix handling of bad EnumJobs levels
       via  241da63 s3-nmbd: Fix netbios name truncation.
      from  ec9437d winbind3: Fix pwent variable substitution

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test


- Log -----------------------------------------------------------------
commit 703957e0e5308bfc1e265890e86fcd113c2ba638
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Oct 21 14:41:32 2014 -0700

    s3: libsmbclient - smb2. MacOSX 10 SMB2 server doesn't set STATUS_NO_MORE_FILES when handed a non-wildcard path.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Steve French <smfrench at gmail.com>
    Tested-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Steve French <sfrench at samba.org>
    Autobuild-Date(master): Thu Oct 23 20:44:31 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 95bf43bc6a0b6a4a47b8a556eee3b78446ea4123)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10904
    smbclient loops doing a directory listing against Mac OS X 10 server with a
    non-wildcard path.
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Wed Oct 29 23:48:26 CET 2014 on sn-devel-104

commit bab7e5190f312d21fa713242c587430ec6a9f8d5
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Oct 27 20:13:59 2014 +0100

    spoolss: fix handling of bad EnumJobs levels
    
    Currently Samba is inconsistent when returning WERR_UNKNOWN_LEVEL
    errors for spoolss EnumJobs requests - if no print jobs are present,
    then WERR_OK will be returned, regardless of whether the EnumJobs level
    is supported or not.
    This change fixes this behaviour, by catching invalid or unsupported
    levels prior to the no-jobs response fast-path.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10898
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Oct 28 03:05:35 CET 2014 on sn-devel-104
    
    (cherry picked from commit d4f233a746d89e13aae78008b499c71b695ff882)

commit 241da6317b7c46b7e6cdbe4b5497a928f21279b4
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>
    (cherry picked from commit 6adcc7bffd5e1474ecba04d2328955c0b208cabc)
    Signed-off-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source3/libsmb/cli_smb2_fnum.c              |   14 +++++
 source3/nmbd/nmbd_nameregister.c            |   76 ++++++++++++++++++++++++---
 source3/rpc_server/spoolss/srv_spoolss_nt.c |    7 ++-
 3 files changed, 88 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index a099e03..de4bd6f 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -667,6 +667,7 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
 	bool processed_file = false;
 	TALLOC_CTX *frame = talloc_stackframe();
 	TALLOC_CTX *subframe = NULL;
+	bool mask_has_wild;
 
 	if (smbXcli_conn_has_async_calls(cli->conn)) {
 		/*
@@ -690,6 +691,8 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
 		goto fail;
         }
 
+	mask_has_wild = ms_has_wild(mask);
+
 	status = cli_smb2_create_fnum(cli,
 			parent_dir,
 			0,			/* create_flags */
@@ -791,6 +794,17 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
 
 		TALLOC_FREE(subframe);
 
+		if (!mask_has_wild) {
+			/*
+			 * MacOSX 10 doesn't set STATUS_NO_MORE_FILES
+			 * when handed a non-wildcard path. Do it
+			 * for the server (with a non-wildcard path
+			 * there should only ever be one file returned.
+			 */
+			status = STATUS_NO_MORE_FILES;
+			break;
+		}
+
 	} while (NT_STATUS_IS_OK(status));
 
 	if (NT_STATUS_EQUAL(status, STATUS_NO_MORE_FILES)) {
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/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index b8a6d77..552d4cb 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -7338,6 +7338,11 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
 		return WERR_INVALID_PARAM;
 	}
 
+	if ((r->in.level != 1) && (r->in.level != 2) && (r->in.level != 3)) {
+		DEBUG(4, ("EnumJobs level %d not supported\n", r->in.level));
+		return WERR_UNKNOWN_LEVEL;
+	}
+
 	DEBUG(4,("_spoolss_EnumJobs\n"));
 
 	*r->out.needed = 0;
@@ -7383,7 +7388,7 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
 					 pinfo2, r->out.info, r->out.count);
 		break;
 	default:
-		result = WERR_UNKNOWN_LEVEL;
+		SMB_ASSERT(false);	/* level checked on entry */
 		break;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list