diff options
author | Günther Deschner <gd@samba.org> | 2014-05-08 17:13:04 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-07-30 13:29:27 +0200 |
commit | d49b4aafa81d121e9122f84b0e66fb566d70c3e9 (patch) | |
tree | 5a4a5315e2777492109e8128905fd3d20db3543d /source4/kdc/hdb-samba4.c | |
parent | 99d3719e7d3073989442cffe635c3ac7a0bc200c (diff) | |
download | samba-d49b4aafa81d121e9122f84b0e66fb566d70c3e9.tar.gz |
s4-kdc: Use sdb in db-glue and hdb-samba4
Guenther
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Guenther Deschner <gd@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jul 30 13:29:27 CEST 2015 on sn-devel-104
Diffstat (limited to 'source4/kdc/hdb-samba4.c')
-rw-r--r-- | source4/kdc/hdb-samba4.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c index 77f6a9079dd..c8f26e03c18 100644 --- a/source4/kdc/hdb-samba4.c +++ b/source4/kdc/hdb-samba4.c @@ -37,6 +37,8 @@ #include "kdc/db-glue.h" #include "auth/auth_sam.h" #include <ldb.h> +#include "sdb.h" +#include "sdb_hdb.h" static krb5_error_code hdb_samba4_open(krb5_context context, HDB *db, int flags, mode_t mode) { @@ -87,33 +89,74 @@ static krb5_error_code hdb_samba4_fetch_kvno(krb5_context context, HDB *db, hdb_entry_ex *entry_ex) { struct samba_kdc_db_context *kdc_db_ctx; + struct sdb_entry_ex sdb_entry_ex = {}; + krb5_error_code code, ret; kdc_db_ctx = talloc_get_type_abort(db->hdb_db, struct samba_kdc_db_context); - return samba_kdc_fetch(context, kdc_db_ctx, principal, flags, kvno, entry_ex); + code = samba_kdc_fetch(context, + kdc_db_ctx, + principal, + flags, + kvno, + &sdb_entry_ex); + /* + * If SDB_ERR_WRONG_REALM is returned we need to process the sdb_entry + * to fill the principal in the HDB entry. + */ + if (code != 0 && code != SDB_ERR_WRONG_REALM) { + return code; + } + + ret = sdb_entry_ex_to_hdb_entry_ex(context, &sdb_entry_ex, entry_ex); + sdb_free_entry(&sdb_entry_ex); + + if (code == 0 && ret != 0) { + code = ret; + } + + return code; } static krb5_error_code hdb_samba4_firstkey(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry) { struct samba_kdc_db_context *kdc_db_ctx; + struct sdb_entry_ex sdb_entry_ex = {}; + krb5_error_code ret; kdc_db_ctx = talloc_get_type_abort(db->hdb_db, struct samba_kdc_db_context); - return samba_kdc_firstkey(context, kdc_db_ctx, entry); + ret = samba_kdc_firstkey(context, kdc_db_ctx, &sdb_entry_ex); + if (ret) { + return ret; + } + + ret = sdb_entry_ex_to_hdb_entry_ex(context, &sdb_entry_ex, entry); + sdb_free_entry(&sdb_entry_ex); + return ret; } static krb5_error_code hdb_samba4_nextkey(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry) { struct samba_kdc_db_context *kdc_db_ctx; + struct sdb_entry_ex sdb_entry_ex = {}; + krb5_error_code ret; kdc_db_ctx = talloc_get_type_abort(db->hdb_db, struct samba_kdc_db_context); - return samba_kdc_nextkey(context, kdc_db_ctx, entry); + ret = samba_kdc_nextkey(context, kdc_db_ctx, &sdb_entry_ex); + if (ret) { + return ret; + } + + ret = sdb_entry_ex_to_hdb_entry_ex(context, &sdb_entry_ex, entry); + sdb_free_entry(&sdb_entry_ex); + return ret; } static krb5_error_code hdb_samba4_destroy(krb5_context context, HDB *db) |