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

Karolin Seeger kseeger at samba.org
Tue Feb 16 11:56:08 UTC 2016


The branch, v4-4-test has been updated
       via  3a4be07 ctdb-scripts: Drop use of "smbcontrol winbindd ip-dropped ..."
       via  4f637ba lib/tsocket: workaround sockets not supporting FIONREAD
       via  6774af1 param: Fix str_list_v3 to accept ; again
       via  b65697f lib:socket: fix CID 1350009 - illegal memory accesses (BUFFER_SIZE_WARNING)
       via  08b1ff8 s3:utils/smbget set default blocksize
       via  5ca7624 s3:utils/smbget add a error message on allocation error
       via  558663a lib/socket: Fix improper use of default interface speed
       via  903b13e loadparm: Fix memory leak issue.
       via  2c91eb7 Revert "ctdb-daemon: Check packet generation against database generation"
       via  f3bca17 s3: smbd: posix_acls: Fix check for setting u:g:o entry on a filesystem with no ACL support.
       via  0221677 s3:smbd:open: Skip redundant call to file_set_dosmode when creating a new file.
       via  c358f3c smbd: Fix CID 1351216 Dereference null return value
       via  ed8a55f smbd: Fix CID 1351215 Improper use of negative value
       via  6c2a3e2 lib:socket: fix CID 1350010 - integer OVERFLOW_BEFORE_WIDEN
      from  0a0276b VERSION: Bump version up to 4.4.0rc3...

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


- Log -----------------------------------------------------------------
commit 3a4be07364acf90913c49e58c5ee876d06923c2a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 8 15:55:17 2016 +1100

    ctdb-scripts: Drop use of "smbcontrol winbindd ip-dropped ..."
    
    This is unnecessary in Samba >= 4.0 because winbindd monitors IP
    address itself and no longer needs to be told when they are dropped.
    The smbcontrol commands can hang if a node has recovery mode active
    because smbcontrol is unable to connect to the registry.  Therefore,
    the smbcontrol commands should be removed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11719
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Feb 10 14:08:17 CET 2016 on sn-devel-144
    
    (cherry picked from commit 519564bb35a0f840bc4d7c8c5a92441c97b49791)
    
    Autobuild-User(v4-4-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-4-test): Tue Feb 16 12:54:57 CET 2016 on sn-devel-144

commit 4f637ba7df5754130739c98aafd8bc6eb8e5b1c0
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 4 15:35:06 2016 +0100

    lib/tsocket: workaround sockets not supporting FIONREAD
    
    Netlink sockets don't support querying pending bytes with ioctl(fd,
    FIONREAD, ...) and would return EOPNOTSUPP, so use recvmsg() with
    MSG_PEEK|MSG_TRUNC as a fallback.
    
    The MSG_TRUNC flag to recvmsg() is Linux only, but netlink is as well,
    so we're safe for now.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11714
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Feb 10 10:30:24 CET 2016 on sn-devel-144
    
    (cherry picked from commit 574313a1e11d521ba3f7232ff0b4186b49658199)

commit 6774af16ea9b9fecb797a6fae2668b589ee22dc2
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 11 13:11:46 2016 +0100

    param: Fix str_list_v3 to accept ; again
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Feb 11 19:19:55 CET 2016 on sn-devel-144
    https://bugzilla.samba.org/show_bug.cgi?id=11732

commit b65697fd937a5d5765349aad65d2d60b04e33191
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 3 11:41:23 2016 +0100

    lib:socket: fix CID 1350009 - illegal memory accesses (BUFFER_SIZE_WARNING)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11735
    
    Pair-Programmed-With: Guenther Deschner <gd at samba.org>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 8b36428b195f6e1d1063f1abccb718f2665d271f)

commit 08b1ff8d8c7bbee8d7c8cd2ac8ac8dceac87b95d
Author: Christian Ambach <ambi at samba.org>
Date:   Thu Feb 4 21:39:47 2016 +0100

    s3:utils/smbget set default blocksize
    
    this got lost in the recent refactorings and causes problems
    when smbget attempts to use a zero byte read buffer
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Fri Feb  5 12:10:16 CET 2016 on sn-devel-144
    
    (cherry picked from commit da2aae933e3964aafce05c74755244e0f2b4d982)
    
    The last 2 patches address the following
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11700
    smbget options should be streamlined with the rest of the Samba utils

