1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

s3:lib: always use db_open(serverid.tdb)

We should not create an empty local serverid.tdb in a cluster setup...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Stefan Metzmacher 2014-05-12 10:21:12 +02:00
parent 360ca8e017
commit 74e2d6e786

View File

@ -39,41 +39,6 @@ struct serverid_data {
uint32_t msg_flags;
};
bool serverid_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
struct loadparm_context *lp_ctx;
const char *fname;
lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers());
if (lp_ctx == NULL) {
DEBUG(0, ("loadparm_init_s3 failed\n"));
return false;
}
/*
* Open the tdb in the parent process (smbd) so that our
* CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
* work.
*/
fname = lock_path("serverid.tdb");
db = tdb_wrap_open(mem_ctx, fname,
lpcfg_tdb_hash_size(lp_ctx, fname),
lpcfg_tdb_flags(lp_ctx,
TDB_DEFAULT|TDB_CLEAR_IF_FIRST|
TDB_INCOMPATIBLE_HASH),
O_RDWR|O_CREAT, 0644);
talloc_unlink(mem_ctx, lp_ctx);
if (db == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",
strerror(errno)));
return false;
}
return true;
}
static struct db_context *serverid_db(void)
{
static struct db_context *db;
@ -88,6 +53,20 @@ static struct db_context *serverid_db(void)
return db;
}
bool serverid_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
db = serverid_db();
if (db == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",
strerror(errno)));
return false;
}
return true;
}
static void serverid_fill_key(const struct server_id *id,
struct serverid_key *key)
{