kdc_entry can be hdb_entry or krb5_db_entry.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
static int samba_kdc_entry_destructor(struct samba_kdc_entry *p)
{
+ if (p->db_entry != NULL) {
+ /*
+ * A sdb_entry still has a reference
+ */
+ return -1;
+ }
+
+ if (p->kdc_entry != NULL) {
+ /*
+ * hdb_entry or krb5_db_entry still
+ * have a reference...
+ */
+ return -1;
+ }
+
return 0;
}
* 'context' set, so we have to check that the context is not NULL.
*/
if (entry->context != NULL) {
+ struct samba_kdc_entry *skdc_entry =
+ talloc_get_type_abort(entry->context,
+ struct samba_kdc_entry);
+
/* this function is called only from hdb_free_entry().
* Make sure we neutralize the destructor or we will
* get a double free later when hdb_free_entry() will
* try to call free_hdb_entry() */
- talloc_set_destructor(entry->context, NULL);
-
- /* now proceed to free the talloc part */
- talloc_free(entry->context);
+ entry->context = NULL;
+ skdc_entry->kdc_entry = NULL;
+ TALLOC_FREE(skdc_entry);
}
}
#include <profile.h>
#include <kdb.h>
+#include "kdc/samba_kdc.h"
#include "kdc/mit_samba.h"
#include "kdb_samba.h"
skdc_entry = talloc_get_type_abort(e_data,
struct samba_kdc_entry);
- talloc_set_destructor(skdc_entry, NULL);
+ skdc_entry->kdc_entry = NULL;
TALLOC_FREE(skdc_entry);
}
#include <profile.h>
#include <kdb.h>
+#include "kdc/samba_kdc.h"
#include "kdc/mit_samba.h"
#include "kdb_samba.h"
skdc_entry = talloc_get_type_abort(e_data,
struct samba_kdc_entry);
- talloc_set_destructor(skdc_entry, NULL);
+ skdc_entry->kdc_entry = NULL;
TALLOC_FREE(skdc_entry);
}
struct samba_kdc_entry {
struct samba_kdc_db_context *kdc_db_ctx;
+ const struct sdb_entry *db_entry; /* this is only temporary valid */
+ const void *kdc_entry; /* this is a reference to hdb_entry/krb5_db_entry */
struct ldb_message *msg;
struct ldb_dn *realm_dn;
struct auth_user_info_dc *user_info_dc;
#include "includes.h"
#include "system/kerberos.h"
#include "sdb.h"
+#include "samba_kdc.h"
#include "lib/krb5_wrap/krb5_samba.h"
static void free_sdb_entry(struct sdb_entry *s);
static void free_sdb_entry(struct sdb_entry *s)
{
+ if (s->skdc_entry != NULL) {
+ s->skdc_entry->db_entry = NULL;
+ TALLOC_FREE(s->skdc_entry);
+ }
+
/*
* Passing NULL as the Kerberos context is intentional here, as both
* Heimdal and MIT libraries don't use the context when clearing the
}
h->context = ske;
+ if (ske != NULL) {
+ ske->kdc_entry = h;
+ }
return 0;
error:
free_hdb_entry(h);
}
k->e_data = (void *)ske;
+ if (ske != NULL) {
+ ske->kdc_entry = k;
+ }
return 0;
}