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

Karolin Seeger kseeger at samba.org
Wed Aug 10 10:43:03 UTC 2016


The branch, v4-4-test has been updated
       via  8620c56 dbwrap_ctdb: treat empty records in ltdb as non-existing
       via  8f6b83d s4/torture: add a test for ctdb-tombstrone-record deadlock
       via  a21dbf7 smbd: ignore ctdb tombstone records in fetch_share_mode_unlocked_parser()
       via  793a6da ctdb-daemon: Fix CID 1125627 Resource leak (RESOURCE_LEAK)
       via  0bb88b7 ctdb-common: Fix CID 1125585 Dereference after null check (FORWARD_NULL)
       via  3a182d1 ctdb-common: Fix CID 1125583 Dereference after null check (FORWARD_NULL)
       via  d6bbbb7 ctdb-common: Fix CID 1125581 Dereference after null check (FORWARD_NULL)
       via  1a9e8e0 ctdb-daemon: Fix CID 1363067 Resource leak (RESOURCE_LEAK)
       via  1a1dbce ctdb-daemon: Fix CID 1363233 Resource leak (RESOURCE_LEAK)
       via  6b22bee ctdb-utils: Fix CID 1297451 Explicit null dereferenced (FORWARD_NULL)
       via  0c0231d ctdb-common: Consistently use strlcpy() on interface names
       via  5fb821d ctdb-common: Fix CID 1125553 Buffer not null terminated (BUFFER_SIZE_WARNING)
       via  b9a3011 ctdb-daemon: Fix CID 1364527/8/9: Null pointer dereferences (NULL_RETURNS)
      from  f557672 ctdb-packaging: Move ctdb tests to libexec directory

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


- Log -----------------------------------------------------------------
commit 8620c56e3d8df5412aa63ce391b61ec5de2964dd
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Aug 8 16:58:51 2016 +0200

    dbwrap_ctdb: treat empty records in ltdb as non-existing
    
    When fetching records from remote ctdb nodes via ctdbd_parse() or in
    db_ctdb_traverse(), we already check for tombstone records and skip
    them. This was originally also done for the ltdb checks.
    
    See also bug: https://bugzilla.samba.org/show_bug.cgi?id=10008
    (commit 1cae59ce112ccb51b45357a52b902f80fce1eef1).
    
    Commit 925625b52886d40b50fc631bad8bdc81970f7598 reverted part of the
    patch of bug 10008 due to a deadlock it introduced.
    
    This patch re-introduces the consistent treatment of empty records in
    the ltdb but avoids the deadlock by correctly signalling
    NT_STATUS_NOT_FOUND if an empty record is found authoritatively in
    the ltdb and not calling ctdb in this case.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12005
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Tue Aug  9 04:38:44 CEST 2016 on sn-devel-144
    
    (backported from commit 25df582739918b7afd4e5497eaffe279e2d92cd1)
    
    Autobuild-User(v4-4-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-4-test): Wed Aug 10 12:42:51 CEST 2016 on sn-devel-144

commit 8f6b83dd81a5b665810709b1cf9c5e323e4d4252
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Jul 23 11:08:13 2016 +0200

    s4/torture: add a test for ctdb-tombstrone-record deadlock
    
    This tests for a possible deadlock between smbd and ctdb dealing with
    ctdb tombstone records.
    
    Commit 925625b52886d40b50fc631bad8bdc81970f7598 explains the deadlock in
    more details and contains the fix. It's a fix for a regression
    introduced by the patch for bug 10008 (1cae59ce112c).
    
    If you ever want to use this test against that specific commit:
    
    $ git checkout 925625b52886d40b50fc631bad8bdc81970f7598
    $ git cherry-pick THIS_COMMIT
    
    This should not deadlock on a ctdb cluster.
    
    $ git revert 925625b52886d40b50fc631bad8bdc81970f7598
    
    This will deadlock.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12005
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit b17e2f5c740fb081c007ed2e1c23138ffcba1469)