commit 5ca762425bc5bcfbb164e401479707a087776a8d
Author: Christian Ambach <ambi at samba.org>
Date:   Thu Feb 4 21:38:20 2016 +0100

    s3:utils/smbget add a error message on allocation error
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 64121471f98cfeaf48b701b3b85614a7436d3da9)

commit 558663a859c2890bf419d12604485f8acb4de71b
Author: Anoop C S <anoopcs at redhat.com>
Date:   Thu Feb 11 14:55:55 2016 +0530

    lib/socket: Fix improper use of default interface speed
    
    _get_interfaces() function from interfaces.c uses if_speed
    variable to store interface speed and is initialized with a
    default value at start. But if_speed populated via one
    iteration for a specific IP address will be treated as the
    default value for next iteration which is wrong. Therefore
    change is to move the initialization cum declaration of
    if_speed inside iteration of IP addresses loop.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11734
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Sat Feb 13 16:22:22 CET 2016 on sn-devel-144
    
    (cherry picked from commit 9fb98e3e056f059e2a5fcdd54a6a0d60ecdb01b7)

commit 903b13eae311b363ac3e870e4c44771d196b8286
Author: Hemanth Thummala <hemanth.thummala at nutanix.com>
Date:   Tue Feb 2 10:33:20 2016 -0800

    loadparm: Fix memory leak issue.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11708
    
    Signed-off-by: Hemanth Thummala <hemanth.thummala at nutanix.com>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Feb  4 12:39:14 CET 2016 on sn-devel-144
    
    (cherry picked from commit 8247d93701ed838190fe74044a63a56d63d37bf5)

commit 2c91eb7bbc0f7fca8d51f1e73c63cf8aba682ad7
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 2 15:58:37 2016 +1100

    Revert "ctdb-daemon: Check packet generation against database generation"
    
    This reverts commit 0ff90f4fac74e61192aff100b168e38ce0adfabb.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11707
    
    The checks against database generation are not required since
    the global generation is updated as part of updating vnnmap
    before the actual database recovery.  This change was done in
    5aab31a39a3589b910a78b96071d6aa5e6547696.
    
    Checking only against the database generation is incomplete.  It can
    cause CTDB to abort if the following sequence of events happen.
    
     - CTDB gets REQ_DMASTER packet (gen1)
       This packet processing gets deferred to get a record lock
    
     - CTDB goes into recovery, marks RECOVERY_ACTIVE
       CTDB recovery helper updates vnnmap (gen2)
    
     - CTDB processes REQ_DMASTER packet (gen1)
       The check against database generation (gen1) succeeds.
       The check for lmaster is now invalid because VNNMAP has changed.
       This will cause CTDB to abort due to protocol error.
    
    Reverting the patch stops processing packets of older generation before
    they get into call processing.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Tue Feb  9 12:39:24 CET 2016 on sn-devel-144
    
    (cherry picked from commit b71c2e42308d23f08e1dd38c9a45ee8f25c65404)

commit f3bca17914698e83a1f874fc7adce58e21af6b2d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Feb 9 12:47:43 2016 -0800

    s3: smbd: posix_acls: Fix check for setting u:g:o entry on a filesystem with no ACL support.
    
    Since 4.0.x we add 2 additional ACE entries, one SMB_ACL_USER
    and SMB_ACL_GROUP to match the existing SMB_ACL_USER_OBJ and
    SMB_ACL_GROUP_OBJ entries. The two additional entries break
    the simple "must have 3 entries" check done inside convert_canon_ace_to_posix_perms().
    Replace this with a more complete test.
    
    Problem and initial fix provided by <tcleamy at ucdavis.edu>
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10489
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Uri Simchoni <uri at samba.org>
    Autobuild-Date(master): Thu Feb 11 11:14:53 CET 2016 on sn-devel-144
    
    (cherry picked from commit 5172bf0c5b0672c1479c2ad776460956aa469bca)

