krb5/krb5-1.15-krb5_db_register_keytab.patch
2016-09-19 16:18:42 +00:00

70 lines
2.1 KiB
Diff

From c9136272512a6158d77e74035d52869443403a10 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Wed, 7 Sep 2016 18:33:43 +0200
Subject: [PATCH] Add krb5_db_register_keytab()
Add a public libkdb5 function to register the KDB keytab type. This
functionality is needed for out-of-tree KDC servers such as the Samba
kpasswd service.
[ghudson@mit.edu: edited comments, whitespace, commit message]
ticket: 8494 (new)
(cherry picked from commit 2e99582062d9d6a70f2adb00fd8fe58a1f95b9b7)
---
src/include/kdb.h | 7 +++++++
src/lib/kdb/keytab.c | 6 ++++++
src/lib/kdb/libkdb5.exports | 1 +
3 files changed, 14 insertions(+)
diff --git a/src/include/kdb.h b/src/include/kdb.h
index 9d3bf9d..048327c 100644
--- a/src/include/kdb.h
+++ b/src/include/kdb.h
@@ -797,6 +797,13 @@ krb5_dbe_free_strings(krb5_context, krb5_string_attr *, int count);
void
krb5_dbe_free_string(krb5_context, char *);
+/*
+ * Register the KDB keytab type, allowing "KDB:" to be used as a keytab name.
+ * For this type to work, the context used for keytab operations must have an
+ * associated database handle (via krb5_db_open()).
+ */
+krb5_error_code krb5_db_register_keytab(krb5_context context);
+
#define KRB5_KDB_DEF_FLAGS 0
#define KDB_MAX_DB_NAME 128
diff --git a/src/lib/kdb/keytab.c b/src/lib/kdb/keytab.c
index b85b67d..c6aa100 100644
--- a/src/lib/kdb/keytab.c
+++ b/src/lib/kdb/keytab.c
@@ -66,6 +66,12 @@ typedef struct krb5_ktkdb_data {
} krb5_ktkdb_data;
krb5_error_code
+krb5_db_register_keytab(krb5_context context)
+{
+ return krb5_kt_register(context, &krb5_kt_kdb_ops);
+}
+
+krb5_error_code
krb5_ktkdb_resolve(context, name, id)
krb5_context context;
const char * name;
diff --git a/src/lib/kdb/libkdb5.exports b/src/lib/kdb/libkdb5.exports
index cb4c3df..e5d1045 100644
--- a/src/lib/kdb/libkdb5.exports
+++ b/src/lib/kdb/libkdb5.exports
@@ -85,6 +85,7 @@ krb5_db_delete_policy
krb5_db_free_policy
krb5_def_store_mkey_list
krb5_db_promote
+krb5_db_register_keytab
ulog_add_update
ulog_init_header
ulog_map
--
2.9.3