diff options
author | Günther Deschner <gd@samba.org> | 2008-02-08 23:12:53 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-02-09 02:05:39 +0100 |
commit | 7ec5bfc49f912b9908d6d73eb541b5a5748f8f83 (patch) | |
tree | 5279da5db988dffd14acc851ed43ea629c419a9e /source3 | |
parent | ebec5010b48f3de6eaf98ce2395e512a2e0258d5 (diff) | |
download | samba-7ec5bfc49f912b9908d6d73eb541b5a5748f8f83.tar.gz samba-7ec5bfc49f912b9908d6d73eb541b5a5748f8f83.tar.bz2 samba-7ec5bfc49f912b9908d6d73eb541b5a5748f8f83.zip |
More paranoid checks for secrets_init() success.
Guenther
(This used to be commit 5e60852bae61be72dee9d5b93c59ac900aba73ae)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/passdb/secrets.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 330ffbc853..6c5375e7de 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -113,12 +113,20 @@ void secrets_shutdown(void) void *secrets_fetch(const char *key, size_t *size) { TDB_DATA dbuf; - secrets_init(); - if (!tdb) + + if (!secrets_init()) { return NULL; + } + + if (!tdb) { + return NULL; + } + dbuf = tdb_fetch(tdb, string_tdb_data(key)); - if (size) + if (size) { *size = dbuf.dsize; + } + return dbuf.dptr; } @@ -126,9 +134,14 @@ void *secrets_fetch(const char *key, size_t *size) */ bool secrets_store(const char *key, const void *data, size_t size) { - secrets_init(); - if (!tdb) - return False; + if (!secrets_init()) { + return false; + } + + if (!tdb) { + return false; + } + return tdb_trans_store(tdb, string_tdb_data(key), make_tdb_data((const uint8 *)data, size), TDB_REPLACE) == 0; @@ -139,9 +152,14 @@ bool secrets_store(const char *key, const void *data, size_t size) */ bool secrets_delete(const char *key) { - secrets_init(); - if (!tdb) - return False; + if (!secrets_init()) { + return false; + } + + if (!tdb) { + return false; + } + return tdb_trans_delete(tdb, string_tdb_data(key)) == 0; } @@ -923,7 +941,9 @@ NTSTATUS secrets_trusted_domains(TALLOC_CTX *mem_ctx, uint32 *num_domains, return NT_STATUS_NO_MEMORY; } - if (!secrets_init()) return NT_STATUS_ACCESS_DENIED; + if (!secrets_init()) { + return NT_STATUS_ACCESS_DENIED; + } /* generate searching pattern */ pattern = talloc_asprintf(tmp_ctx, "%s/*", SECRETS_DOMTRUST_ACCT_PASS); @@ -1034,12 +1054,14 @@ bool secrets_named_mutex(const char *name, unsigned int timeout) { int ret = 0; - if (!secrets_init()) - return False; + if (!secrets_init()) { + return false; + } ret = tdb_lock_bystring_with_timeout(tdb, name, timeout); - if (ret == 0) + if (ret == 0) { DEBUG(10,("secrets_named_mutex: got mutex for %s\n", name )); + } return (ret == 0); } |