[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Sep 27 18:20:05 MDT 2010


The branch, master has been updated
       via  f98d217 Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on all TDB_CLEAR_IF_FIRST tdb's. For tdb's like gencache where we open without CLEAR_IF_FIRST and then with CLEAR_IF_FIRST if corrupt this is still safe to use as if opening an existing tdb the new hash will be ignored - it's only used on creating a new tdb not opening an old one.
      from  6676142 s4-ildap: two more places that need talloc_reparent()

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


- Log -----------------------------------------------------------------
commit f98d217514433cd06887f8c0217a7835392f0375
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Sep 27 05:46:07 2010 -0700

    Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on all
    TDB_CLEAR_IF_FIRST tdb's. For tdb's like gencache where we open
    without CLEAR_IF_FIRST and then with CLEAR_IF_FIRST if corrupt
    this is still safe to use as if opening an existing tdb the new
    hash will be ignored - it's only used on creating a new tdb not
    opening an old one.
    
    Jeremy.

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

Summary of changes:
 source3/lib/conn_tdb.c            |    2 +-
 source3/lib/g_lock.c              |    2 +-
 source3/lib/gencache.c            |    8 ++++----
 source3/lib/messages_local.c      |    4 ++--
 source3/lib/serverid.c            |    4 ++--
 source3/lib/sessionid_tdb.c       |    2 +-
 source3/libsmb/samlogon_cache.c   |    4 ++--
 source3/libsmb/smb_share_modes.c  |    2 +-
 source3/libsmb/unexpected.c       |    2 +-
 source3/locking/brlock.c          |    2 +-
 source3/locking/locking.c         |    2 +-
 source3/nmbd/nmbd_winsserver.c    |    3 ++-
 source3/printing/printer_list.c   |    2 +-
 source3/smbd/notify_internal.c    |    8 ++++----
 source3/utils/dbwrap_torture.c    |    2 +-
 source3/utils/smbcontrol.c        |    3 ++-
 source3/utils/status.c            |    2 +-
 source3/winbindd/winbindd_cache.c |    7 +++++--
 18 files changed, 33 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/conn_tdb.c b/source3/lib/conn_tdb.c
index 75841cc..e4c5e72 100644
--- a/source3/lib/conn_tdb.c
+++ b/source3/lib/conn_tdb.c
@@ -33,7 +33,7 @@ static struct db_context *connections_db_ctx(bool rw)
 	open_flags = rw ? (O_RDWR|O_CREAT) : O_RDONLY;
 
 	db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
-			 TDB_CLEAR_IF_FIRST|TDB_DEFAULT, open_flags, 0644);
+			 TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, open_flags, 0644);
 	return db_ctx;
 }
 
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index edb7786..2c06502 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -53,7 +53,7 @@ struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
 	result->msg = msg;
 
 	result->db = db_open(result, lock_path("g_lock.tdb"), 0,
-			     TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0700);
+			     TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0700);
 	if (result->db == NULL) {
 		DEBUG(1, ("g_lock_init: Could not open g_lock.tdb"));
 		TALLOC_FREE(result);
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index a78e60a..8d2ddb2 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -65,7 +65,7 @@ static bool gencache_init(void)
 	DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
 again:
-	cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, open_flags, 0644);
+	cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, open_flags, 0644);
 	if (cache) {
 		int ret;
 		ret = tdb_check(cache, NULL, NULL);
@@ -80,7 +80,7 @@ again:
 			first_try = false;
 			DEBUG(0, ("gencache_init: tdb_check(%s) failed - retry after CLEAR_IF_FIRST\n",
 				  cache_fname));
-			cache = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST, open_flags, 0644);
+			cache = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, open_flags, 0644);
 			if (cache) {
 				tdb_close(cache);
 				cache = NULL;
@@ -91,7 +91,7 @@ again:
 
 	if (!cache && (errno == EACCES)) {
 		open_flags = O_RDONLY;
-		cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, open_flags,
+		cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, open_flags,
 				     0644);
 		if (cache) {
 			DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname));
@@ -107,7 +107,7 @@ again:
 
 	DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
