s3: use TDB_INCOMPATIBLE_HASH (the jenkins hash) on all TDB_CLEAR_IF_FIRST tdb's.
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Oct 2010 10:37:51 +0000 (12:37 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 21 Oct 2010 12:26:03 +0000 (14:26 +0200)
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

17 files changed:
source3/lib/conn_tdb.c
source3/lib/g_lock.c
source3/lib/gencache.c
source3/lib/messages_local.c
source3/lib/serverid.c
source3/libsmb/smb_share_modes.c
source3/libsmb/unexpected.c
source3/locking/brlock.c
source3/locking/locking.c
source3/nmbd/nmbd_winsserver.c
source3/smbd/notify_internal.c
source3/smbd/session.c
source3/utils/dbwrap_torture.c
source3/utils/net_serverid.c
source3/utils/net_status.c
source3/utils/status.c
source3/winbindd/winbindd_cache.c

index 6732529c0c50a1041a3ca05763cf47744db3693f..dcf74d1c746caa8dc9c6505edf8bd5bd1e568634 100644 (file)
@@ -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;
index cf1bab76cb0b7c5a0eb6d6fd8efad298e9df3c12..b6cd7aadb94f7756da0718db2a844ce018170fd4 100644 (file)
@@ -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);
index 004fea1a28a80e81dc429707c08d3a7376af541f..241908a8515072e9785443e8a91b0e96f077339f 100644 (file)
@@ -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,
index b7c301e4a5858d50eaf621733ac55ea9a6ecb9a8..4b8dc3f3cfb310b7c409d5557d009381bb9f40d1 100644 (file)
@@ -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",
index b848edf5956ea748133cd3c4cba2f3fba749473b..a174774a2d907366366aa136b411bbc093609b10 100644 (file)
@@ -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;
 }
 
index 177e0114b3de25d5011bd61e7f1accf31edce1f0..9f985501b6f930d2573616fb9ef7b3018fe74d30 100644 (file)
@@ -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);
 
index d123e24aa8ec6cabab9ed3083296e4073d23fffd..6dee594ed86ad51d0533263fe235253bda106825 100644 (file)
@@ -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"));
index beb0850a3a77bc637928ece5e344f3c0c95abf37..55925a315e6a241b218e1db541569eb8215da813 100644 (file)
@@ -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",
index 33400fc5d0e3b5e4f0b84533d89777fde337055b..7096604bf41f8820d3b178d30a09b9aca40fbf6a 100644 (file)
@@ -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) {
index 0a5b1c876477150360f595de1ea08a5f73f03b2c..624e561764ab1faeb4f4302c154dda8d161e625c 100644 (file)
@@ -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) ));
index c8f8616d8b469a85a301bd2f25074c8631a82af7..ecf15b67ef269a7adedbdca5127fc36fd999fa57 100644 (file)
@@ -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)));
index ebfffb7d57ead87d83843ff787d8088c406f1dc3..f5acdae8e15d9de4e66b91623b3f278c62d5b457 100644 (file)
@@ -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;
 }
index 24fdebea85442609077238d0fb8f39d327d75a89..5005743d490a6397a1e594e870da5363ccb08592 100644 (file)
@@ -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);
index a549125856ebcd8d131add8fa7ee2a5409c47343..d625c519e25ce388d8637ca34d814245405c5c52 100644 (file)
@@ -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;
index 4e4debda5eb64412a2f482e68410b161ec90cb8a..48b5b61db8c0ce310405041103fc6340ef5a3afd 100644 (file)
@@ -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;
index 9491076b22e969845968595c28e4e0c3719ef675..fc26573bd4d7310c398f96c719129bb6394de11a 100644 (file)
@@ -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",
index 141ceb1b5ec6b32cbbe39f5e1e93029d1248db69..28f6b57c0c2a14aa0eecdd7eecbb77ec8eb7331f 100644 (file)
@@ -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) {