commit a21dbf76fe606ee9287ea3ec1f65bb8dee4ee18e
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 20 12:36:24 2016 +0200

    smbd: ignore ctdb tombstone records in fetch_share_mode_unlocked_parser()
    
    dbwrap_parse_record() can return ctdb tombstone records from the lctdb,
    ignore them.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12005
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 7147859c7afc1344e76485e2cbc286679110d96e)

commit 793a6da83ea18c0ff0b5a970b80e9a9b5f3273f9
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 5 16:50:58 2016 +1000

    ctdb-daemon: Fix CID 1125627 Resource leak (RESOURCE_LEAK)
    
    Also fixes CID 1125628.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 940272d215049f5f5079aa926e69eae1985a4bfa)

commit 0bb88b75a5c4d2647d12f9e4fcf9c507ba0e92ff
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 5 16:39:50 2016 +1000

    ctdb-common: Fix CID 1125585 Dereference after null check (FORWARD_NULL)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit b4f23a7e95cd9c8fc4a6324d4ec5a2881eaec207)

commit 3a182d140d2fd854b453eb27222697ae6e9f5b0a
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 5 16:38:45 2016 +1000

    ctdb-common: Fix CID 1125583 Dereference after null check (FORWARD_NULL)
    
    This also fixes CID 1125584.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit bbf0b907cb04184515d0f5f09f14824df1c2e59f)

commit d6bbbb7ef878180cba8cb0fab4ea68750ac8ea41
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 5 16:37:00 2016 +1000

    ctdb-common: Fix CID 1125581 Dereference after null check (FORWARD_NULL)
    
    This also fixes CID 1125582.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 7ae3699831427725f12e0a26a0681e59f2fbb2d9)

commit 1a9e8e0fcd5769b54e4ee50d8c5cabf2b21e450e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 28 12:06:23 2016 +1000

    ctdb-daemon: Fix CID 1363067 Resource leak (RESOURCE_LEAK)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit c6a7f680ce74d4a630fa9305d0a926cc1a4b3d2c)

commit 1a1dbce84451ab18759e75c87d69a44e256a5176
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 28 12:00:27 2016 +1000

    ctdb-daemon: Fix CID 1363233 Resource leak (RESOURCE_LEAK)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 74aca5f4c671d9f15ae6c3a901978a1cf247dd6f)

commit 6b22bee52edd1336454893d6c60e0dd004fd1a78
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 27 17:43:34 2016 +1000

    ctdb-utils: Fix CID 1297451 Explicit null dereferenced (FORWARD_NULL)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d46960f20e795cd4abc1c727705f77b2f0e0e564)

commit 0c0231d9c6edbdae707d4930967108c7eec033b6
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 1 15:03:56 2016 +1000

    ctdb-common: Consistently use strlcpy() on interface names
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit aff33a59479cafcb1f24a07ff76383d47bb196b3)

commit 5fb821d15e0084fb59cbc79d624ea64a8925dfc3
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 27 16:22:36 2016 +1000

    ctdb-common: Fix CID 1125553 Buffer not null terminated (BUFFER_SIZE_WARNING)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 763f9c13f2998a8858e8a3ec013d166a3d429835)

commit b9a3011961f1cef265d1b8e3f219ff479afeab84
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 27 11:45:49 2016 +1000

    ctdb-daemon: Fix CID 1364527/8/9: Null pointer dereferences (NULL_RETURNS)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit ed81e51cc1633cecfef05b84c0595418db8a384b)

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

