1 /* $NetBSD: glue.c,v 1.1.1.2 2014/04/24 12:45:27 pettai Exp $ */
4 * Copyright (c) 2005, PADL Software Pty Ltd.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of PADL Software nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * Server-side loopback glue for credentials cache operations; this
41 * must be initialized with kcm_internal_ccache(), it is not for real
42 * use. This entire file assumes the cache is locked, it does not do
43 * any concurrency checking for multithread applications.
46 #define KCMCACHE(X) ((kcm_ccache)(X)->data.data)
47 #define CACHENAME(X) (KCMCACHE(X)->name)
50 kcmss_get_name(krb5_context context
,
56 static krb5_error_code
57 kcmss_resolve(krb5_context context
, krb5_ccache
*id
, const char *res
)
59 return KRB5_FCC_INTERNAL
;
62 static krb5_error_code
63 kcmss_gen_new(krb5_context context
, krb5_ccache
*id
)
65 return KRB5_FCC_INTERNAL
;
68 static krb5_error_code
69 kcmss_initialize(krb5_context context
,
71 krb5_principal primary_principal
)
74 kcm_ccache c
= KCMCACHE(id
);
78 ret
= kcm_zero_ccache_data_internal(context
, c
);
82 ret
= krb5_copy_principal(context
, primary_principal
,
88 static krb5_error_code
89 kcmss_close(krb5_context context
,
92 kcm_ccache c
= KCMCACHE(id
);
102 static krb5_error_code
103 kcmss_destroy(krb5_context context
,
107 kcm_ccache c
= KCMCACHE(id
);
111 ret
= kcm_ccache_destroy(context
, CACHENAME(id
));
116 static krb5_error_code
117 kcmss_store_cred(krb5_context context
,
122 kcm_ccache c
= KCMCACHE(id
);
127 ret
= kcm_ccache_store_cred_internal(context
, c
, creds
, 1, &tmp
);
132 static krb5_error_code
133 kcmss_retrieve(krb5_context context
,
136 const krb5_creds
*mcred
,
140 kcm_ccache c
= KCMCACHE(id
);
145 ret
= kcm_ccache_retrieve_cred_internal(context
, c
, which
,
150 ret
= krb5_copy_creds_contents(context
, credp
, creds
);
157 static krb5_error_code
158 kcmss_get_principal(krb5_context context
,
160 krb5_principal
*principal
)
163 kcm_ccache c
= KCMCACHE(id
);
167 ret
= krb5_copy_principal(context
, c
->client
,
173 static krb5_error_code
174 kcmss_get_first (krb5_context context
,
176 krb5_cc_cursor
*cursor
)
178 kcm_ccache c
= KCMCACHE(id
);
184 return (*cursor
== NULL
) ? KRB5_CC_END
: 0;
187 static krb5_error_code
188 kcmss_get_next (krb5_context context
,
190 krb5_cc_cursor
*cursor
,
194 kcm_ccache c
= KCMCACHE(id
);
198 ret
= krb5_copy_creds_contents(context
,
199 &((struct kcm_creds
*)cursor
)->cred
,
204 *cursor
= ((struct kcm_creds
*)cursor
)->next
;
211 static krb5_error_code
212 kcmss_end_get (krb5_context context
,
214 krb5_cc_cursor
*cursor
)
220 static krb5_error_code
221 kcmss_remove_cred(krb5_context context
,
227 kcm_ccache c
= KCMCACHE(id
);
231 ret
= kcm_ccache_remove_cred_internal(context
, c
, which
, cred
);
236 static krb5_error_code
237 kcmss_set_flags(krb5_context context
,
244 static krb5_error_code
245 kcmss_get_version(krb5_context context
,
251 static const krb5_cc_ops krb5_kcmss_ops
= {
272 kcm_internal_ccache(krb5_context context
,
276 id
->ops
= &krb5_kcmss_ops
;
277 id
->data
.length
= sizeof(*c
);