[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Jun 10 20:29:06 UTC 2020


The branch, master has been updated
       via  787092b50ad s3/torture: test rbtree TDB_INSERT and TDB_MODIFY flags
       via  00a0da05033 s3/torture: use stack buffer for rbtree loop
       via  c5b10466c30 dbwrap_rbt: support TDB_INSERT and TDB_MODIFY store flags
       via  f501881a1c2 vfs_default: Remove an unused data member
      from  accbd9ee1c6 Revert "s3:libsmb: add a cache for cli_session_creds_prepare_krb5()"

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


- Log -----------------------------------------------------------------
commit 787092b50ad36fcafff85662f4039b4c7a0a3a47
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Jun 9 18:21:11 2020 +0200

    s3/torture: test rbtree TDB_INSERT and TDB_MODIFY flags
    
    Confirm that record overwrite with TDB_INSERT and record insert with
    TDB_MODIFY both fail with appropriate error values.
    
    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): Wed Jun 10 20:28:45 UTC 2020 on sn-devel-184

commit 00a0da050331d963d4dd2134ab4983e4f4da9d29
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Jun 9 15:52:29 2020 +0200

    s3/torture: use stack buffer for rbtree loop
    
    Using the stack here simplifies the error paths.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c5b10466c30759aabd472bb1baa4a5bd2540215d
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Jun 9 15:46:51 2020 +0200

    dbwrap_rbt: support TDB_INSERT and TDB_MODIFY store flags
    
    These flags provide insert-new and overwrite-existing record semantics
    respectively.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f501881a1c27a2aa070e5b2848749fa7d8f115ba
Author: Anoop C S <anoopcs at redhat.com>
Date:   Sat May 30 17:51:20 2020 +0530

    vfs_default: Remove an unused data member
    
    This was added as part of 7f7ce0ec2f3e3cfb46314e5ad3ea6b5c49085f1d but
    never got consumed.
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 lib/dbwrap/dbwrap_rbt.c       |  8 +++++
 source3/modules/vfs_default.c |  2 --
 source3/torture/torture.c     | 79 +++++++++++++++++++++++++++++++------------
 3 files changed, 66 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/dbwrap/dbwrap_rbt.c b/lib/dbwrap/dbwrap_rbt.c
index d988ca776de..db456dfffba 100644
--- a/lib/dbwrap/dbwrap_rbt.c
+++ b/lib/dbwrap/dbwrap_rbt.c
@@ -138,6 +138,14 @@ static NTSTATUS db_rbt_storev(struct db_record *rec,
 		return NT_STATUS_MEDIA_WRITE_PROTECTED;
 	}
 
+	if ((flag == TDB_INSERT) && (rec_priv->node != NULL)) {
+		return NT_STATUS_OBJECT_NAME_COLLISION;
+	}
+
+	if ((flag == TDB_MODIFY) && (rec_priv->node == NULL)) {
+		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+	}
+
 	if (num_dbufs == 1) {
 		data = dbufs[0];
 	} else {
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index a4910b4882d..fb9d16efd6b 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -3238,7 +3238,6 @@ struct vfswrap_getxattrat_state {
 	struct tevent_context *ev;
 	files_struct *dir_fsp;
 	const struct smb_filename *smb_fname;
-	struct tevent_req *req;
 
 	/*
 	 * The following variables are talloced off "state" which is protected
@@ -3291,7 +3290,6 @@ static struct tevent_req *vfswrap_getxattrat_send(
 		.ev = ev,
 		.dir_fsp = dir_fsp,
 		.smb_fname = smb_fname,
-		.req = req,
 	};
 
 	max_threads = pthreadpool_tevent_max_threads(dir_fsp->conn->sconn->pool);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index ce9c56056f5..2a3133373e9 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -12880,6 +12880,54 @@ static bool run_local_gencache(int dummy)
 	return True;
 }
 
+static bool rbt_testflags(struct db_context *db, const char *key,
+			  const char *value)
+{
+	bool ret = false;
+	NTSTATUS status;
+	struct db_record *rec;
+
+	rec = dbwrap_fetch_locked(db, db, string_tdb_data(key));
+	if (rec == NULL) {
+		d_fprintf(stderr, "fetch_locked failed\n");
+		goto done;
+	}
+
+	status = dbwrap_record_store(rec, string_tdb_data(value), TDB_MODIFY);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+		d_fprintf(stderr, "store TDB_MODIFY unexpected status: %s\n",
+			  nt_errstr(status));
+		goto done;
+	}
+
+	status = dbwrap_record_store(rec, string_tdb_data("overwriteme"),
+				     TDB_INSERT);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "store TDB_INSERT failed: %s\n",
+			  nt_errstr(status));
+		goto done;
+	}
+
+	status = dbwrap_record_store(rec, string_tdb_data(value), TDB_INSERT);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		d_fprintf(stderr, "store TDB_INSERT unexpected status: %s\n",
+			  nt_errstr(status));
+		goto done;
+	}
+
+	status = dbwrap_record_store(rec, string_tdb_data(value), TDB_MODIFY);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "store TDB_MODIFY failed: %s\n",
+			  nt_errstr(status));
+		goto done;
+	}
+
+	ret = true;
+done:
+	TALLOC_FREE(rec);
+	return ret;
+}
+
 static bool rbt_testval(struct db_context *db, const char *key,
 			const char *value)
 {
@@ -12951,37 +12999,26 @@ static bool run_local_rbtree(int dummy)
 		return false;
 	}
 
-	for (i=0; i<1000; i++) {
-		char *key, *value;
+	if (!rbt_testflags(db, "firstkey", "firstval")) {
+		goto done;
+	}
 
-		if (asprintf(&key, "key%ld", random()) == -1) {
-			goto done;
-		}
-		if (asprintf(&value, "value%ld", random()) == -1) {
-			SAFE_FREE(key);
-			goto done;
-		}
+	for (i = 0; i < 999; i++) {
+		char key[sizeof("key-9223372036854775807")];
+		char value[sizeof("value-9223372036854775807")];
+
+		snprintf(key, sizeof(key), "key%ld", random());
+		snprintf(value, sizeof(value) ,"value%ld", random());
 
 		if (!rbt_testval(db, key, value)) {
-			SAFE_FREE(key);
-			SAFE_FREE(value);
 			goto done;
 		}
 
-		SAFE_FREE(value);
-		if (asprintf(&value, "value%ld", random()) == -1) {
-			SAFE_FREE(key);
-			goto done;
-		}
+		snprintf(value, sizeof(value) ,"value%ld", random());
 
 		if (!rbt_testval(db, key, value)) {
-			SAFE_FREE(key);
-			SAFE_FREE(value);
 			goto done;
 		}
-
-		SAFE_FREE(key);
-		SAFE_FREE(value);
 	}
 
 	ret = true;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list