commit 022167722618a300d2b16fc51b8b9628e765daec
Author: Jose A. Rivera <jarrpa at samba.org>
Date:   Wed Feb 3 20:58:19 2016 -0600

    s3:smbd:open: Skip redundant call to file_set_dosmode when creating a new file.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11727
    
    Signed-off-by: Jose A. Rivera <jarrpa at samba.org>
    Pair-programmed-with: Ira Cooper <ira at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Feb  5 04:37:43 CET 2016 on sn-devel-144
    
    (cherry picked from commit aec07b8b60ff9589a3c84eef6adeca464e6c01f6)

commit c358f3c120183cb8f64d681cc54c42782d89a4a1
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 3 09:10:46 2016 +0100

    smbd: Fix CID 1351216 Dereference null return value
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11725
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit f1933618500f8c4787f3bf7aa260e21cd6bf7cd8)

commit ed8a55f1ef6c689a0574267f7a350d1ca9d25522
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Feb 3 09:18:14 2016 +0100

    smbd: Fix CID 1351215 Improper use of negative value
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11724
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Feb  3 15:03:09 CET 2016 on sn-devel-144
    
    (cherry picked from commit 2d80498e64bc7f9e1fd2d080825c1e8904018a19)

commit 6c2a3e2f7656c9a89edf85141c9e1d2da98d51ff
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 3 11:28:32 2016 +0100

    lib:socket: fix CID 1350010 - integer OVERFLOW_BEFORE_WIDEN
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11723
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Feb  4 00:35:11 CET 2016 on sn-devel-144
    
    (cherry picked from commit 498383afefccb8c7acd93da2c374b5bed1de6e4a)

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

Summary of changes:
 ctdb/config/events.d/11.natgw   |  4 ---
 ctdb/config/events.d/49.winbind |  7 -----
 ctdb/server/ctdb_call.c         | 59 ++++++++-------------------------------
 ctdb/server/ctdb_server.c       | 21 ++++++++++----
 lib/socket/interfaces.c         |  9 ++++--
 lib/tsocket/tsocket_bsd.c       | 62 ++++++++++++++++++++++++++++++++++++++++-
 lib/util/util_strlist.c         | 18 +++++++++++-
 source3/param/loadparm.c        |  2 +-
 source3/smbd/open.c             |  4 +--
 source3/smbd/posix_acls.c       | 39 +++++++++++++++++++++++++-
 source3/smbd/smbXsrv_client.c   | 15 ++++++++--
 source3/utils/smbget.c          |  4 ++-
 12 files changed, 169 insertions(+), 75 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw
index 2b30eeb..956f77b 100755
--- a/ctdb/config/events.d/11.natgw
+++ b/ctdb/config/events.d/11.natgw
@@ -164,10 +164,6 @@ natgw_set_slave ()
 	_net="${_net_gw%@*}"
 	ip route add "$_net" via "$_natgwip" metric 10
     done
-
-    # Make sure winbindd does not stay bound to this address if we are
-    # no longer NATGW master
-    smbcontrol winbindd ip-dropped $CTDB_NATGW_PUBLIC_IP >/dev/null 2>&1
 }
 
 natgw_ensure_master ()
diff --git a/ctdb/config/events.d/49.winbind b/ctdb/config/events.d/49.winbind
index dee3c90..a1ea787 100755
--- a/ctdb/config/events.d/49.winbind
+++ b/ctdb/config/events.d/49.winbind
@@ -55,13 +55,6 @@ case "$1" in
 	ctdb_check_command wbinfo -p
 	;;
 
-     takeip|releaseip)
-	iface=$2
-	ip=$3
-	maskbits=$4
-
-	smbcontrol winbindd ip-dropped $ip >/dev/null 2>/dev/null
-	;;
     *)
 	ctdb_standard_event_handler "$@"
 	;;
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index db9fb6a..b61754e 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -586,23 +586,6 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 	size_t len;
 	int ret;
 
-	ctdb_db = find_ctdb_db(ctdb, c->db_id);
-	if (!ctdb_db) {
-		ctdb_send_error(ctdb, hdr, -1,
-				"Unknown database in request. db_id==0x%08x",
-				c->db_id);
-		return;
-	}
-
-	if (hdr->generation != ctdb_db->generation) {
-		DEBUG(DEBUG_DEBUG,
-		      ("ctdb operation %u request %u from node %u to %u had an"
-		       " invalid generation:%u while our generation is:%u\n",
-		       hdr->operation, hdr->reqid, hdr->srcnode, hdr->destnode,
-		       hdr->generation, ctdb_db->generation));
-		return;
-	}
-
 	key.dptr = c->data;
 	key.dsize = c->keylen;
 	data.dptr = c->data + c->keylen;
