mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
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.
This commit is contained in:
parent
6676142347
commit
f98d217514
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"));
|
||||
|
@ -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()) {
|
||||
/*
|
||||
|
@ -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) {
|
||||
|
@ -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) ));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)));
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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 ),
|
||||
|
Loading…
x
Reference in New Issue
Block a user