From ea3b0febab5dc24619de48e5c858775f660e9b1e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Oct 2010 12:37:51 +0200 Subject: [PATCH] s3: use TDB_INCOMPATIBLE_HASH (the jenkins hash) on all TDB_CLEAR_IF_FIRST tdb's. In the backport we only use TDB_INCOMPATIBLE_HASH if CLEAR_IF_FIRST was also set, that should make downgrades easier to handle. (similar to commit f98d217514433cd06887f8c0217a7835392f0375) metze --- source3/lib/conn_tdb.c | 4 ++-- source3/lib/g_lock.c | 2 +- source3/lib/gencache.c | 2 +- source3/lib/messages_local.c | 4 ++-- source3/lib/serverid.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/smbd/notify_internal.c | 8 ++++---- source3/smbd/session.c | 2 +- source3/utils/dbwrap_torture.c | 2 +- source3/utils/net_serverid.c | 2 +- source3/utils/net_status.c | 4 ++-- source3/utils/status.c | 4 ++-- source3/winbindd/winbindd_cache.c | 10 +++++++--- 17 files changed, 32 insertions(+), 27 deletions(-) diff --git a/source3/lib/conn_tdb.c b/source3/lib/conn_tdb.c index 6732529c0c..dcf74d1c74 100644 --- a/source3/lib/conn_tdb.c +++ b/source3/lib/conn_tdb.c @@ -29,12 +29,12 @@ static struct db_context *connections_db_ctx(bool rw) if (rw) { db_ctx = db_open(NULL, lock_path("connections.tdb"), 0, - TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, O_RDWR | O_CREAT, 0644); } else { db_ctx = db_open(NULL, lock_path("connections.tdb"), 0, - TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDONLY, 0); + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, O_RDONLY, 0); } return db_ctx; diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index cf1bab76cb..b6cd7aadb9 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -51,7 +51,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 004fea1a28..241908a851 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -82,7 +82,7 @@ static bool gencache_init(void) 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 b7c301e4a5..4b8dc3f3cf 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, + 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, O_RDWR|O_CREAT,0600); if (!ctx->tdb) { @@ -148,7 +148,7 @@ bool messaging_tdb_parent_init(void) db = tdb_wrap_open(talloc_autofree_context(), lock_path("messages.tdb"), 0, - TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE, + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT|TDB_VOLATILE, 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 b848edf595..a174774a2d 100644 --- a/source3/lib/serverid.c +++ b/source3/lib/serverid.c @@ -39,7 +39,7 @@ bool serverid_parent_init(void) db = tdb_wrap_open(talloc_autofree_context(), 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(talloc_autofree_context(), lock_path("serverid.tdb"), - 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0644); + 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644); return db; } diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c index 177e0114b3..9f985501b6 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 d123e24aa8..6dee594ed8 100644 --- a/source3/libsmb/unexpected.c +++ b/source3/libsmb/unexpected.c @@ -46,7 +46,7 @@ void unexpected_packet(struct packet_struct *p) if (!tdbd) { tdbd = tdb_open_log(lock_path("unexpected.tdb"), 0, - TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, 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 beb0850a3a..55925a315e 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -269,7 +269,7 @@ void brl_init(bool read_only) } brlock_db = db_open(NULL, lock_path("brlock.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 (!brlock_db) { DEBUG(0,("Failed to open byte range locking database %s\n", diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 33400fc5d0..7096604bf4 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -427,7 +427,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 0a5b1c8764..624e561764 100644 --- a/source3/nmbd/nmbd_winsserver.c +++ b/source3/nmbd/nmbd_winsserver.c @@ -583,7 +583,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/smbd/notify_internal.c b/source3/smbd/notify_internal.c index c8f8616d8b..ecf15b67ef 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -93,7 +93,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); @@ -101,7 +101,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); @@ -143,7 +143,7 @@ bool notify_internal_parent_init(void) */ db1 = tdb_wrap_open(talloc_autofree_context(), 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))); @@ -151,7 +151,7 @@ bool notify_internal_parent_init(void) } db2 = tdb_wrap_open(talloc_autofree_context(), 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/smbd/session.c b/source3/smbd/session.c index ebfffb7d57..f5acdae8e1 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -38,7 +38,7 @@ static struct db_context *session_db_ctx(void) return session_db_ctx_ptr; session_db_ctx_ptr = db_open(NULL, lock_path("sessionid.tdb"), 0, - TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, O_RDWR | O_CREAT, 0644); return session_db_ctx_ptr; } diff --git a/source3/utils/dbwrap_torture.c b/source3/utils/dbwrap_torture.c index 24fdebea85..5005743d49 100644 --- a/source3/utils/dbwrap_torture.c +++ b/source3/utils/dbwrap_torture.c @@ -300,7 +300,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/net_serverid.c b/source3/utils/net_serverid.c index a549125856..d625c519e2 100644 --- a/source3/utils/net_serverid.c +++ b/source3/utils/net_serverid.c @@ -125,7 +125,7 @@ static int net_serverid_wipedbs(struct net_context *c, int argc, connections_forall(net_serverid_wipedbs_conn, NULL); db = db_open(NULL, lock_path("sessionid.tdb"), 0, - TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0644); if (db == NULL) { d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); return -1; diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c index 4e4debda5e..48b5b61db8 100644 --- a/source3/utils/net_status.c +++ b/source3/utils/net_status.c @@ -87,7 +87,7 @@ static int net_status_sessions(struct net_context *c, int argc, const char **arg } db = db_open(NULL, lock_path("sessionid.tdb"), 0, - TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0644); if (db == NULL) { d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); return -1; @@ -192,7 +192,7 @@ static int net_status_shares_parseable(struct net_context *c, int argc, const ch ids.entries = NULL; db = db_open(NULL, lock_path("sessionid.tdb"), 0, - TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0644); if (db == NULL) { d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); return -1; diff --git a/source3/utils/status.c b/source3/utils/status.c index 9491076b22..fc26573bd4 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -403,7 +403,7 @@ static int traverse_sessionid(struct db_record *db, void *state) if ( show_processes ) { struct db_context *db; db = db_open(NULL, lock_path("sessionid.tdb"), 0, - TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); + TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0644); if (!db) { d_printf("sessionid.tdb not initialised\n"); } else { @@ -449,7 +449,7 @@ static int traverse_sessionid(struct db_record *db, void *state) 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 141ceb1b5e..28f6b57c0c 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -2539,7 +2539,9 @@ 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), + ( lp_winbind_offline_logon() + ? TDB_DEFAULT + : TDB_DEFAULT | TDB_CLEAR_IF_FIRST | TDB_INCOMPATIBLE_HASH ), O_RDWR|O_CREAT, 0600); if (wcache->tdb == NULL) { @@ -2867,7 +2869,9 @@ 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), + ( lp_winbind_offline_logon() + ? TDB_DEFAULT + : TDB_DEFAULT | TDB_CLEAR_IF_FIRST | TDB_INCOMPATIBLE_HASH ), O_RDWR|O_CREAT, 0600); if (!wcache->tdb) { @@ -3705,7 +3709,7 @@ int winbindd_validate_cache(void) WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, ( lp_winbind_offline_logon() ? TDB_DEFAULT - : TDB_DEFAULT | TDB_CLEAR_IF_FIRST ), + : TDB_DEFAULT | TDB_CLEAR_IF_FIRST | TDB_INCOMPATIBLE_HASH ), O_RDWR|O_CREAT, 0600); if (!tdb) { -- 2.34.1