From 13c1f1b6f14bf6459e4046f3ffa7d45897b317f5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 31 Jan 2006 03:15:16 +0000 Subject: r13252: Cleanup, both in code, comments and talloc use: In particular, I've used the --leak-report-full option to smbd to track down memory that shouldn't be on a long-term context. This is now talloc_free()ed much earlier. Andrew Bartlett (This used to be commit c6eb74f42989d62c82d2a219251837b09df8491c) --- source4/kdc/hdb-ldb.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'source4/kdc/hdb-ldb.c') diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index 86c1b048a7..0306bf3106 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -509,18 +509,11 @@ static krb5_error_code LDB_lookup_principal(krb5_context context, struct ldb_con realm_dn_str = ldb_dn_linearize(mem_ctx, realm_dn); - if (lret != LDB_SUCCESS || res->count == 0) { - krb5_warnx(context, "ldb_search: basedn: '%s' filter: '%s' failed: %s", - realm_dn_str, filter, ldb_errstring(ldb_ctx)); - krb5_set_error_string(context, "ldb_search: basedn: '%s' filter: '%s' failed: %s", - realm_dn_str, filter, ldb_errstring(ldb_ctx)); + if (lret != LDB_SUCCESS) { + DEBUG(3, ("Failed to search for %s: %s\n", filter, ldb_errstring(ldb_ctx))); return HDB_ERR_NOENTRY; - } else if (res->count > 1) { - krb5_warnx(context, "ldb_search: basedn: '%s' filter: '%s' more than 1 entry: %d", - realm_dn_str, filter, res->count); - krb5_set_error_string(context, "ldb_search: basedn: '%s' filter: '%s' more than 1 entry: %d", - realm_dn_str, filter, res->count); - talloc_free(res); + } else if (res->count == 0 || res->count > 1) { + DEBUG(3, ("Failed find a single entry for %s: got %d\n", filter, res->count)); return HDB_ERR_NOENTRY; } talloc_steal(mem_ctx, res->msgs); @@ -548,25 +541,21 @@ static krb5_error_code LDB_lookup_realm(krb5_context context, struct ldb_context ret = ldb_search(ldb_ctx, NULL, LDB_SCOPE_SUBTREE, cross_ref_filter, realm_ref_attrs, &cross_ref_res); - if (ret != LDB_SUCCESS || cross_ref_res->count == 0) { - krb5_warnx(context, "ldb_search: filter: '%s' failed: %s", cross_ref_filter, ldb_errstring(ldb_ctx)); - krb5_set_error_string(context, "ldb_search: filter: '%s' failed: %s", cross_ref_filter, ldb_errstring(ldb_ctx)); - + if (ret != LDB_SUCCESS) { + DEBUG(3, ("Failed to search for %s: %s\n", cross_ref_filter, ldb_errstring(ldb_ctx))); talloc_free(cross_ref_res); return HDB_ERR_NOENTRY; - } else if (cross_ref_res->count > 1) { - krb5_warnx(context, "ldb_search: filter: '%s' more than 1 entry: %d", cross_ref_filter, cross_ref_res->count); - krb5_set_error_string(context, "ldb_search: filter: '%s' more than 1 entry: %d", cross_ref_filter, cross_ref_res->count); - + } else if (cross_ref_res->count == 0 || cross_ref_res->count > 1) { + DEBUG(3, ("Failed find a single entry for %s: got %d\n", cross_ref_filter, cross_ref_res->count)); talloc_free(cross_ref_res); return HDB_ERR_NOENTRY; } if (pmsg) { - *pmsg = talloc_steal(mem_ctx, cross_ref_res->msgs); - } else { - talloc_free(cross_ref_res); + *pmsg = cross_ref_res->msgs; + talloc_steal(mem_ctx, cross_ref_res->msgs); } + talloc_free(cross_ref_res); return 0; } @@ -922,6 +911,7 @@ static krb5_error_code LDB_firstkey(krb5_context context, HDB *db, unsigned flag priv->count = res->count; priv->msgs = talloc_steal(priv, res->msgs); + talloc_free(res); db->hdb_openp = priv; @@ -958,7 +948,6 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx, { NTSTATUS nt_status; struct auth_session_info *session_info; - struct gensec_security_ops **not_kerberos_list; *db = talloc(mem_ctx, HDB); if (!*db) { krb5_set_error_string(context, "malloc: out of memory"); -- cgit