summaryrefslogtreecommitdiff
path: root/source4/passdb/secrets.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-16 13:47:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:56 -0500
commit12ea0fd34cec2d7b6d8c8374dfd95728112585b3 (patch)
tree108bca68e9642ac4bb301a9f74e8e73d09c08abc /source4/passdb/secrets.c
parent645067efc69ff510612f7b63cf262cc9d60df700 (diff)
downloadsamba-12ea0fd34cec2d7b6d8c8374dfd95728112585b3.tar.gz
samba-12ea0fd34cec2d7b6d8c8374dfd95728112585b3.tar.bz2
samba-12ea0fd34cec2d7b6d8c8374dfd95728112585b3.zip
r3005: added talloc wrappers around tdb_open() and ldb_connect(), so that the
caller doesn't have to worry about the constraint of only opening a database a single time in a process. These wrappers will ensure that only a single open is done, and will auto-close when the last instance is gone. When you are finished with a database pointer, use talloc_free() to close it. note that this code does not take account of the threads process model, and does not yet take account of symlinks or hard links to tdb files. (This used to be commit 04e1171996612ddb15f84134cadded68f0d173b2)
Diffstat (limited to 'source4/passdb/secrets.c')
-rw-r--r--source4/passdb/secrets.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source4/passdb/secrets.c b/source4/passdb/secrets.c
index 21938db154..60b197de93 100644
--- a/source4/passdb/secrets.c
+++ b/source4/passdb/secrets.c
@@ -27,7 +27,7 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
-static TDB_CONTEXT *tdb;
+static struct tdb_wrap *tdb;
/**
* Use a TDB to store an incrementing random seed.
@@ -41,7 +41,7 @@ static void get_rand_seed(int *new_seed)
{
*new_seed = getpid();
if (tdb) {
- tdb_change_int32_atomic(tdb, "INFO/random_seed", new_seed, 1);
+ tdb_change_int32_atomic(tdb->tdb, "INFO/random_seed", new_seed, 1);
}
}
@@ -57,7 +57,7 @@ BOOL secrets_init(void)
pstrcpy(fname, lp_private_dir());
pstrcat(fname,"/secrets.tdb");
- tdb = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ tdb = tdb_wrap_open(NULL, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open %s\n", fname));
@@ -89,7 +89,7 @@ static void *secrets_fetch(const char *key, size_t *size)
return NULL;
kbuf.dptr = strdup(key);
kbuf.dsize = strlen(key);
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch(tdb->tdb, kbuf);
if (size)
*size = dbuf.dsize;
free(kbuf.dptr);
@@ -127,7 +127,7 @@ BOOL secrets_named_mutex(const char *name, uint_t timeout, size_t *p_ref_count)
return False;
if (ref_count == 0) {
- ret = tdb_lock_bystring(tdb, name, timeout);
+ ret = tdb_lock_bystring(tdb->tdb, name, timeout);
if (ret == 0)
DEBUG(10,("secrets_named_mutex: got mutex for %s\n", name ));
}
@@ -150,7 +150,7 @@ void secrets_named_mutex_release(const char *name, size_t *p_ref_count)
SMB_ASSERT(ref_count != 0);
if (ref_count == 1) {
- tdb_unlock_bystring(tdb, name);
+ tdb_unlock_bystring(tdb->tdb, name);
DEBUG(10,("secrets_named_mutex: released mutex for %s\n", name ));
}