From d634ab06b34990b6eecee751435f2436ff76ec44 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Mar 2008 15:48:04 +0100 Subject: Convert secrets_lock_trust_account_password to talloc This is preparing the conversion of secrets.c to ctdb (This used to be commit 1307f0130c47b8d740d2b7afe7a5d8d1a655e2a2) --- source3/passdb/secrets.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'source3/passdb/secrets.c') diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 2ef8f43988..2c0d648716 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -325,20 +325,36 @@ static char *trustdom_keystr(const char *domain) return keystr; } +static int unlock_trust_account(char *domain) +{ + tdb_unlock_bystring(tdb, trust_keystr(domain)); + return 0; +} + /************************************************************************ Lock the trust password entry. ************************************************************************/ -bool secrets_lock_trust_account_password(const char *domain, bool dolock) +void *secrets_get_trust_account_lock(TALLOC_CTX *mem_ctx, const char *domain) { - if (!tdb) - return False; + char *result; - if (dolock) - return (tdb_lock_bystring(tdb, trust_keystr(domain)) == 0); - else - tdb_unlock_bystring(tdb, trust_keystr(domain)); - return True; + if (!secrets_init()) { + return NULL; + } + + result = talloc_strdup(mem_ctx, domain); + if (result == NULL) { + return NULL; + } + + if (tdb_lock_bystring(tdb, trust_keystr(domain)) != 0) { + TALLOC_FREE(result); + return NULL; + } + + talloc_set_destructor(result, unlock_trust_account); + return result; } /************************************************************************ -- cgit