summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/ccache/Makefile.in9
-rw-r--r--src/lib/krb5/ccache/cc-int.h8
-rw-r--r--src/lib/krb5/ccache/ccselect.c179
-rw-r--r--src/lib/krb5/ccache/ccselect_k5identity.c211
-rw-r--r--src/lib/krb5/ccache/ccselect_realm.c95
-rw-r--r--src/lib/krb5/ccache/deps57
-rw-r--r--src/lib/krb5/krb/init_ctx.c1
-rw-r--r--src/lib/krb5/krb/int-proto.h3
-rw-r--r--src/lib/krb5/libkrb5.exports2
-rw-r--r--src/lib/krb5_32.def1
10 files changed, 565 insertions, 1 deletions
diff --git a/src/lib/krb5/ccache/Makefile.in b/src/lib/krb5/ccache/Makefile.in
index 00aaae7d6a..a094151067 100644
--- a/src/lib/krb5/ccache/Makefile.in
+++ b/src/lib/krb5/ccache/Makefile.in
@@ -24,6 +24,9 @@ STLIBOBJS= \
cccursor.o \
ccdefault.o \
ccdefops.o \
+ ccselect.o \
+ ccselect_k5identity.o \
+ ccselect_realm.o \
cc_dir.o \
cc_retr.o \
cc_file.o \
@@ -37,6 +40,9 @@ OBJS= $(OUTPRE)ccbase.$(OBJEXT) \
$(OUTPRE)cccursor.$(OBJEXT) \
$(OUTPRE)ccdefault.$(OBJEXT) \
$(OUTPRE)ccdefops.$(OBJEXT) \
+ $(OUTPRE)ccselect.$(OBJEXT) \
+ $(OUTPRE)ccselect_k5identity.$(OBJEXT) \
+ $(OUTPRE)ccselect_realm.$(OBJEXT) \
$(OUTPRE)cc_dir.$(OBJEXT) \
$(OUTPRE)cc_retr.$(OBJEXT) \
$(OUTPRE)cc_file.$(OBJEXT) \
@@ -50,6 +56,9 @@ SRCS= $(srcdir)/ccbase.c \
$(srcdir)/cccursor.c \
$(srcdir)/ccdefault.c \
$(srcdir)/ccdefops.c \
+ $(srcdir)/ccselect.c \
+ $(srcdir)/ccselect_k5identity.c \
+ $(srcdir)/ccselect_realm.c \
$(srcdir)/cc_dir.c \
$(srcdir)/cc_retr.c \
$(srcdir)/cc_file.c \
diff --git a/src/lib/krb5/ccache/cc-int.h b/src/lib/krb5/ccache/cc-int.h
index aeb1447ce7..9c24f20cc8 100644
--- a/src/lib/krb5/ccache/cc-int.h
+++ b/src/lib/krb5/ccache/cc-int.h
@@ -115,4 +115,12 @@ k5_cccol_force_unlock(void);
krb5_error_code
krb5int_fcc_new_unique(krb5_context context, char *template, krb5_ccache *id);
+krb5_error_code
+ccselect_realm_initvt(krb5_context context, int maj_ver, int min_ver,
+ krb5_plugin_vtable vtable);
+
+krb5_error_code
+ccselect_k5identity_initvt(krb5_context context, int maj_ver, int min_ver,
+ krb5_plugin_vtable vtable);
+
#endif /* __KRB5_CCACHE_H__ */
diff --git a/src/lib/krb5/ccache/ccselect.c b/src/lib/krb5/ccache/ccselect.c
new file mode 100644
index 0000000000..235c0c6a46
--- /dev/null
+++ b/src/lib/krb5/ccache/ccselect.c
@@ -0,0 +1,179 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/* lib/krb5/ccache/ccselect.c - krb5_cc_select API and module loader */
+/*
+ * Copyright (C) 2011 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ */
+
+#include "k5-int.h"
+#include "cc-int.h"
+#include <krb5/ccselect_plugin.h>
+#include "../krb/int-proto.h"
+
+struct ccselect_module_handle {
+ struct krb5_ccselect_vtable_st vt;
+ krb5_ccselect_moddata data;
+ int priority;
+};
+
+static void
+free_handles(krb5_context context, struct ccselect_module_handle **handles)
+{
+ struct ccselect_module_handle *h, **hp;
+
+ if (handles == NULL)
+ return;
+ for (hp = handles; *hp != NULL; hp++) {
+ h = *hp;
+ if (h->vt.fini)
+ h->vt.fini(context, h->data);
+ free(h);
+ }
+ free(handles);
+}
+
+static krb5_error_code
+load_modules(krb5_context context)
+{
+ krb5_error_code ret;
+ struct ccselect_module_handle **list = NULL, *handle;
+ krb5_plugin_initvt_fn *modules = NULL, *mod;
+ size_t count;
+
+#ifndef _WIN32
+ ret = k5_plugin_register(context, PLUGIN_INTERFACE_CCSELECT, "k5identity",
+ ccselect_k5identity_initvt);
+ if (ret != 0)
+ goto cleanup;
+#endif
+
+ ret = k5_plugin_register(context, PLUGIN_INTERFACE_CCSELECT, "realm",
+ ccselect_realm_initvt);
+ if (ret != 0)
+ goto cleanup;
+
+ ret = k5_plugin_load_all(context, PLUGIN_INTERFACE_CCSELECT, &modules);
+ if (ret != 0)
+ goto cleanup;
+
+ /* Allocate a large enough list of handles. */
+ for (count = 0; modules[count] != NULL; count++);
+ list = k5alloc((count + 1) * sizeof(*list), &ret);
+ if (list == NULL)
+ goto cleanup;
+
+ /* Initialize each module, ignoring ones that fail. */
+ count = 0;
+ for (mod = modules; *mod != NULL; mod++) {
+ handle = k5alloc(sizeof(*handle), &ret);
+ if (handle == NULL)
+ goto cleanup;
+ ret = (*mod)(context, 1, 1, (krb5_plugin_vtable)&handle->vt);
+ if (ret != 0) { /* Failed vtable init is non-fatal. */
+ TRACE_CCSELECT_VTINIT_FAIL(context, ret);
+ free(handle);
+ continue;
+ }
+ handle->data = NULL;
+ ret = handle->vt.init(context, &handle->data, &handle->priority);
+ if (ret != 0) { /* Failed initialization is non-fatal. */
+ TRACE_CCSELECT_INIT_FAIL(context, handle->vt.name, ret);
+ free(handle);
+ continue;
+ }
+ list[count++] = handle;
+ list[count] = NULL;
+ }
+ list[count] = NULL;
+
+ ret = 0;
+ context->ccselect_handles = list;
+ list = NULL;
+
+cleanup:
+ k5_plugin_free_modules(context, modules);
+ free_handles(context, list);
+ return ret;
+}
+
+static krb5_error_code
+choose(krb5_context context, struct ccselect_module_handle *h,
+ krb5_principal server, krb5_ccache *cache_out,
+ krb5_principal *princ_out)
+{
+ return h->vt.choose(context, h->data, server, cache_out, princ_out);
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_cc_select(krb5_context context, krb5_principal server,
+ krb5_ccache *cache_out, krb5_principal *princ_out)
+{
+ krb5_error_code ret;
+ int priority;
+ struct ccselect_module_handle **hp, *h;
+ krb5_ccache cache;
+ krb5_principal princ;
+
+ *cache_out = NULL;
+ *princ_out = NULL;
+
+ if (context->ccselect_handles == NULL) {
+ ret = load_modules(context);
+ if (ret)
+ return ret;
+ }
+
+ /* Consult authoritative modules first, then heuristic ones. */
+ for (priority = KRB5_CCSELECT_PRIORITY_AUTHORITATIVE;
+ priority >= KRB5_CCSELECT_PRIORITY_HEURISTIC; priority--) {
+ for (hp = context->ccselect_handles; *hp != NULL; hp++) {
+ h = *hp;
+ if (h->priority != priority)
+ continue;
+ ret = choose(context, h, server, &cache, &princ);
+ if (ret == 0) {
+ TRACE_CCSELECT_MODCHOICE(context, h->vt.name, server, cache,
+ princ);
+ *cache_out = cache;
+ *princ_out = princ;
+ return 0;
+ } else if (ret == KRB5_CC_NOTFOUND) {
+ TRACE_CCSELECT_MODNOTFOUND(context, h->vt.name, server, princ);
+ *princ_out = princ;
+ return ret;
+ } else if (ret != KRB5_PLUGIN_NO_HANDLE) {
+ TRACE_CCSELECT_MODFAIL(context, h->vt.name, ret, server);
+ return ret;
+ }
+ }
+ }
+
+ TRACE_CCSELECT_NOTFOUND(context, server);
+ return KRB5_CC_NOTFOUND;
+}
+
+void
+k5_ccselect_free_context(krb5_context context)
+{
+ free_handles(context, context->ccselect_handles);
+ context->ccselect_handles = NULL;
+}
diff --git a/src/lib/krb5/ccache/ccselect_k5identity.c b/src/lib/krb5/ccache/ccselect_k5identity.c
new file mode 100644
index 0000000000..adf0fad269
--- /dev/null
+++ b/src/lib/krb5/ccache/ccselect_k5identity.c
@@ -0,0 +1,211 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/* lib/krb5/ccache/ccselect_k5identity.c - k5identity ccselect module */
+/*
+ * Copyright (C) 2011 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ */
+
+#include "k5-int.h"
+#include "cc-int.h"
+#include <krb5/ccselect_plugin.h>
+#include <ctype.h>
+
+#ifndef _WIN32
+
+#include <pwd.h>
+
+static krb5_error_code
+k5identity_init(krb5_context context, krb5_ccselect_moddata *data_out,
+ int *priority_out)
+{
+ *data_out = NULL;
+ *priority_out = KRB5_CCSELECT_PRIORITY_AUTHORITATIVE;
+ return 0;
+}
+
+/* Match data (folded to lowercase if fold_case is set) against pattern. */
+static krb5_boolean
+fnmatch_data(const char *pattern, krb5_data *data, krb5_boolean fold_case)
+{
+ char *str, *p;
+ int res;
+
+ str = malloc(data->length + 1);
+ if (str == NULL)
+ return FALSE;
+ memcpy(str, data->data, data->length);
+ str[data->length] = '\0';
+
+ if (fold_case) {
+ for (p = str; *p != '\0'; p++) {
+ if (isupper((unsigned char)*p))
+ *p = tolower((unsigned char)*p);
+ }
+ }
+
+ res = fnmatch(pattern, str, 0);
+ free(str);
+ return (res == 0);
+}
+
+/* Return true if server satisfies the constraint given by name and value. */
+static krb5_boolean
+check_constraint(krb5_context context, const char *name, const char *value,
+ krb5_principal server)
+{
+ if (strcmp(name, "realm") == 0) {
+ return fnmatch_data(value, &server->realm, FALSE);
+ } else if (strcmp(name, "service") == 0) {
+ return (server->type == KRB5_NT_SRV_HST && server->length >= 2 &&
+ fnmatch_data(value, &server->data[0], FALSE));
+ } else if (strcmp(name, "host") == 0) {
+ return (server->type == KRB5_NT_SRV_HST && server->length >= 2 &&
+ fnmatch_data(value, &server->data[1], TRUE));
+ }
+ /* Assume unrecognized constraints are critical. */
+ return FALSE;
+}
+
+/*
+ * If line begins with a valid principal and server matches the constraints
+ * listed afterwards, set *princ_out to the client principal described in line
+ * and return true. Otherwise return false. May destructively affect line.
+ */
+static krb5_boolean
+parse_line(krb5_context context, char *line, krb5_principal server,
+ krb5_principal *princ_out)
+{
+ const char *whitespace = " \t\r\n";
+ char *princ, *princ_end, *field, *field_end, *sep;
+
+ *princ_out = NULL;
+
+ /* Find the bounds of the principal. */
+ princ = line + strspn(line, whitespace);
+ if (*princ == '#')
+ return FALSE;
+ princ_end = princ + strcspn(princ, whitespace);
+ if (princ_end == princ)
+ return FALSE;
+
+ /* Check all constraints. */
+ field = princ_end + strspn(princ_end, whitespace);
+ while (*field != '\0') {
+ field_end = field + strcspn(field, whitespace);
+ if (*field_end != '\0')
+ *field_end++ = '\0';
+ sep = strchr(field, '=');
+ if (sep == NULL) /* Malformed line. */
+ return FALSE;
+ *sep = '\0';
+ if (!check_constraint(context, field, sep + 1, server))
+ return FALSE;
+ field = field_end + strspn(field_end, whitespace);
+ }
+
+ *princ_end = '\0';
+ return (krb5_parse_name(context, princ, princ_out) == 0);
+}
+
+/* Determine the current user's homedir. Allow HOME to override the result for
+ * non-secure profiles; otherwise, use the euid's homedir from passwd. */
+static char *
+get_homedir(krb5_context context)
+{
+ const char *homedir = NULL;
+ char pwbuf[BUFSIZ];
+ struct passwd pwx, *pwd;
+
+ if (!context->profile_secure)
+ homedir = getenv("HOME");
+
+ if (homedir == NULL) {
+ if (k5_getpwuid_r(geteuid(), &pwx, pwbuf, sizeof(pwbuf), &pwd) != 0)
+ return NULL;
+ homedir = pwd->pw_dir;
+ }
+
+ return strdup(homedir);
+}
+
+static krb5_error_code
+k5identity_choose(krb5_context context, krb5_ccselect_moddata data,
+ krb5_principal server, krb5_ccache *cache_out,
+ krb5_principal *princ_out)
+{
+ krb5_error_code ret;
+ krb5_principal princ = NULL;
+ char *filename, *homedir;
+ FILE *fp;
+ char buf[256];
+
+ *cache_out = NULL;
+ *princ_out = NULL;
+
+ /* Open the .k5identity file. */
+ homedir = get_homedir(context);
+ if (homedir == NULL)
+ return KRB5_PLUGIN_NO_HANDLE;
+ ret = k5_path_join(homedir, ".k5identity", &filename);
+ free(homedir);
+ if (ret)
+ return ret;
+ fp = fopen(filename, "r");
+ free(filename);
+ if (fp == NULL)
+ return KRB5_PLUGIN_NO_HANDLE;
+
+ /* Look for a line with constraints matched by server. */
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ if (parse_line(context, buf, server, &princ))
+ break;
+ }
+ fclose(fp);
+ if (princ == NULL)
+ return KRB5_PLUGIN_NO_HANDLE;
+
+ /* Look for a ccache with the appropriate client principal. If we don't
+ * find out, set *princ_out to indicate the desired client principal. */
+ ret = krb5_cc_cache_match(context, princ, cache_out);
+ if (ret == 0 || ret == KRB5_CC_NOTFOUND)
+ *princ_out = princ;
+ else
+ krb5_free_principal(context, princ);
+ return ret;
+}
+
+krb5_error_code
+ccselect_k5identity_initvt(krb5_context context, int maj_ver, int min_ver,
+ krb5_plugin_vtable vtable)
+{
+ krb5_ccselect_vtable vt;
+
+ if (maj_ver != 1)
+ return KRB5_PLUGIN_VER_NOTSUPP;
+ vt = (krb5_ccselect_vtable)vtable;
+ vt->name = "k5identity";
+ vt->init = k5identity_init;
+ vt->choose = k5identity_choose;
+ return 0;
+}
+
+#endif /* not _WIN32 */
diff --git a/src/lib/krb5/ccache/ccselect_realm.c b/src/lib/krb5/ccache/ccselect_realm.c
new file mode 100644
index 0000000000..3a4b4af136
--- /dev/null
+++ b/src/lib/krb5/ccache/ccselect_realm.c
@@ -0,0 +1,95 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/* lib/krb5/ccache/ccselect_realm.c - realm ccselect module */
+/*
+ * Copyright (C) 2011 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ */
+
+#include "k5-int.h"
+#include "cc-int.h"
+#include <krb5/ccselect_plugin.h>
+
+static krb5_error_code
+realm_init(krb5_context context, krb5_ccselect_moddata *data_out,
+ int *priority_out)
+{
+ *data_out = NULL;
+ *priority_out = KRB5_CCSELECT_PRIORITY_HEURISTIC;
+ return 0;
+}
+
+static krb5_error_code
+realm_choose(krb5_context context, krb5_ccselect_moddata data,
+ krb5_principal server, krb5_ccache *cache_out,
+ krb5_principal *princ_out)
+{
+ krb5_error_code ret;
+ krb5_cccol_cursor cursor;
+ krb5_ccache cache;
+ krb5_principal princ;
+
+ *cache_out = NULL;
+ *princ_out = NULL;
+
+ if (krb5_is_referral_realm(&server->realm))
+ return KRB5_PLUGIN_NO_HANDLE;
+
+ /* Scan the collection for a cache with a client principal in the same
+ * realm as the server principal. */
+ ret = krb5_cccol_cursor_new(context, &cursor);
+ if (ret)
+ return ret;
+ while ((ret = krb5_cccol_cursor_next(context, cursor, &cache)) == 0 &&
+ cache != NULL) {
+ ret = krb5_cc_get_principal(context, cache, &princ);
+ if (ret == 0) {
+ if (data_eq(princ->realm, server->realm))
+ break;
+ krb5_free_principal(context, princ);
+ }
+ krb5_cc_close(context, cache);
+ }
+ krb5_cccol_cursor_free(context, &cursor);
+ if (ret)
+ return ret;
+
+ if (cache == NULL)
+ return KRB5_PLUGIN_NO_HANDLE;
+ *cache_out = cache;
+ *princ_out = princ;
+ return 0;
+}
+
+krb5_error_code
+ccselect_realm_initvt(krb5_context context, int maj_ver, int min_ver,
+ krb5_plugin_vtable vtable)
+{
+ krb5_ccselect_vtable vt;
+
+ if (maj_ver != 1)
+ return KRB5_PLUGIN_VER_NOTSUPP;
+ vt = (krb5_ccselect_vtable)vtable;
+ vt->name = "realm";
+ vt->init = realm_init;
+ vt->choose = realm_choose;
+ return 0;
+}
diff --git a/src/lib/krb5/ccache/deps b/src/lib/krb5/ccache/deps
index a5a6de2034..0c4f411a17 100644
--- a/src/lib/krb5/ccache/deps
+++ b/src/lib/krb5/ccache/deps
@@ -56,6 +56,53 @@ ccdefops.so ccdefops.po $(OUTPRE)ccdefops.$(OBJEXT): \
$(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
$(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
$(top_srcdir)/include/socket-utils.h ccdefops.c fcc.h
+ccselect.so ccselect.po $(OUTPRE)ccselect.$(OBJEXT): \
+ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
+ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
+ $(COM_ERR_DEPS) $(srcdir)/../krb/int-proto.h $(top_srcdir)/include/k5-buf.h \
+ $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
+ $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
+ $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
+ $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
+ $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+ $(top_srcdir)/include/krb5/ccselect_plugin.h $(top_srcdir)/include/krb5/plugin.h \
+ $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
+ $(top_srcdir)/include/socket-utils.h cc-int.h ccselect.c
+ccselect_k5identity.so ccselect_k5identity.po $(OUTPRE)ccselect_k5identity.$(OBJEXT): \
+ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
+ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
+ $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \
+ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \
+ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \
+ $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \
+ $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \
+ $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/ccselect_plugin.h \
+ $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
+ $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
+ cc-int.h ccselect_k5identity.c
+ccselect_realm.so ccselect_realm.po $(OUTPRE)ccselect_realm.$(OBJEXT): \
+ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
+ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
+ $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \
+ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \
+ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \
+ $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \
+ $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \
+ $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/ccselect_plugin.h \
+ $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
+ $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
+ cc-int.h ccselect_realm.c
+cc_dir.so cc_dir.po $(OUTPRE)cc_dir.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
+ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
+ $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \
+ $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
+ $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
+ $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
+ $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \
+ $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \
+ $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
+ $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
+ cc-int.h cc_dir.c
cc_retr.so cc_retr.po $(OUTPRE)cc_retr.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
$(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
$(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../krb/int-proto.h \
@@ -135,4 +182,12 @@ t_cc.so t_cc.po $(OUTPRE)t_cc.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
t_cc.c
t_cccursor.so t_cccursor.po $(OUTPRE)t_cccursor.$(OBJEXT): \
$(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \
- $(COM_ERR_DEPS) $(top_srcdir)/include/krb5.h t_cccursor.c
+ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
+ $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \
+ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \
+ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \
+ $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \
+ $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \
+ $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
+ $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \
+ $(top_srcdir)/include/socket-utils.h t_cccursor.c
diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c
index f244d566eb..40c9f95623 100644
--- a/src/lib/krb5/krb/init_ctx.c
+++ b/src/lib/krb5/krb/init_ctx.c
@@ -288,6 +288,7 @@ krb5_free_context(krb5_context ctx)
ctx->trace_callback(ctx, NULL, ctx->trace_callback_data);
#endif
+ k5_ccselect_free_context(ctx);
k5_plugin_free_context(ctx);
free(ctx->plugin_base_dir);
diff --git a/src/lib/krb5/krb/int-proto.h b/src/lib/krb5/krb/int-proto.h
index 336c045719..9b975ab4ac 100644
--- a/src/lib/krb5/krb/int-proto.h
+++ b/src/lib/krb5/krb/int-proto.h
@@ -178,4 +178,7 @@ krb5int_mk_setpw_req(krb5_context context, krb5_auth_context auth_context,
krb5_data *ap_req, krb5_principal targetprinc,
char *passwd, krb5_data *packet);
+void
+k5_ccselect_free_context(krb5_context context);
+
#endif /* KRB5_INT_FUNC_PROTO__ */
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index a5b05b5fba..cff9d396d5 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -107,6 +107,7 @@ initialize_krb5_error_table
initialize_k5e1_error_table
initialize_kv5m_error_table
initialize_prof_error_table
+k5_ccselect_free_context
k5_free_serverlist
k5_kt_get_principal
k5_locate_kdc
@@ -207,6 +208,7 @@ krb5_cc_remove_cred
krb5_cc_resolve
krb5_cc_retrieve_cred
krb5_cc_retrieve_cred_default
+krb5_cc_select
krb5_cc_set_config
krb5_cc_set_default_name
krb5_cc_set_flags
diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def
index 0afa6e499f..17d15b076f 100644
--- a/src/lib/krb5_32.def
+++ b/src/lib/krb5_32.def
@@ -417,3 +417,4 @@ EXPORTS
krb5_cc_support_switch @391
krb5_cc_switch @392
krb5_free_string @393
+ krb5_cc_select @394