A few patches

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Oct 5 09:32:52 MDT 2013


Hi!

Attached find a few unsorted but pretty trivial patches.
Please review & push.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de

*****************************************************************
visit us on it-sa:IT security exhibitions in Nürnberg, Germany
October 8th - 10th 2013, hall 12, booth 333
free tickets available via code 270691 on: www.it-sa.de/gutschein
******************************************************************
-------------- next part --------------
From adfa5303cf75a41637d9c0a485eeb230a65a93c5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 22 Sep 2013 19:16:56 -0700
Subject: [PATCH 01/10] smbd: Avoid calling serverid_exists twice

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/locking/locking.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d4c68f8..d0b6eaf 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -646,6 +646,12 @@ bool share_mode_stale_pid(struct share_mode_data *d, unsigned idx)
 		return false;
 	}
 	e = &d->share_modes[idx];
+	if (e->stale) {
+		/*
+		 * Checked before
+		 */
+		return true;
+	}
 	if (serverid_exists(&e->pid)) {
 		DEBUG(10, ("PID %s (index %u out of %u) still exists\n",
 			   procid_str_static(&e->pid), idx,
-- 
1.7.9.5


From 0bb5eb460be76dd7a41731a238b61deea2512c70 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 3 Sep 2013 13:31:27 +0000
Subject: [PATCH 02/10] smbd: Fix confusing comments

The brlock-check is done in grant_fsp_oplock_type

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/open.c   |    3 +--
 source3/smbd/oplock.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 1a86233..858d2be 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2676,8 +2676,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 	status = set_file_oplock(fsp, fsp->oplock_type);
 	if (!NT_STATUS_IS_OK(status)) {
 		/*
-		 * Could not get the kernel oplock or there are byte-range
-		 * locks on the file.
+		 * Could not get the kernel oplock
 		 */
 		fsp->oplock_type = NO_OPLOCK;
 	}
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 96c451c..efb37e1 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -47,8 +47,7 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
 
 /****************************************************************************
  Attempt to set an oplock on a file. Succeeds if kernel oplocks are
- disabled (just sets flags) and no byte-range locks in the file. Returns True
- if oplock set.
+ disabled (just sets flags).
 ****************************************************************************/
 
 NTSTATUS set_file_oplock(files_struct *fsp, int oplock_type)
-- 
1.7.9.5


From 10555835c8d3b4802b62af94b2ff513e2957cfa0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 Oct 2013 15:20:16 +0000
Subject: [PATCH 03/10] smbd: Fix a comment

This has been converted from a timed event to an immediate one in
e7dab403c0ca6f6

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/oplock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index efb37e1..6218862 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -645,7 +645,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
 	 * When we get here we might have a brlock entry locked. Also
 	 * locking the share mode entry would violate the locking
 	 * order. Breaking level2 oplocks to none is asynchronous
-	 * anyway, so we postpone this into an immediate timed event.
+	 * anyway, so we postpone this into an immediate event.
 	 */
 
 	state = talloc(sconn, struct break_to_none_state);
-- 
1.7.9.5


From ad52f5c8f8d9a78de9f9c78f53ef323a07f7d6c7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 22 Sep 2013 17:19:09 -0700
Subject: [PATCH 04/10] torture: Fix a typo

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/raw/streams.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 1611c64..cbb7dcf 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -478,7 +478,7 @@ done:
  * A stream held open with FILE_SHARE_DELETE allows the file to be
  * deleted. After the main file is deleted, access to the open file descriptor
  * still works, but all name-based access to both the main file as well as the
- * stream is denied with DELETE ending.
+ * stream is denied with DELETE pending.
  *
  * This means, an open of the main file with SEC_STD_DELETE should walk all
  * streams and also open them with SEC_STD_DELETE. If any of these opens gives
-- 
1.7.9.5


From 93a086a33969d77f44b8e64e4fd11206adb3528b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 21 Aug 2013 10:27:43 +0000
Subject: [PATCH 05/10] libcli: Add const to smb2_lease_pull

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 libcli/smb/smb2_lease.c |    3 ++-
 libcli/smb/smb2_lease.h |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c
index 10beaca..9e6c950 100644
--- a/libcli/smb/smb2_lease.c
+++ b/libcli/smb/smb2_lease.c
@@ -23,7 +23,8 @@
 #include "includes.h"
 #include "../libcli/smb/smb_common.h"
 
-ssize_t smb2_lease_pull(uint8_t *buf, size_t len, struct smb2_lease *lease)
+ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
+			struct smb2_lease *lease)
 {
 	int version;
 
diff --git a/libcli/smb/smb2_lease.h b/libcli/smb/smb2_lease.h
index fa8e7af..73f97ac 100644
--- a/libcli/smb/smb2_lease.h
+++ b/libcli/smb/smb2_lease.h
@@ -44,7 +44,8 @@ struct smb2_lease {
  * Parse a smb2 lease create context. Return -1 on error, buffer.length on
  * success. V1 and V2 differ only by length of buffer.length
  */
-ssize_t smb2_lease_pull(uint8_t *buf, size_t len, struct smb2_lease *lease);
+ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
+			struct smb2_lease *lease);
 bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len);
 
 #endif /* _LIBCLI_SMB_SMB2_LEASE_H_ */
-- 
1.7.9.5


From c7163d81d05215b4d98a53dc6a0c350ad0a2770e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 26 Sep 2013 17:10:50 -0700
Subject: [PATCH 06/10] libcli: Correct smb2_lease_pull

We don't really use leases yet, so so far this went by unnoticed. It's
the V2 lease requests that hold the parent lease key, not the V1 ones.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 libcli/smb/smb2_lease.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c
index 9e6c950..f97f096 100644
--- a/libcli/smb/smb2_lease.c
+++ b/libcli/smb/smb2_lease.c
@@ -46,13 +46,13 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len,
 
 	switch (version) {
 	case 1:
-		memcpy(&lease->parent_lease_key, buf+32, 16);
-		lease->lease_epoch = SVAL(buf, 48);
-		break;
-	case 2:
 		ZERO_STRUCT(lease->parent_lease_key);
 		lease->lease_epoch = 0;
 		break;
+	case 2:
+		memcpy(&lease->parent_lease_key, buf+32, 16);
+		lease->lease_epoch = SVAL(buf, 48);
+		break;
 	}
 
 	return len;
-- 
1.7.9.5


From 17e9bdc358dca066a9c65f314e034a13d6c6dc2f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 26 Sep 2013 21:21:21 -0700
Subject: [PATCH 07/10] torture: Continue buffer check after NOT_IMPLEMENTED
 infolevels

Patch from the SDC plugfest. Not every implementation supports every
infolevel, and we want to be able to test buffersize error behaviour
for all supported infolevels

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/getinfo.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index fafc36c..34fc8ee 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -328,6 +328,9 @@ static bool torture_smb2_qfile_buffercheck(struct torture_context *tctx)
 		b.in.output_buffer_length	= 65535;
 
 		status = smb2_getinfo(tree, tree, &b);
+		if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) {
+			continue;
+		}
 		torture_assert_ntstatus_equal(
 			tctx, status, NT_STATUS_OK,
 			"Wrong error code for large buffer");
-- 
1.7.9.5


From 63636895bd4021b8d0ef1bd2541079354c8b4375 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 26 Sep 2013 21:27:42 -0700
Subject: [PATCH 08/10] torture: Remove an unused variable

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/getinfo.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 34fc8ee..427fdd9 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -352,7 +352,6 @@ static bool torture_smb2_qsec_buffercheck(struct torture_context *tctx)
 	struct smb2_create c;
 	NTSTATUS status;
 	struct smb2_handle handle;
-	int i;
 
 	printf("Testing SMB2_GETINFO_SECURITY buffer sizes\n");
 
-- 
1.7.9.5


From 171629f7fec9512f7e23c3ad092df028bcb55e33 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 15 Sep 2013 19:18:41 -0700
Subject: [PATCH 09/10] smbd: Convert some dbgtxt to DEBUG

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/oplock.c |   31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 6218862..70f168e 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -255,13 +255,11 @@ static files_struct *initial_break_processing(
 {
 	files_struct *fsp = NULL;
 
-	if( DEBUGLVL( 3 ) ) {
-		dbgtext( "initial_break_processing: called for %s/%u\n",
-			 file_id_string_tos(&id), (int)file_id);
-		dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n",
-			sconn->oplocks.exclusive_open,
-			sconn->oplocks.level_II_open);
-	}
+	DEBUG(3, ("initial_break_processing: called for %s/%u\n"
+		  "Current oplocks_open (exclusive = %d, levelII = %d)\n",
+		  file_id_string_tos(&id), (int)file_id,
+		  sconn->oplocks.exclusive_open,
+		  sconn->oplocks.level_II_open));
 
 	/*
 	 * We need to search the file open table for the
@@ -273,11 +271,9 @@ static files_struct *initial_break_processing(
 
 	if(fsp == NULL) {
 		/* The file could have been closed in the meantime - return success. */
-		if( DEBUGLVL( 3 ) ) {
-			dbgtext( "initial_break_processing: cannot find open file with " );
-			dbgtext( "file_id %s gen_id = %lu, ", file_id_string_tos(&id), file_id);
-			dbgtext( "allowing break to succeed.\n" );
-		}
+		DEBUG(3, ("initial_break_processing: cannot find open file "
+			  "with file_id %s gen_id = %lu, allowing break to "
+			  "succeed.\n", file_id_string_tos(&id), file_id));
 		return NULL;
 	}
 
@@ -292,13 +288,10 @@ static files_struct *initial_break_processing(
 	 */
 
 	if(fsp->oplock_type == NO_OPLOCK) {
-		if( DEBUGLVL( 3 ) ) {
-			dbgtext( "initial_break_processing: file %s ",
-				 fsp_str_dbg(fsp));
-			dbgtext( "(file_id = %s gen_id = %lu) has no oplock.\n",
-				 file_id_string_tos(&id), fsp->fh->gen_id );
-			dbgtext( "Allowing break to succeed regardless.\n" );
-		}
+		DEBUG(3, ("initial_break_processing: file %s (file_id = %s "
+			  "gen_id = %lu) has no oplock. Allowing break to "
+			  "succeed regardless.\n", fsp_str_dbg(fsp),
+			  file_id_string_tos(&id), fsp->fh->gen_id));
 		return NULL;
 	}
 
-- 
1.7.9.5


From 5ff0e721eda68ad2ecc377eb2fc5ad6df0468613 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 11 Sep 2013 09:31:36 +0000
Subject: [PATCH 10/10] smbd: Remove unused "brl->key" struct element

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/locking/brlock.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index adbfc5f..ee4354c 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -48,7 +48,6 @@ struct byte_range_lock {
 	unsigned int num_locks;
 	bool modified;
 	bool read_only;
-	struct file_id key;
 	struct lock_struct *lock_data;
 	struct db_record *record;
 };
@@ -1944,9 +1943,8 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
 	br_lck->fsp = fsp;
 	br_lck->num_locks = 0;
 	br_lck->modified = False;
-	br_lck->key = fsp->file_id;
 
-	key.dptr = (uint8 *)&br_lck->key;
+	key.dptr = (uint8 *)&fsp->file_id;
 	key.dsize = sizeof(struct file_id);
 
 	if (!fsp->lockdb_clean) {
-- 
1.7.9.5



More information about the samba-technical mailing list