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

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


The branch, v4-0-test has been updated
       via  1b0da1d spoolss: fix handling of bad EnumJobs levels
       via  76ff1da s3-nmbd: Fix netbios name truncation.
       via  e158ed9 There are tests all over the SMB1 code to check that srv_send_smb fails, but it never returns false.
       via  2ec015b s3: daemons - ensure nmbd and winbindd are consistent in command line processing by adding POPT_COMMON_DYNCONFIG.
      from  5b9d192 s3: nmbd: Ensure the main nmbd process doesn't create zombies.

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


- Log -----------------------------------------------------------------
commit 1b0da1d8bac7e8dfb52e723a7753b75ce8053a9c
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)
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Wed Oct 29 23:28:50 CET 2014 on sn-devel-104

commit 76ff1da55d36677a809c2c93761e713b6c2fae1c
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>

commit e158ed9d56c1d125deab00b46f325c5147045801
Author: Richard Sharpe <realrichardsharpe at gmail.com>
Date:   Mon Jul 22 16:04:43 2013 -0700

    There are tests all over the SMB1 code to check that srv_send_smb fails, but it never returns false.
    
    Even if the write to the socket/fd fails, we never return false and
    will keep reading stuff off of the input buffer until it is exhausted
    and then we will exit.
    
    Signed-off-by: Richard Sharpe <rsharpe at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Richard Sharpe <sharpe at samba.org>
    Autobuild-Date(master): Sat Aug  3 17:41:22 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 852c9ac34dbef66d0b2619554c611157c2fab771)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10880
    S3: source3/smbd/process.c::srv_send_smb() returns true on the error path.

commit 2ec015ba04ae821b99d99201bd8d80f09c7fe4e8
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jul 14 16:13:24 2014 -0700

    s3: daemons - ensure nmbd and winbindd are consistent in command line processing by adding POPT_COMMON_DYNCONFIG.
    
    Bug #10711 - nmbd fails to accept --piddir option.
    
    https://bugzilla.samba.org/show_bug.cgi?id=10711
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 source3/nmbd/nmbd.c                         |    3 +-
 source3/nmbd/nmbd_nameregister.c            |   76 ++++++++++++++++++++++++---
 source3/rpc_server/spoolss/srv_spoolss_nt.c |    7 ++-
 source3/smbd/process.c                      |    2 +-
 source3/winbindd/winbindd.c                 |    1 +
 5 files changed, 78 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index c924dd4..6990ae7 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -798,7 +798,8 @@ static bool open_sockets(bool isdaemon, int port)
 	{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 0, "Load a netbios hosts file"},
 	{"port", 'p', POPT_ARG_INT, &global_nmb_port, 0, "Listen on the specified port" },
 	POPT_COMMON_SAMBA
-	{ NULL }
+	POPT_COMMON_DYNCONFIG
+	POPT_TABLEEND
 	};
 	TALLOC_CTX *frame;
 	NTSTATUS status;
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 44497a6..f0ae9fa 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -7323,6 +7323,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;
@@ -7368,7 +7373,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;
 	}
 
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 942ede0..e67c56c 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -202,7 +202,7 @@ out:
 	SMB_PERFCOUNT_END(pcd);
 
 	smbd_unlock_socket(sconn);
-	return true;
+	return (ret > 0);
 }
 
 /*******************************************************************
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 69aa9a7..c481509 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1333,6 +1333,7 @@ int main(int argc, char **argv, char **envp)
 		{ "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
 		{ "no-caching", 'n', POPT_ARG_NONE, NULL, 'n', "Disable caching" },
 		POPT_COMMON_SAMBA
+		POPT_COMMON_DYNCONFIG
 		POPT_TABLEEND
 	};
 	poptContext pc;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list