[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Dec 4 22:33:05 UTC 2020


The branch, master has been updated
       via  bbd94522b1e smbd: Remove "have_share_modes" from "struct share_mode_data"
       via  1ba4672ee90 smbd: Simplify share_mode_entry_do()
       via  7677c40fa55 smbd: Remove a comment that was not helpful for me
       via  05f9e8f9997 smbd: Simplify share_mode_lock_destructor()
       via  0f40c4ab637 smbd: Remove unused share_mode_have_entries()
       via  b712bd8173f smbd: Simplify open_mode_check()
       via  2c7e8e3fc5c smbd: Simplify share_mode_memcache_fetch()
       via  a8d2654d52b build: Fix kernel oplock test
       via  7d04b5a705f smbd: Align integer types
       via  18146c6285f spoolssd: Align integer types
       via  3bf9973d21f clitar: Align integer types
       via  441fdc1280b lib: Align integer types
      from  8a0a7359fab s3: smbd: Quiet log messages from usershares for an unknown share.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bbd94522b1e626ed1a4e87c297cfebe982fdbbce
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 17:16:25 2020 +0100

    smbd: Remove "have_share_modes" from "struct share_mode_data"
    
    Nobody in share_mode_lock.c looked at that value anymore, so we don't
    need to manually maintain it.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Dec  4 22:32:38 UTC 2020 on sn-devel-184

commit 1ba4672ee909251d41d2edb9af957549a72a1a36
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 17:12:20 2020 +0100

    smbd: Simplify share_mode_entry_do()
    
    Rely on the truth in locking.tdb wrt existence of share entries
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7677c40fa5587e0ac29427639011ae4e7c562d04
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 17:03:32 2020 +0100

    smbd: Remove a comment that was not helpful for me
    
    Also avoid an "else" branch
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 05f9e8f9997a4e72be69ca085db0c6efbffade78
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 17:02:10 2020 +0100

    smbd: Simplify share_mode_lock_destructor()
    
    Rely on the truth in the database whether we found share modes or
    not, share_mode_data_store() has that information for free.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0f40c4ab637cb0f74f0dbdf93611fe55b69c7f35
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 16:23:58 2020 +0100

    smbd: Remove unused share_mode_have_entries()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b712bd8173f860be25652420ac94db265003fd62
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 16:18:25 2020 +0100

    smbd: Simplify open_mode_check()
    
    The call to share_mode_have_entries() was put in before
    fresh_share_mode_lock() initialized d->flags to be completely
    permissive. With that correct initialization the call to
    share_conflict() a few lines down will also make open_mode_check()
    pass for any share_access/access_mask.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2c7e8e3fc5c04326bae7bd4de69c6a41e5c2bf43
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 1 13:50:32 2020 +0100

    smbd: Simplify share_mode_memcache_fetch()
    
    Take a struct file_id instead of a locking.tdb key,
    share_mode_memcache_store() also operates on the implicit fid in
    struct share_mode_data.
    
    To do this, parse_share_modes() also needs to take file_id.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a8d2654d52bd8539eb73cafe9da5666aad7c7d50
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Nov 20 14:19:21 2020 +0100

    build: Fix kernel oplock test
    
    In a pure docker environment with overlayfs F_GETLEASE works on /tmp,
    but F_SETLEASE does not. This test now correctly detects that.
    
    The effect is that the samba-fileserver environment would run fine in
    a shared gitlab runner, at the price of not testing kernel oplocks. We
    could move the kernel oplock tests to another environment that for
    other reasons can't run on shared gitlab runners.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7d04b5a705f0e97ae568a40b1d5fb13483e9afab
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 1 13:27:11 2020 +0100

    smbd: Align integer types
    
    full_path_tos() return ssize_t
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 18146c6285fa5a7f7e17dbe8b5481679ce8b8e2b
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 3 16:23:39 2020 +0100

    spoolssd: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3bf9973d21ffb261bbf8cbf257935c6c66855fe6
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Dec 2 11:13:11 2020 +0100

    clitar: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 441fdc1280bc2158a3bc7cf9c9896cf93b7c8be3
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 30 13:39:15 2020 +0100

    lib: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 source3/client/clitar.c           |  2 +-
 source3/lib/tldap.c               |  3 +-
 source3/librpc/idl/open_files.idl |  1 -
 source3/locking/share_mode_lock.c | 86 +++++++++++++++------------------------
 source3/locking/share_mode_lock.h |  1 -
 source3/printing/spoolssd.c       |  2 +-
 source3/smbd/dir.c                |  4 +-
 source3/smbd/open.c               | 11 +----
 source3/wscript                   |  8 +++-
 9 files changed, 45 insertions(+), 73 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 4fd1f3c47d9..7348420db5e 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -272,7 +272,6 @@ int cmd_tarmode(void)
 {
 	const extern char *cmd_ptr;
 	char *buf;
-	int i;
 	TALLOC_CTX *ctx;
 
 	struct {
@@ -298,6 +297,7 @@ int cmd_tarmode(void)
 	}
 
 	while (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) {
+		size_t i;
 		for (i = 0; i < ARRAY_SIZE(table); i++) {
 			if (strequal(table[i].cmd, buf)) {
 				*table[i].p = table[i].value;
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index 0e39a307728..e008b04e5e6 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -666,7 +666,8 @@ static void tldap_msg_received(struct tevent_req *subreq)
 	uint8_t *inbuf;
 	ssize_t received;
 	size_t num_pending;
-	int i, err;
+	size_t i;
+	int err;
 	TLDAPRC status = TLDAP_PROTOCOL_ERROR;
 	int id;
 	uint8_t type;
diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl
index 891ff1f763d..49bc09d77b6 100644
--- a/source3/librpc/idl/open_files.idl
+++ b/source3/librpc/idl/open_files.idl
@@ -64,7 +64,6 @@ interface open_files
 		NTTIME changed_write_time;
 		[skip] boolean8 fresh;
 		[skip] boolean8 modified;
-		[skip] boolean8 have_share_modes;
 		[ignore] file_id id; /* In memory key used to lookup cache. */
 	} share_mode_data;
 
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index c9012f7454b..8ad9341a765 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -274,26 +274,17 @@ static int share_mode_data_nofree_destructor(struct share_mode_data *d)
 
 static struct share_mode_data *share_mode_memcache_fetch(
 	TALLOC_CTX *mem_ctx,
-	const TDB_DATA id_key,
+	struct file_id id,
 	const uint8_t *buf,
 	size_t buflen)
 {
+	const DATA_BLOB key = memcache_key(&id);
 	enum ndr_err_code ndr_err;
 	struct share_mode_data *d;
 	uint64_t unique_content_epoch;
 	uint16_t flags;
 	void *ptr;
-	struct file_id id;
 	struct file_id_buf idbuf;
-	DATA_BLOB key;
-
-	/* Ensure this is a locking_key record. */
-	if (id_key.dsize != sizeof(id)) {
-		return NULL;
-	}
-
-	memcpy(&id, id_key.dptr, id_key.dsize);
-	key = memcache_key(&id);
 
 	ptr = memcache_lookup_talloc(NULL,
 			SHARE_MODE_LOCK_CACHE,
@@ -592,7 +583,7 @@ static NTSTATUS locking_tdb_data_store(
 
 static struct share_mode_data *parse_share_modes(
 	TALLOC_CTX *mem_ctx,
-	const TDB_DATA key,
+	struct file_id id,
 	const uint8_t *buf,
 	size_t buflen)
 {
@@ -601,7 +592,7 @@ static struct share_mode_data *parse_share_modes(
 	DATA_BLOB blob;
 
 	/* See if we already have a cached copy of this key. */
-	d = share_mode_memcache_fetch(mem_ctx, key, buf, buflen);
+	d = share_mode_memcache_fetch(mem_ctx, id, buf, buflen);
 	if (d != NULL) {
 		return d;
 	}
@@ -629,14 +620,6 @@ static struct share_mode_data *parse_share_modes(
 		NDR_PRINT_DEBUG(share_mode_data, d);
 	}
 
-	/*
-	 * We have a non-zero locking.tdb record that was correctly
-	 * parsed. This means a share_entries.tdb entry exists,
-	 * otherwise we'd have paniced before in
-	 * share_mode_data_store()
-	 */
-	d->have_share_modes = true;
-
 	return d;
 fail:
 	TALLOC_FREE(d);
@@ -647,7 +630,8 @@ fail:
  If modified, store the share_mode_data back into the database.
 ********************************************************************/
 
-static NTSTATUS share_mode_data_store(struct share_mode_data *d)
+static NTSTATUS share_mode_data_store(
+	struct share_mode_data *d, bool *have_share_entries)
 {
 	TDB_DATA key = locking_key(&d->id);
 	struct locking_tdb_data *ltdb = NULL;
@@ -685,6 +669,8 @@ static NTSTATUS share_mode_data_store(struct share_mode_data *d)
 			TALLOC_FREE(ltdb);
 			return ndr_map_error2ntstatus(ndr_err);
 		}
+
+		*have_share_entries = true;
 	}
 
 	ltdb->share_mode_data_buf = blob.data;
@@ -786,7 +772,6 @@ static void get_static_share_mode_data_fn(
 	void *private_data)
 {
 	struct get_static_share_mode_data_state *state = private_data;
-	TDB_DATA key = locking_key(&state->id);
 	struct share_mode_data *d = NULL;
 	struct locking_tdb_data ltdb = { 0 };
 
@@ -818,7 +803,7 @@ static void get_static_share_mode_data_fn(
 	} else {
 		d = parse_share_modes(
 			lock_ctx,
-			key,
+			state->id,
 			ltdb.share_mode_data_buf,
 			ltdb.share_mode_data_len);
 		if (d == NULL) {
@@ -957,6 +942,7 @@ fail:
 
 static int share_mode_lock_destructor(struct share_mode_lock *lck)
 {
+	bool have_share_entries = false;
 	NTSTATUS status;
 
 	SMB_ASSERT(static_share_mode_data_refcount > 0);
@@ -966,7 +952,8 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
 		return 0;
 	}
 
-	status = share_mode_data_store(static_share_mode_data);
+	status = share_mode_data_store(
+		static_share_mode_data, &have_share_entries);
 	if (!NT_STATUS_IS_OK(status)) {
 		DBG_ERR("share_mode_data_store failed: %s\n",
 			nt_errstr(status));
@@ -985,7 +972,7 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
 		}
 	}
 
-	if (static_share_mode_data->have_share_modes) {
+	if (have_share_entries) {
 		/*
 		 * This is worth keeping. Without share modes,
 		 * share_mode_data_store above has left nothing in the
@@ -993,17 +980,9 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
 		 */
 		share_mode_memcache_store(static_share_mode_data);
 		static_share_mode_data = NULL;
-	} else {
-		/*
-		 * The next opener of this file will find an empty
-		 * locking.tdb record. Don't store the share_mode_data
-		 * in the memcache, fresh_share_mode_lock() will
-		 * generate a fresh seqnum anyway, obsoleting the
-		 * cache entry.
-		 */
-		TALLOC_FREE(static_share_mode_data);
 	}
 
+	TALLOC_FREE(static_share_mode_data);
 	return 0;
 }
 
@@ -1117,11 +1096,6 @@ NTSTATUS share_mode_wakeup_waiters(struct file_id id)
 	return share_mode_do_locked(id, share_mode_wakeup_waiters_fn, NULL);
 }
 
-bool share_mode_have_entries(struct share_mode_lock *lck)
-{
-	return lck->data->have_share_modes;
-}
-
 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck)
 {
 	return lck->data->changed_write_time;
@@ -1324,7 +1298,7 @@ NTSTATUS share_mode_watch_recv(
 
 struct fetch_share_mode_unlocked_state {
 	TALLOC_CTX *mem_ctx;
-	TDB_DATA key;
+	struct file_id id;
 	struct share_mode_lock *lck;
 };
 
@@ -1360,7 +1334,7 @@ static void fetch_share_mode_unlocked_parser(
 
 	state->lck->data = parse_share_modes(
 		state->lck,
-		state->key,
+		state->id,
 		ltdb.share_mode_data_buf,
 		ltdb.share_mode_data_len);
 	if (state->lck->data == NULL) {
@@ -1379,12 +1353,13 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
 {
 	struct fetch_share_mode_unlocked_state state = {
 		.mem_ctx = mem_ctx,
-		.key = locking_key(&id),
+		.id = id,
 	};
+	TDB_DATA key = locking_key(&id);
 	NTSTATUS status;
 
 	status = g_lock_dump(
-		lock_ctx, state.key, fetch_share_mode_unlocked_parser, &state);
+		lock_ctx, key, fetch_share_mode_unlocked_parser, &state);
 	if (!NT_STATUS_IS_OK(status)) {
 		DBG_DEBUG("g_lock_dump failed: %s\n", nt_errstr(status));
 		return NULL;
@@ -1497,7 +1472,7 @@ static void fetch_share_mode_fn(
 
 	state->lck->data = parse_share_modes(
 		state->lck,
-		locking_key(&state->id),
+		state->id,
 		ltdb.share_mode_data_buf,
 		ltdb.share_mode_data_len);
 	if (state->lck->data == NULL) {
@@ -1593,7 +1568,7 @@ static void share_mode_forall_dump_fn(
 
 	d = parse_share_modes(
 		talloc_tos(),
-		state->key,
+		fid,
 		ltdb.share_mode_data_buf,
 		ltdb.share_mode_data_len);
 	if (d == NULL) {
@@ -1892,7 +1867,6 @@ bool set_share_mode(struct share_mode_lock *lck,
 		/*
 		 * Storing a fresh record with just one share entry
 		 */
-		d->have_share_modes = true;
 		d->modified = true;
 	}
 
@@ -2086,9 +2060,9 @@ bool share_mode_forall_entries(
 
 	if ((ltdb->num_share_entries != 0 ) && (num_share_entries == 0)) {
 		/*
-		 * This routine wiped all share entries
+		 * This routine wiped all share entries, let
+		 * share_mode_data_store() delete the record
 		 */
-		d->have_share_modes = false;
 		d->modified = true;
 	}
 
@@ -2177,7 +2151,7 @@ static bool share_mode_entry_do(
 	bool modified;
 	struct share_mode_entry e;
 	uint8_t *e_ptr = NULL;
-	bool have_share_modes;
+	bool had_share_entries, have_share_entries;
 	NTSTATUS status;
 	bool ret = false;
 
@@ -2189,6 +2163,8 @@ static bool share_mode_entry_do(
 	}
 	DBG_DEBUG("num_share_modes=%zu\n", ltdb->num_share_entries);
 
+	had_share_entries = (ltdb->num_share_entries != 0);
+
 	idx = share_mode_entry_find(
 		ltdb->share_entries,
 		ltdb->num_share_entries,
@@ -2265,9 +2241,12 @@ static bool share_mode_entry_do(
 		goto done;
 	}
 
-	have_share_modes = (ltdb->num_share_entries != 0);
-	if (d->have_share_modes != have_share_modes) {
-		d->have_share_modes = have_share_modes;
+	have_share_entries = (ltdb->num_share_entries != 0);
+	if (had_share_entries != have_share_entries) {
+		/*
+		 * Make share_mode_data_store do the right thing wrt
+		 * possibly deleting the locking.tdb record
+		 */
 		d->modified = true;
 	}
 
@@ -2533,7 +2512,6 @@ bool reset_share_mode_entry(
 		goto done;
 	}
 
-	d->have_share_modes = true;
 	d->modified = true;
 	ret = true;
 done:
diff --git a/source3/locking/share_mode_lock.h b/source3/locking/share_mode_lock.h
index 09a354c0d01..f2fe3d51a16 100644
--- a/source3/locking/share_mode_lock.h
+++ b/source3/locking/share_mode_lock.h
@@ -94,7 +94,6 @@ bool share_mode_forall_entries(
 		   bool *modified,
 		   void *private_data),
 	void *private_data);
-bool share_mode_have_entries(struct share_mode_lock *lck);
 
 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck);
 const char *share_mode_servicepath(struct share_mode_lock *lck);
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index babec72e299..cd1f4b2188a 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -586,7 +586,7 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx,
 	int fd = -1;
 	int rc;
 	enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
-	uint32_t i;
+	int i;
 	struct dcesrv_endpoint *e = NULL;
 
 	DBG_INFO("Initializing DCE/RPC connection endpoints\n");
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 5602fa9ea15..73eb2d17166 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1640,7 +1640,7 @@ bool SearchDir(struct smb_Dir *dir_hnd, const char *name, long *poffset)
 
 struct files_below_forall_state {
 	char *dirpath;
-	size_t dirpath_len;
+	ssize_t dirpath_len;
 	int (*fn)(struct file_id fid, const struct share_mode_data *data,
 		  void *private_data);
 	void *private_data;
@@ -1653,7 +1653,7 @@ static int files_below_forall_fn(struct file_id fid,
 	struct files_below_forall_state *state = private_data;
 	char tmpbuf[PATH_MAX];
 	char *fullpath, *to_free;
-	size_t len;
+	ssize_t len;
 
 	len = full_path_tos(data->servicepath, data->base_name,
 			    tmpbuf, sizeof(tmpbuf),
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 3f5bc89cefe..bf612970458 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1761,7 +1761,7 @@ static NTSTATUS open_mode_check(connection_struct *conn,
 				uint32_t share_access)
 {
 	struct open_mode_check_state state;
-	bool ok, conflict, have_share_entries;
+	bool ok, conflict;
 	bool modified = false;
 
 	if (is_oplock_stat_open(access_mask)) {
@@ -1787,15 +1787,6 @@ static NTSTATUS open_mode_check(connection_struct *conn,
 	}
 #endif
 
-	have_share_entries = share_mode_have_entries(lck);
-	if (!have_share_entries) {
-		/*
-		 * This is a fresh share mode lock where no conflicts
-		 * can happen.
-		 */
-		return NT_STATUS_OK;
-	}
-
 	share_mode_flags_get(
 		lck, &state.access_mask, &state.share_access, NULL);
 
diff --git a/source3/wscript b/source3/wscript
index 011594b3844..a370fae667f 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -184,8 +184,12 @@ main() {
 #ifndef F_GETLEASE
 #define F_GETLEASE 1025
 #endif
-main() {
-        exit(fcntl(open("/tmp", O_RDONLY), F_GETLEASE, 0) == -1 ?  1 : 0);
+int main() {
+	const char *fname="/tmp/oplock-test.txt";
+	int fd = open(fname, O_RDWR|O_CREAT, 0644);
+	int ret = fcntl(fd, F_SETLEASE, F_WRLCK);
+	unlink(fname);
+	return (ret == -1) ? 1 : 0;
 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
         msg="Checking for Linux kernel oplocks")
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list