@@ -614,6 +597,14 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 		       sizeof(record_flags));
 	}
 
+	ctdb_db = find_ctdb_db(ctdb, c->db_id);
+	if (!ctdb_db) {
+		ctdb_send_error(ctdb, hdr, -1,
+				"Unknown database in request. db_id==0x%08x",
+				c->db_id);
+		return;
+	}
+
 	dmaster_defer_setup(ctdb_db, hdr, key);
 
 	/* fetch the current record */
@@ -642,7 +633,7 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 	if (header.dmaster != hdr->srcnode) {
 		DEBUG(DEBUG_ALERT,("pnn %u dmaster request for new-dmaster %u from non-master %u real-dmaster=%u key %08x dbid 0x%08x gen=%u curgen=%u c->rsn=%llu header.rsn=%llu reqid=%u keyval=0x%08x\n",
 			 ctdb->pnn, c->dmaster, hdr->srcnode, header.dmaster, ctdb_hash(&key),
-			 ctdb_db->db_id, hdr->generation, ctdb_db->generation,
+			 ctdb_db->db_id, hdr->generation, ctdb->vnn_map->generation,
 			 (unsigned long long)c->rsn, (unsigned long long)header.rsn, c->hdr.reqid,
 			 (key.dsize >= 4)?(*(uint32_t *)key.dptr):0));
 		if (header.rsn != 0 || header.dmaster != ctdb->pnn) {
@@ -657,7 +648,7 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 	if (header.rsn > c->rsn) {
 		DEBUG(DEBUG_ALERT,("pnn %u dmaster request with older RSN new-dmaster %u from %u real-dmaster=%u key %08x dbid 0x%08x gen=%u curgen=%u c->rsn=%llu header.rsn=%llu reqid=%u\n",
 			 ctdb->pnn, c->dmaster, hdr->srcnode, header.dmaster, ctdb_hash(&key),
-			 ctdb_db->db_id, hdr->generation, ctdb_db->generation,
+			 ctdb_db->db_id, hdr->generation, ctdb->vnn_map->generation,
 			 (unsigned long long)c->rsn, (unsigned long long)header.rsn, c->hdr.reqid));
 	}
 
@@ -902,6 +893,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		return;
 	}
 
+
 	ctdb_db = find_ctdb_db(ctdb, c->db_id);
 	if (!ctdb_db) {
 		ctdb_send_error(ctdb, hdr, -1,
@@ -910,15 +902,6 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		return;
 	}
 
-	if (hdr->generation != ctdb_db->generation) {
-		DEBUG(DEBUG_DEBUG,
-		      ("ctdb operation %u request %u from node %u to %u had an"
-		       " invalid generation:%u while our generation is:%u\n",
-		       hdr->operation, hdr->reqid, hdr->srcnode, hdr->destnode,
-		       hdr->generation, ctdb_db->generation));
-		return;
-	}
-
 	call = talloc(hdr, struct ctdb_call);
 	CTDB_NO_MEMORY_FATAL(ctdb, call);
 
@@ -1193,15 +1176,6 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		return;
 	}
 
-	if (hdr->generation != state->generation) {
-		DEBUG(DEBUG_DEBUG,
-		      ("ctdb operation %u request %u from node %u to %u had an"
-		       " invalid generation:%u while our generation is:%u\n",
-		       hdr->operation, hdr->reqid, hdr->srcnode, hdr->destnode,
-		       hdr->generation, state->generation));
-		return;
-	}
-
 
 	/* read only delegation processing */
 	/* If we got a FETCH_WITH_HEADER we should check if this is a ro
@@ -1296,16 +1270,7 @@ void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		DEBUG(DEBUG_ERR,("Unknown db_id 0x%x in ctdb_reply_dmaster\n", c->db_id));
 		return;
 	}
-
-	if (hdr->generation != ctdb_db->generation) {
-		DEBUG(DEBUG_DEBUG,
-		      ("ctdb operation %u request %u from node %u to %u had an"
-		       " invalid generation:%u while our generation is:%u\n",
-		       hdr->operation, hdr->reqid, hdr->srcnode, hdr->destnode,
-		       hdr->generation, ctdb_db->generation));
-		return;
-	}
-
+	
 	key.dptr = c->data;
 	key.dsize = c->keylen;
 	data.dptr = &c->data[key.dsize];
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index b30ecaa..7d42c38 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -225,11 +225,22 @@ void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 			goto done;
 		}
 
-		/* Push the check for generation in the handlers for these
-		 * operations.  Check database generation instead of global
-		 * generation.  Since the database context is not available
-		 * here, push the check in the operations.
-		 */
+		/* for ctdb_call inter-node operations verify that the
+		   remote node that sent us the call is running in the
+		   same generation instance as this node
+		*/
+		if (ctdb->vnn_map->generation != hdr->generation) {
+			DEBUG(DEBUG_DEBUG,(__location__ " ctdb operation %u"
+				" request %u"
+				" length %u from node %u to %u had an"
+				" invalid generation id:%u while our"
+				" generation id is:%u\n", 
+				 hdr->operation, hdr->reqid,
+				 hdr->length, 
+				 hdr->srcnode, hdr->destnode, 
+				 hdr->generation, ctdb->vnn_map->generation));
+			goto done;
+		}
 	}
 
 	switch (hdr->operation) {
diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
index 98341e2..2cabf46 100644
--- a/lib/socket/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -140,6 +140,11 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 		return;
 	}
 