Summary of changes:
 ctdb/common/rb_tree.c             |  6 ++--
 ctdb/common/system_linux.c        |  8 ++---
 ctdb/server/ctdb_daemon.c         |  8 +++++
 ctdb/server/ctdb_logging.c        |  9 ++++--
 ctdb/server/ctdb_recover.c        |  2 ++
 ctdb/server/ctdbd.c               |  4 +++
 ctdb/utils/ping_pong/ping_pong.c  |  4 ++-
 source3/lib/dbwrap/dbwrap_ctdb.c  | 27 ++++++++++++++++-
 source3/locking/share_mode_lock.c |  6 ++++
 source4/torture/smb2/lock.c       | 64 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 127 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/rb_tree.c b/ctdb/common/rb_tree.c
index 1c602a7..990ec61 100644
--- a/ctdb/common/rb_tree.c
+++ b/ctdb/common/rb_tree.c
@@ -216,21 +216,21 @@ static inline int trbt_get_color_right(trbt_node_t *node)
 /* setting a NULL node to black is a nop */
 static inline void trbt_set_color(trbt_node_t *node, int color)
 {
-	if ( (node==NULL) && (color==TRBT_BLACK) ) {
+	if (node == NULL) {
 		return;
 	}
 	node->rb_color = color;
 }
 static inline void trbt_set_color_left(trbt_node_t *node, int color)
 {
-	if ( ((node==NULL)||(node->left==NULL)) && (color==TRBT_BLACK) ) {
+	if (node == NULL || node->left == NULL) {
 		return;
 	}
 	node->left->rb_color = color;
 }
 static inline void trbt_set_color_right(trbt_node_t *node, int color)
 {
-	if ( ((node==NULL)||(node->right==NULL)) && (color==TRBT_BLACK) ) {
+	if (node == NULL || node->right == NULL) {
 		return;
 	}
 	node->right->rb_color = color;
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index 6d01699..2aa9e35 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -115,7 +115,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
 		}
 
 		/* get the mac address */
-		strncpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name)-1);
+		strlcpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name));
 		ret = ioctl(s, SIOCGIFHWADDR, &if_hwaddr);
 		if ( ret < 0 ) {
 			close(s);
@@ -201,7 +201,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
 		}
 
 		DEBUG(DEBUG_DEBUG, (__location__ " Created SOCKET FD:%d for sending arp\n", s));
-		strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
+		strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
 		if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
 			DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
 			close(s);
@@ -209,7 +209,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
 		}
 
 		/* get the mac address */
-		strncpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name)-1);
+		strlcpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name));
 		ret = ioctl(s, SIOCGIFHWADDR, &if_hwaddr);
 		if ( ret < 0 ) {
 			close(s);
@@ -588,7 +588,7 @@ bool ctdb_sys_check_iface_exists(const char *iface)
 		return true;
 	}
 
-	strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1);
+	strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
 	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
 		DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
 		close(s);
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 9a33691..1fe792c 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1260,6 +1260,10 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	}
 
 	ctdb->ev = tevent_context_init(NULL);
+	if (ctdb->ev == NULL) {
+		DEBUG(DEBUG_ALERT,("tevent_context_init() failed\n"));
+		exit(1);
+	}
 	tevent_loop_allow_nesting(ctdb->ev);
 	tevent_set_trace_callback(ctdb->ev, ctdb_tevent_trace, ctdb);
 	ret = ctdb_init_tevent_logging(ctdb);
@@ -1845,6 +1849,10 @@ int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...
 
 	/* get a new event context */
 	ctdb->ev = tevent_context_init(ctdb);
+	if (ctdb->ev == NULL) {
+		DEBUG(DEBUG_ALERT,("tevent_context_init() failed\n"));
+		exit(1);
+	}
 	tevent_loop_allow_nesting(ctdb->ev);
 
 	/* Connect to main CTDB daemon */
diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c
index 1819ab7..b19aad7 100644
--- a/ctdb/server/ctdb_logging.c
+++ b/ctdb/server/ctdb_logging.c
@@ -281,9 +281,14 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
 
 	/* We'll fail if stderr/stdout not already open; it's simpler. */
 	old_stdout = dup(STDOUT_FILENO);
