xref: /minix3/crypto/external/bsd/heimdal/dist/lib/krb5/pcache.c (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*	$NetBSD: pcache.c,v 1.1.1.1 2011/04/13 18:15:36 elric Exp $	*/
2*ebfedea0SLionel Sambuc 
3*ebfedea0SLionel Sambuc /***********************************************************************
4*ebfedea0SLionel Sambuc  * Copyright (c) 2010, Secure Endpoints Inc.
5*ebfedea0SLionel Sambuc  * All rights reserved.
6*ebfedea0SLionel Sambuc  *
7*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
8*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
9*ebfedea0SLionel Sambuc  * are met:
10*ebfedea0SLionel Sambuc  *
11*ebfedea0SLionel Sambuc  * - Redistributions of source code must retain the above copyright
12*ebfedea0SLionel Sambuc  *   notice, this list of conditions and the following disclaimer.
13*ebfedea0SLionel Sambuc  *
14*ebfedea0SLionel Sambuc  * - Redistributions in binary form must reproduce the above copyright
15*ebfedea0SLionel Sambuc  *   notice, this list of conditions and the following disclaimer in
16*ebfedea0SLionel Sambuc  *   the documentation and/or other materials provided with the
17*ebfedea0SLionel Sambuc  *   distribution.
18*ebfedea0SLionel Sambuc  *
19*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20*ebfedea0SLionel Sambuc  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21*ebfedea0SLionel Sambuc  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22*ebfedea0SLionel Sambuc  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23*ebfedea0SLionel Sambuc  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24*ebfedea0SLionel Sambuc  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25*ebfedea0SLionel Sambuc  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26*ebfedea0SLionel Sambuc  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*ebfedea0SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28*ebfedea0SLionel Sambuc  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29*ebfedea0SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30*ebfedea0SLionel Sambuc  * OF THE POSSIBILITY OF SUCH DAMAGE.
31*ebfedea0SLionel Sambuc  *
32*ebfedea0SLionel Sambuc  **********************************************************************/
33*ebfedea0SLionel Sambuc 
34*ebfedea0SLionel Sambuc #include "krb5_locl.h"
35*ebfedea0SLionel Sambuc #include "ccache_plugin.h"
36*ebfedea0SLionel Sambuc #ifdef HAVE_DLFCN_H
37*ebfedea0SLionel Sambuc #include <dlfcn.h>
38*ebfedea0SLionel Sambuc #endif
39*ebfedea0SLionel Sambuc #include <assert.h>
40*ebfedea0SLionel Sambuc 
41*ebfedea0SLionel Sambuc krb5_error_code
_krb5_load_ccache_plugins(krb5_context context)42*ebfedea0SLionel Sambuc _krb5_load_ccache_plugins(krb5_context context)
43*ebfedea0SLionel Sambuc {
44*ebfedea0SLionel Sambuc     struct krb5_plugin * plist = NULL;
45*ebfedea0SLionel Sambuc     struct krb5_plugin *p;
46*ebfedea0SLionel Sambuc     krb5_error_code code;
47*ebfedea0SLionel Sambuc 
48*ebfedea0SLionel Sambuc     code = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, KRB5_PLUGIN_CCACHE,
49*ebfedea0SLionel Sambuc                              &plist);
50*ebfedea0SLionel Sambuc     if (code)
51*ebfedea0SLionel Sambuc         return code;
52*ebfedea0SLionel Sambuc 
53*ebfedea0SLionel Sambuc     for (p = plist; p != NULL; p = _krb5_plugin_get_next(p)) {
54*ebfedea0SLionel Sambuc         krb5_cc_ops * ccops;
55*ebfedea0SLionel Sambuc         krb5_error_code c_load;
56*ebfedea0SLionel Sambuc 
57*ebfedea0SLionel Sambuc         ccops = _krb5_plugin_get_symbol(p);
58*ebfedea0SLionel Sambuc         if (ccops != NULL && ccops->version == KRB5_CC_OPS_VERSION) {
59*ebfedea0SLionel Sambuc             c_load = krb5_cc_register(context, ccops, TRUE);
60*ebfedea0SLionel Sambuc             if (c_load != 0)
61*ebfedea0SLionel Sambuc                 code = c_load;
62*ebfedea0SLionel Sambuc         }
63*ebfedea0SLionel Sambuc     }
64*ebfedea0SLionel Sambuc 
65*ebfedea0SLionel Sambuc     _krb5_plugin_free(plist);
66*ebfedea0SLionel Sambuc 
67*ebfedea0SLionel Sambuc     return code;
68*ebfedea0SLionel Sambuc }
69