diff options
author | Jeremy Allison <jra@samba.org> | 2010-09-27 05:46:07 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-09-27 17:18:54 -0700 |
commit | f98d217514433cd06887f8c0217a7835392f0375 (patch) | |
tree | c7bf61f24c3381c9f7996a0a19045d36af3f0783 /source3 | |
parent | 66761423474edc9736a8a6eae6feaaf958d89d0e (diff) | |
download | samba-f98d217514433cd06887f8c0217a7835392f0375.tar.gz samba-f98d217514433cd06887f8c0217a7835392f0375.tar.bz2 samba-f98d217514433cd06887f8c0217a7835392f0375.zip |
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.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/conn_tdb.c | 2 | ||||
-rw-r--r-- | source3/lib/g_lock.c | 2 | ||||
-rw-r--r-- | source3/lib/gencache.c | 8 | ||||
-rw-r--r-- | source3/lib/messages_local.c | 4 | ||||
-rw-r--r-- | source3/lib/serverid.c | 4 | ||||
-rw-r--r-- | source3/lib/sessionid_tdb.c | 2 | ||||
-rw-r--r-- | source3/libsmb/samlogon_cache.c | 4 | ||||
-rw-r--r-- | source3/libsmb/smb_share_modes.c | 2 | ||||
-rw-r--r-- | source3/libsmb/unexpected.c | 2 | ||||
-rw-r--r-- | source3/locking/brlock.c | 2 | ||||
-rw-r--r-- | source3/locking/locking.c | 2 | ||||
-rw-r--r-- | source3/nmbd/nmbd_winsserver.c | 3 | ||||
-rw-r--r-- | source3/printing/printer_list.c | 2 | ||||
-rw-r--r-- | source3/smbd/notify_internal.c | 8 | ||||
-rw-r--r-- | source3/utils/dbwrap_torture.c | 2 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 3 | ||||
-rw-r--r-- | source3/utils/status.c | 2 | ||||
-rw-r--r-- | source3/winbindd/winbindd_cache.c | 7 |
18 files changed, 33 insertions, 28 deletions
diff --git a/source3/lib/conn_tdb.c b/source3/lib/conn_tdb.c index 75841cce65..e4c5e72014 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 edb77869cc..2c065029e7 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 a78e60a153..8d2ddb2387 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 542d49e2dd..bad577cc35 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 f0c61aeb82..dd02e51a21 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 1515728bd9..fe67681d18 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 7f096ece76..45354f1c77 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 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 1ac45ec84b..17ebcd22ab 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 408917ef2e..3cb94871cc 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 89bd19a710..ed07d7a25a 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 5f3a9c39bf..d4580e41c5 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 f52dfcffa5..667ff70a05 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 1dc10bbab5..acb438b118 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 1fdad0eb29..2d9761bac4 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 7b5f8aaa55..f8b359d99f 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 12595236e7..053efab592 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 f7ab726e49..81317464ef 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 ), |