+	if (old_stdout < 0) {
+		DEBUG(DEBUG_ERR, ("Failed to dup stdout for child logging\n"));
+		return -1;
+	}
 	old_stderr = dup(STDERR_FILENO);
-	if (old_stdout < 0 || old_stderr < 0) {
-		DEBUG(DEBUG_ERR, ("Failed to dup stdout/stderr for child logging\n"));
+	if (old_stderr < 0) {
+		DEBUG(DEBUG_ERR, ("Failed to dup stderr for child logging\n"));
+		close(old_stdout);
 		return -1;
 	}
 	if (dup2(p[1], STDOUT_FILENO) < 0 || dup2(p[1], STDERR_FILENO) < 0) {
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 47461f4..2c0edb0 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -1373,6 +1373,7 @@ int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA inda
 
 		if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
 			DEBUG(DEBUG_CRIT,(__location__ " bad ltdb record in indata\n"));
+			talloc_free(records);
 			return -1;
 		}
 
@@ -1565,6 +1566,7 @@ int32_t ctdb_control_receive_records(struct ctdb_context *ctdb,
 		if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
 			DEBUG(DEBUG_CRIT, (__location__ " bad ltdb record "
 					   "in indata\n"));
+			talloc_free(records);
 			return -1;
 		}
 
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index b8b979d..3c83dab 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -178,6 +178,10 @@ int main(int argc, const char *argv[])
 	fault_setup();
 
 	ev = tevent_context_init(NULL);
+	if (ev == NULL) {
+		DEBUG(DEBUG_ALERT,("tevent_context_init() failed\n"));
+		exit(1);
+	}
 	tevent_loop_allow_nesting(ev);
 
 	ctdb = ctdb_cmdline_init(ev);
diff --git a/ctdb/utils/ping_pong/ping_pong.c b/ctdb/utils/ping_pong/ping_pong.c
index be43a1d..f7f2eb1 100644
--- a/ctdb/utils/ping_pong/ping_pong.c
+++ b/ctdb/utils/ping_pong/ping_pong.c
@@ -142,7 +142,9 @@ static void ping_pong(int fd, int num_locks)
 	val = (unsigned char *)calloc(num_locks+1, sizeof(unsigned char));
 	if (val == NULL) {
 		printf("calloc failed\n");
-		munmap(p, num_locks+1);
+		if (use_mmap) {
+			munmap(p, num_locks+1);
+		}
 		return;
 	}
 
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index d5b8f45..5915444 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1216,6 +1216,7 @@ struct db_ctdb_parse_record_state {
 	void *private_data;
 	bool ask_for_readonly_copy;
 	bool done;
+	bool empty_record;
 };
 
 static void db_ctdb_parse_record_parser(
@@ -1235,7 +1236,16 @@ static void db_ctdb_parse_record_parser_nonpersistent(
 		(struct db_ctdb_parse_record_state *)private_data;
 
 	if (db_ctdb_can_use_local_hdr(header, true)) {
-		state->parser(key, data, state->private_data);
+		/*
+		 * A record consisting only of the ctdb header can be
+		 * a validly created empty record or a tombstone
+		 * record of a deleted record (not vacuumed yet). Mark
+		 * it accordingly.
+		 */
+		state->empty_record = (data.dsize == 0);
+		if (!state->empty_record) {
+			state->parser(key, data, state->private_data);
+		}
 		state->done = true;
 	} else {
 		/*
@@ -1261,6 +1271,7 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
 
 	state.parser = parser;
 	state.private_data = private_data;
+	state.empty_record = false;
 
 	if (ctx->transaction != NULL) {
 		struct db_ctdb_transaction_handle *h = ctx->transaction;
@@ -1292,6 +1303,20 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
 	status = db_ctdb_ltdb_parse(
 		ctx, key, db_ctdb_parse_record_parser_nonpersistent, &state);
 	if (NT_STATUS_IS_OK(status) && state.done) {
+		if (state.empty_record) {
+			/*
+			 * We know authoritatively, that this is an empty
+			 * record. Since ctdb does not distinguish between empty
+			 * and deleted records, this can be a record stored as
+			 * empty or a not-yet-vacuumed tombstone record of a
+			 * deleted record. Now Samba right now can live without
+			 * empty records, so we can safely report this record
+			 * as non-existing.
+			 *
+			 * See bugs 10008 and 12005.
+			 */
+			return NT_STATUS_NOT_FOUND;
+		}
 		return NT_STATUS_OK;
 	}
 
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 4e9de03..4503d5d 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -620,6 +620,12 @@ static void fetch_share_mode_unlocked_parser(
 	struct share_mode_lock *lck = talloc_get_type_abort(
 		private_data, struct share_mode_lock);
 
+	if (data.dsize == 0) {
+		/* Likely a ctdb tombstone record, ignore it */
+		lck->data = NULL;
+		return;
+	}
+
 	lck->data = parse_share_modes(lck, key, data);
 }
 
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index 68e353d..3900abf 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -3033,6 +3033,69 @@ done:
 	return ret;
 }
 
+/**
+ * Test lock interaction between smbd and ctdb with tombstone records.
+ *
+ * Re-locking an unlocked record could lead to a deadlock between
+ * smbd and ctdb. Make sure we don't regress.
+ *
+ * https://bugzilla.samba.org/show_bug.cgi?id=12005
+ * https://bugzilla.samba.org/show_bug.cgi?id=10008
+ */
+static bool test_deadlock(struct torture_context *torture,
+			  struct smb2_tree *tree)
+{
+	NTSTATUS status;
+	bool ret = true;
+	struct smb2_handle _h;
+	struct smb2_handle *h = NULL;
+	uint8_t buf[200];
+	const char *fname = BASEDIR "\\deadlock.txt";
+
+	if (!lpcfg_clustering(torture->lp_ctx)) {
+		torture_skip(torture, "Test must be run on a ctdb cluster\n");
+		return true;
+	}
+
+	status = torture_smb2_testdir(tree, BASEDIR, &_h);
+	torture_assert_ntstatus_ok(torture, status,
+				   "torture_smb2_testdir failed");
+	smb2_util_close(tree, _h);
+
+	status = torture_smb2_testfile(tree, fname, &_h);
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"torture_smb2_testfile failed");
+	h = &_h;
+
+	ZERO_STRUCT(buf);
+	status = smb2_util_write(tree, *h, buf, 0, ARRAY_SIZE(buf));
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"smb2_util_write failed");
+
+	status = test_smb2_lock(tree, *h, 0, 1, true);
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"test_smb2_lock failed");
+
+	status = test_smb2_unlock(tree, *h, 0, 1);
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"test_smb2_unlock failed");
+
+	status = test_smb2_lock(tree, *h, 0, 1, true);
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"test_smb2_lock failed");
+
+	status = test_smb2_unlock(tree, *h, 0, 1);
+	torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+					"test_smb2_unlock failed");
+
+done:
+	if (h != NULL) {
+		smb2_util_close(tree, *h);
+	}
+	smb2_deltree(tree, BASEDIR);
+	return ret;
+}
+
 /* basic testing of SMB2 locking
 */
 struct torture_suite *torture_smb2_lock_init(void)
@@ -3068,6 +3131,7 @@ struct torture_suite *torture_smb2_lock_init(void)
 	torture_suite_add_2smb2_test(suite, "overlap", test_overlap);
 	torture_suite_add_1smb2_test(suite, "truncate", test_truncate);
 	torture_suite_add_1smb2_test(suite, "replay", test_replay);
+	torture_suite_add_1smb2_test(suite, "ctdb-delrec-deadlock", test_deadlock);
 
 	suite->description = talloc_strdup(suite, "SMB2-LOCK tests");
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list