Add get_string, free_string kdcpreauth callbacks
authorGreg Hudson <ghudson@mit.edu>
Thu, 6 Oct 2011 20:08:29 +0000 (20:08 +0000)
committerGreg Hudson <ghudson@mit.edu>
Thu, 6 Oct 2011 20:08:29 +0000 (20:08 +0000)
String attributes should be useful to preauth modules without having
to link against libkdb5.  Add a callback to make client string
attributes accessible to modules.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25318 dc483132-0cff-0310-8789-dd5450dbe970

src/include/krb5/preauth_plugin.h
src/kdc/kdc_preauth.c

index 1646263d9f55c294e1ed096d29659437d54d520f..e4f9de2e7591d542d3857f622fa11ae190165605 100644 (file)
@@ -355,6 +355,16 @@ typedef struct krb5_kdcpreauth_callbacks_st {
     krb5_keyblock *(*fast_armor)(krb5_context context,
                                  krb5_kdcpreauth_rock rock);
 
+    /* Retrieve a string attribute from the client DB entry, or NULL if no such
+     * attribute is set.  Free the result with the free_string callback. */
+    krb5_error_code (*get_string)(krb5_context context,
+                                  krb5_kdcpreauth_rock rock, const char *key,
+                                  char **value_out);
+
+    /* Free the result of get_string. */
+    void (*free_string)(krb5_context context, krb5_kdcpreauth_rock rock,
+                        char *string);
+
     /* Get a pointer to the client DB entry (returned as a void pointer to
      * avoid a dependency on a libkdb5 type). */
     void *(*client_entry)(krb5_context context, krb5_kdcpreauth_rock rock);
index 7e9cde1f9e1c905ba1436aea1b3f7f746713fee3..6a04ff2aa7b6c5c850e33f809543e4ca99fd508e 100644 (file)
@@ -574,6 +574,19 @@ fast_armor(krb5_context context, krb5_kdcpreauth_rock rock)
     return rock->rstate->armor_key;
 }
 
+static krb5_error_code
+get_string(krb5_context context, krb5_kdcpreauth_rock rock, const char *key,
+           char **value_out)
+{
+    return krb5_dbe_get_string(context, rock->client, key, value_out);
+}
+
+static void
+free_string(krb5_context context, krb5_kdcpreauth_rock rock, char *string)
+{
+    krb5_dbe_free_string(context, string);
+}
+
 static void *
 client_entry(krb5_context context, krb5_kdcpreauth_rock rock)
 {
@@ -587,6 +600,8 @@ static struct krb5_kdcpreauth_callbacks_st callbacks = {
     free_keys,
     request_body,
     fast_armor,
+    get_string,
+    free_string,
     client_entry
 };