+	if (strlen(name) >= IF_NAMESIZE) {
+		DBG_ERR("Interface name too long.");
+		goto done;
+	}
+
 	strncpy(ifr.ifr_name, name, IF_NAMESIZE);
 
 	ifr.ifr_data = (void *)&edata;
@@ -160,7 +165,7 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 	if (ret == -1) {
 		goto done;
 	}
-	*speed = (ethtool_cmd_speed(&ecmd)) * 1000 * 1000;
+	*speed = ((uint64_t)ethtool_cmd_speed(&ecmd)) * 1000 * 1000;
 
 done:
 	(void)close(fd);
@@ -184,7 +189,6 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
 	int count;
 	int total = 0;
 	size_t copy_size;
-	uint64_t if_speed = 1000 * 1000 * 1000; /* 1GBit */
 
 	if (getifaddrs(&iflist) < 0) {
 		return -1;
@@ -209,6 +213,7 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
 
 	/* Loop through interfaces, looking for given IP address */
 	for (ifptr = iflist; ifptr != NULL; ifptr = ifptr->ifa_next) {
+		uint64_t if_speed = 1000 * 1000 * 1000; /* 1Gbps */
 
 		if (!ifptr->ifa_addr || !ifptr->ifa_netmask) {
 			continue;
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index ac0617d..9608dde 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -132,6 +132,43 @@ static int tsocket_bsd_common_prepare_fd(int fd, bool high_fd)
 	return -1;
 }
 
+#ifdef HAVE_LINUX_RTNETLINK_H
+/**
+ * Get the amount of pending bytes from a netlink socket
+ *
+ * For some reason netlink sockets don't support querying the amount of pending
+ * data via ioctl with FIONREAD, which is what we use in tsocket_bsd_pending()
+ * below.
+ *
+ * We know we are on Linux as we're using netlink, which means we have a working
+ * MSG_TRUNC flag to recvmsg() as well, so we use that together with MSG_PEEK.
+ **/
+static ssize_t tsocket_bsd_netlink_pending(int fd)
+{
+	struct iovec iov;
+	struct msghdr msg;
+	char buf[1];
+
+	iov = (struct iovec) {
+		.iov_base = buf,
+		.iov_len = sizeof(buf)
+	};
+
+	msg = (struct msghdr) {
+		.msg_iov = &iov,
+		.msg_iovlen = 1
+	};
+
+	return recvmsg(fd, &msg, MSG_PEEK | MSG_TRUNC);
+}
+#else
+static ssize_t tsocket_bsd_netlink_pending(int fd)
+{
+	errno = ENOSYS;
+	return -1;
+}
+#endif
+
 static ssize_t tsocket_bsd_pending(int fd)
 {
 	int ret, error;
@@ -640,6 +677,7 @@ struct tdgram_bsd {
 	void *event_ptr;
 	struct tevent_fd *fde;
 	bool optimize_recvfrom;
+	bool netlink;
 
 	void *readable_private;
 	void (*readable_handler)(void *private_data);
@@ -892,7 +930,12 @@ static void tdgram_bsd_recvfrom_handler(void *private_data)
 	int err;
 	bool retry;
 
-	ret = tsocket_bsd_pending(bsds->fd);
+	if (bsds->netlink) {
+		ret = tsocket_bsd_netlink_pending(bsds->fd);
+	} else {
+		ret = tsocket_bsd_pending(bsds->fd);
+	}
+
 	if (state->first_try && ret == 0) {
 		state->first_try = false;
 		/* retry later */
@@ -1395,6 +1438,11 @@ int _tdgram_bsd_existing_socket(TALLOC_CTX *mem_ctx,
 {
 	struct tdgram_context *dgram;
 	struct tdgram_bsd *bsds;
+#ifdef HAVE_LINUX_RTNETLINK_H
+	int result;
+	struct sockaddr sa;
+	socklen_t sa_len = sizeof(struct sockaddr);
+#endif
 
 	dgram = tdgram_context_create(mem_ctx,
 				      &tdgram_bsd_ops,
@@ -1409,6 +1457,18 @@ int _tdgram_bsd_existing_socket(TALLOC_CTX *mem_ctx,
 	talloc_set_destructor(bsds, tdgram_bsd_destructor);
 
 	*_dgram = dgram;
+
+#ifdef HAVE_LINUX_RTNETLINK_H
+	/*
+	 * Try to determine the protocol family and remember if it's
+	 * AF_NETLINK. We don't care if this fails.
+	 */
+	result = getsockname(fd, &sa, &sa_len);
+	if (result == 0 && sa.sa_family == AF_NETLINK) {
+		bsds->netlink = true;
+	}
+#endif
+
 	return 0;
 }
 
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 987fdfb..2c1c2d5 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -552,7 +552,23 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
 		TALLOC_FREE(list);
 		return NULL;
 	}
-	if (!sep) sep = LIST_SEP;
+
+	/*
+	 * DON'T REPLACE THIS BY "LIST_SEP". The common version of
+	 * LIST_SEP does not contain the ;, which used to be accepted
+	 * by Samba 4.0 before param merges. It would be the far
+	 * better solution to split the _v3 version again to source3/
+	 * where it belongs, see the _v3 in its name.
+	 *
+	 * Unfortunately it is referenced in /lib/param/loadparm.c,
+	 * which depends on the version that the AD-DC mandates,
+	 * namely without the ; as part of the list separator. I am
+	 * missing the waf fu to properly work around the wrong
+	 * include paths here for this defect.
+	 */
+	if (sep == NULL) {
+		sep = " \t,;\n\r";
+	}
 
 	num = 0;
 	str = s;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 31d9e2d..fb92230 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1388,7 +1388,7 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na
 		return (-1);
 	}
 	ServicePtrs = tsp;
-	ServicePtrs[iNumServices] = talloc_zero(NULL, struct loadparm_service);
+	ServicePtrs[iNumServices] = talloc_zero(ServicePtrs, struct loadparm_service);
 	if (!ServicePtrs[iNumServices]) {
 		DEBUG(0,("add_a_service: out of memory!\n"));
 		return (-1);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index ed0594b..fa817e4 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -3169,8 +3169,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 	}
 
 	if (info != FILE_WAS_OPENED) {
-		/* Files should be initially set as archive */
-		if (lp_map_archive(SNUM(conn)) ||
+		/* Overwritten files should be initially set as archive */
+		if ((info == FILE_WAS_OVERWRITTEN && lp_map_archive(SNUM(conn))) ||
 		    lp_store_dos_attributes(SNUM(conn))) {
 			if (!posix_open) {
 				if (file_set_dosmode(conn, smb_fname,
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 5e39370..8c19169 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -3085,7 +3085,7 @@ static bool convert_canon_ace_to_posix_perms( files_struct *fsp, canon_ace *file
 	canon_ace *group_ace = NULL;
 	canon_ace *other_ace = NULL;
 
-	if (ace_count != 3) {
+	if (ace_count > 5) {
 		DEBUG(3,("convert_canon_ace_to_posix_perms: Too many ACE "
 			 "entries for file %s to convert to posix perms.\n",
 			 fsp_str_dbg(fsp)));
@@ -3107,6 +3107,43 @@ static bool convert_canon_ace_to_posix_perms( files_struct *fsp, canon_ace *file
 		return False;
 	}
 
+	/*
+	 * Ensure all ACE entries are owner, group or other.
+	 * We can't set if there are any other SIDs.
+	 */
+	for (ace_p = file_ace_list; ace_p; ace_p = ace_p->next) {
+		if (ace_p == owner_ace || ace_p == group_ace ||
+				ace_p == other_ace) {
+			continue;
+		}
+		if (ace_p->owner_type == UID_ACE) {
+			if (ace_p->unix_ug.id != owner_ace->unix_ug.id) {
+				DEBUG(3,("Invalid uid %u in ACE for file %s.\n",
+					(unsigned int)ace_p->unix_ug.id,
+					fsp_str_dbg(fsp)));
+				return false;
+			}
+		} else if (ace_p->owner_type == GID_ACE) {
+			if (ace_p->unix_ug.id != group_ace->unix_ug.id) {
+				DEBUG(3,("Invalid gid %u in ACE for file %s.\n",
+					(unsigned int)ace_p->unix_ug.id,
+					fsp_str_dbg(fsp)));
+				return false;
+			}
+		} else {
+			/*
+			 * There should be no duplicate WORLD_ACE entries.
+			 */
+
+			DEBUG(3,("Invalid type %u, uid %u in "
+				"ACE for file %s.\n",
+				(unsigned int)ace_p->owner_type,
+				(unsigned int)ace_p->unix_ug.id,
+				fsp_str_dbg(fsp)));
+			return false;
+		}
+	}
+
 	*posix_perms = (mode_t)0;
 
 	*posix_perms |= owner_ace->perms;
diff --git a/source3/smbd/smbXsrv_client.c b/source3/smbd/smbXsrv_client.c
index 87cc307..0e21fc6 100644
--- a/source3/smbd/smbXsrv_client.c
+++ b/source3/smbd/smbXsrv_client.c
@@ -63,6 +63,9 @@ NTSTATUS smbXsrv_client_global_init(void)
 	 * This contains secret information like client keys!
 	 */
 	global_path = lock_path("smbXsrv_client_global.tdb");
+	if (global_path == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
 
 	db_ctx = db_open(NULL, global_path,
 			 0, /* hash_size */
@@ -287,14 +290,20 @@ NTSTATUS smb2srv_client_connection_pass(struct smbd_smb2_request *smb2req,
 	NTSTATUS status;
 	struct smbXsrv_connection_pass0 pass_info0;
 	struct smbXsrv_connection_passB pass_blob;
+	ssize_t reqlen;
 	struct iovec iov;
 
 	pass_info0.initial_connect_time = global->initial_connect_time;
 	pass_info0.client_guid = global->client_guid;
-	pass_info0.negotiate_request.length = iov_buflen(smb2req->in.vector,
-							 smb2req->in.vector_count);
+
+	reqlen = iov_buflen(smb2req->in.vector, smb2req->in.vector_count);
+	if (reqlen == -1) {
+		return NT_STATUS_INVALID_BUFFER_SIZE;
+	}
+
+	pass_info0.negotiate_request.length = reqlen;
 	pass_info0.negotiate_request.data = talloc_array(talloc_tos(), uint8_t,
-					pass_info0.negotiate_request.length);
+							 reqlen);
 	if (pass_info0.negotiate_request.data == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 1dd8d77..91809d1 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -57,7 +57,7 @@ struct opt {
 	bool update;
 	int debuglevel;
 };
-static struct opt opt;
+static struct opt opt = { .blocksize = SMB_DEFAULT_BLOCKSIZE };
 
 static bool smb_download_file(const char *base, const char *name,
 			      bool recursive, bool resume, bool toplevel,
@@ -585,6 +585,8 @@ static bool smb_download_file(const char *base, const char *name,
 
 	readbuf = (char *)SMB_MALLOC(opt.blocksize);
 	if (!readbuf) {
+		fprintf(stderr, "Failed to allocate %zu bytes for read "
+				"buffer (%s)", opt.blocksize, strerror(errno));
 		if (localhandle != STDOUT_FILENO) {
 			close(localhandle);
 		}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list