-	cache_notrans = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST,
+	cache_notrans = tdb_open_log(cache_fname, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 				     open_flags, 0644);
 	if (cache_notrans == NULL) {
 		DEBUG(5, ("Opening %s failed: %s\n", cache_fname,
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c
index 542d49e..bad577c 100644
--- a/source3/lib/messages_local.c
+++ b/source3/lib/messages_local.c
@@ -103,7 +103,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
 	ctx->msg_ctx = msg_ctx;
 
 	ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), 0,
-				 TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE,
+				 TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
 				 O_RDWR|O_CREAT,0600);
 
 	if (!ctx->tdb) {
@@ -144,7 +144,7 @@ bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
 	 */
 
 	db = tdb_wrap_open(mem_ctx, lock_path("messages.tdb"), 0,
-			   TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE,
+			   TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
 			   O_RDWR|O_CREAT,0600);
 	if (db == NULL) {
 		DEBUG(1, ("could not open messaging.tdb: %s\n",
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index f0c61ae..dd02e51 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -44,7 +44,7 @@ bool serverid_parent_init(TALLOC_CTX *mem_ctx)
 	 */
 
 	db = tdb_wrap_open(mem_ctx, lock_path("serverid.tdb"),
-			   0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT,
+			   0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT,
 			   0644);
 	if (db == NULL) {
 		DEBUG(1, ("could not open serverid.tdb: %s\n",
@@ -62,7 +62,7 @@ static struct db_context *serverid_db(void)
 		return db;
 	}
 	db = db_open(NULL, lock_path("serverid.tdb"), 0,
-		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0644);
+		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
 	return db;
 }
 
diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c
index 1515728..fe67681 100644
--- a/source3/lib/sessionid_tdb.c
+++ b/source3/lib/sessionid_tdb.c
@@ -29,7 +29,7 @@ static struct db_context *session_db_ctx(void)
 	}
 
 	session_db_ctx_ptr = db_open(NULL, lock_path("sessionid.tdb"), 0,
-				     TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
+				     TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
 				     O_RDWR | O_CREAT, 0644);
 	return session_db_ctx_ptr;
 }
diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index 7f096ec..45354f1 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -45,7 +45,7 @@ bool netsamlogon_cache_init(void)
 
 	path = cache_path(NETSAMLOGON_TDB);
 again:
-	tdb = tdb_open_log(path, 0, TDB_DEFAULT,
+	tdb = tdb_open_log(path, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
 			   O_RDWR | O_CREAT, 0600);
 	if (tdb == NULL) {
 		DEBUG(0,("tdb_open_log('%s') - failed\n", path));
@@ -69,7 +69,7 @@ clear:
 	first_try = false;
 
 	DEBUG(0,("retry after CLEAR_IF_FIRST for '%s'\n", path));
-	tdb = tdb_open_log(path, 0, TDB_CLEAR_IF_FIRST,
+	tdb = tdb_open_log(path, 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 			   O_RDWR | O_CREAT, 0600);
 	if (tdb) {
 		tdb_close(tdb);
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c
index 177e011..9f98550 100644
--- a/source3/libsmb/smb_share_modes.c
+++ b/source3/libsmb/smb_share_modes.c
@@ -67,7 +67,7 @@ struct smbdb_ctx *smb_share_mode_db_open(const char *db_path)
 	memset(smb_db, '\0', sizeof(struct smbdb_ctx));
 
 	smb_db->smb_tdb = tdb_open(db_path,
-				0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST,
+				0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 				O_RDWR|O_CREAT,
 				0644);
 
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index 1ac45ec..17ebcd2 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -47,7 +47,7 @@ void unexpected_packet(struct packet_struct *p)
 	if (!tdbd) {
 		tdbd = tdb_wrap_open(talloc_autofree_context(),
 				     lock_path("unexpected.tdb"), 0,
-				     TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
+				     TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
 				     O_RDWR | O_CREAT, 0644);
 		if (!tdbd) {
 			DEBUG(0,("Failed to open unexpected.tdb\n"));
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index 408917e..3cb9487 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -273,7 +273,7 @@ void brl_init(bool read_only)
 		return;
 	}
 
-	tdb_flags = TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST;
+	tdb_flags = TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH;
 
 	if (!lp_clustering()) {
 		/*
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 89bd19a..ed07d7a 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -437,7 +437,7 @@ static bool locking_init_internal(bool read_only)
 
 	lock_db = db_open(NULL, lock_path("locking.tdb"),
 			  lp_open_files_db_hash_size(),
-			  TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST,
+			  TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 			  read_only?O_RDONLY:O_RDWR|O_CREAT, 0644);
 
 	if (!lock_db) {
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 5f3a9c3..d4580e4 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -604,7 +604,8 @@ bool initialise_wins(void)
 	}
 
 	/* Open the wins.tdb. */
-	wins_tdb = tdb_open_log(state_path("wins.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_CREAT|O_RDWR, 0600);
+	wins_tdb = tdb_open_log(state_path("wins.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+			O_CREAT|O_RDWR, 0600);
 	if (!wins_tdb) {
 		DEBUG(0,("initialise_wins: failed to open wins.tdb. Error was %s\n",
 			strerror(errno) ));
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index f52dfcf..667ff70 100644
--- a/source3/printing/printer_list.c
+++ b/source3/printing/printer_list.c
@@ -36,7 +36,7 @@ static struct db_context *get_printer_list_db(void)
 		return db;
 	}
 	db = db_open(talloc_autofree_context(), PL_DB_NAME(), 0,
-		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST,
+		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 		     O_RDWR|O_CREAT, 0644);
 	return db;
 }
diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c
index 1dc10bb..acb438b 100644
--- a/source3/smbd/notify_internal.c
+++ b/source3/smbd/notify_internal.c
@@ -95,7 +95,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
 	}
 
 	notify->db_recursive = db_open(notify, lock_path("notify.tdb"),
-				       0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
+				       0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 				       O_RDWR|O_CREAT, 0644);
 	if (notify->db_recursive == NULL) {
 		talloc_free(notify);
@@ -103,7 +103,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
 	}
 
 	notify->db_onelevel = db_open(notify, lock_path("notify_onelevel.tdb"),
-				      0, TDB_CLEAR_IF_FIRST,
+				      0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 				      O_RDWR|O_CREAT, 0644);
 	if (notify->db_onelevel == NULL) {
 		talloc_free(notify);
@@ -145,14 +145,14 @@ bool notify_internal_parent_init(TALLOC_CTX *mem_ctx)
 	 */
 
 	db1 = tdb_wrap_open(mem_ctx, lock_path("notify.tdb"),
-			    0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
+			    0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
 			   O_RDWR|O_CREAT, 0644);
 	if (db1 == NULL) {
 		DEBUG(1, ("could not open notify.tdb: %s\n", strerror(errno)));
 		return false;
 	}
 	db2 = tdb_wrap_open(mem_ctx, lock_path("notify_onelevel.tdb"),
-			    0, TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0644);
+			    0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
 	if (db2 == NULL) {
 		DEBUG(1, ("could not open notify_onelevel.tdb: %s\n",
 			  strerror(errno)));
diff --git a/source3/utils/dbwrap_torture.c b/source3/utils/dbwrap_torture.c
index 1fdad0e..2d9761b 100644
--- a/source3/utils/dbwrap_torture.c
+++ b/source3/utils/dbwrap_torture.c
@@ -302,7 +302,7 @@ int main(int argc, const char *argv[])
 	}
 
 	if (no_trans) {
-		tdb_flags |= TDB_CLEAR_IF_FIRST;
+		tdb_flags |= TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH;
 	}
 
 	db = db_open(mem_ctx, db_name, 0, tdb_flags,  O_RDWR | O_CREAT, 0644);
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 7b5f8aa..f8b359d 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -918,7 +918,8 @@ static bool do_winbind_offline(struct messaging_context *msg_ctx,
 
 	tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
 				WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
-				TDB_DEFAULT /* TDB_CLEAR_IF_FIRST */, O_RDWR|O_CREAT, 0600);
+				TDB_DEFAULT|TDB_INCOMPATIBLE_HASH /* TDB_CLEAR_IF_FIRST */,
+				O_RDWR|O_CREAT, 0600);
 
 	if (!tdb) {
 		fprintf(stderr, "Cannot open the tdb %s for writing.\n",
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 1259523..053efab 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -449,7 +449,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
 		int result;
 		struct db_context *db;
 		db = db_open(NULL, lock_path("locking.tdb"), 0,
-			     TDB_CLEAR_IF_FIRST, O_RDONLY, 0);
+			     TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0);
 
 		if (!db) {
 			d_printf("%s not initialised\n",
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index f7ab726..8131746 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -3072,7 +3072,8 @@ bool init_wcache(void)
 	/* when working offline we must not clear the cache on restart */
 	wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
 				WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 
-				lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST), 
+				TDB_INCOMPATIBLE_HASH |
+					(lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST)),
 				O_RDWR|O_CREAT, 0600);
 
 	if (wcache->tdb == NULL) {
@@ -3244,7 +3245,8 @@ void wcache_flush_cache(void)
 	/* when working offline we must not clear the cache on restart */
 	wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
 				WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 
-				lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST), 
+				TDB_INCOMPATIBLE_HASH |
+				(lp_winbind_offline_logon() ? TDB_DEFAULT : (TDB_DEFAULT | TDB_CLEAR_IF_FIRST)),
 				O_RDWR|O_CREAT, 0600);
 
 	if (!wcache->tdb) {
@@ -4062,6 +4064,7 @@ int winbindd_validate_cache(void)
 
 	tdb = tdb_open_log(tdb_path, 
 			   WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
+			   TDB_INCOMPATIBLE_HASH |
 			   ( lp_winbind_offline_logon() 
 			     ? TDB_DEFAULT 
 			     : TDB_DEFAULT | TDB_CLEAR_IF_FIRST ),


-- 
Samba Shared Repository


More information about the samba-cvs mailing list